Page 1 of 1

P1 meter connection problems

Posted: Thursday 25 July 2024 23:41
by marcovz
Recently I have some problems with my p1 meter. It is directly connected with usb to the pi hosting domoticz. I got some very high readings and errors in the log file. I have already changed P1 meter cable and used an older back up of the database, but the error remains.
domoticz p1 meter.JPG
domoticz p1 meter.JPG (156.02 KiB) Viewed 922 times
Knipsel.JPG
Knipsel.JPG (62.68 KiB) Viewed 922 times
Knipsel2.JPG
Knipsel2.JPG (80.24 KiB) Viewed 922 times

Anybody an idea how to solve the issue?

Thanks, Marco

Re: P1 meter connection problems

Posted: Friday 26 July 2024 0:06
by waltervl
Domoticz is not getting complete messages.
It could be related to radio interference on the USB cable from something close by or the power supply of your RPi cannot power the USB interface anymore.. See for example https://github.com/home-assistant/core/issues/94609

Re: P1 meter connection problems

Posted: Friday 26 July 2024 16:04
by FlyingDomotic
There's a generic issue with counters in Domoticz.

Values stored in short and long term tables (for example Meter and Meter_Calendar) are based on last interval highest and lowest values difference.

If, for some reason (like changing battery, rebooting device or more commonly clearing counter at midnight) a counter is reset, then last interval value is stored as old (high) counter value (minus new reset counter), giving a (very) high value.

As of now, until a fix is done in Domoticz code, the only way to fix this is to have 2 devices and a small script which stores previous counter value, and compare new counter with previous one. If new counter is higher, then difference (new - previous) is added to second counter value, else (new counter is lower, meaning counter has been reset), only new counter value is added to second counter value.

I'll propose implementing such kind of change in a future version of Domoticz, eventually with an "always incrementing counter" flag.

Re: P1 meter connection problems

Posted: Friday 26 July 2024 21:38
by waltervl
FlyingDomotic wrote: Friday 26 July 2024 16:04 There's a generic issue with counters in Domoticz.

Values stored in short and long term tables (for example Meter and Meter_Calendar) are based on last interval highest and lowest values difference.

If, for some reason (like changing battery, rebooting device or more commonly clearing counter at midnight) a counter is reset, then last interval value is stored as old (high) counter value (minus new reset counter), giving a (very) high value.

As of now, until a fix is done in Domoticz code, the only way to fix this is to have 2 devices and a small script which stores previous counter value, and compare new counter with previous one. If new counter is higher, then difference (new - previous) is added to second counter value, else (new counter is lower, meaning counter has been reset), only new counter value is added to second counter value.

I'll propose implementing such kind of change in a future version of Domoticz, eventually with an "always incrementing counter" flag.
That is not really the issue here.... And I am not sure what you are referring to. Perhaps better make a new topic.
Besides if there is a unreal high value you can always remove it from the database with shift-click on the value in the Domoticz graph.

Re: P1 meter connection problems

Posted: Saturday 27 July 2024 0:01
by PierreT
FlyingDomotic wrote: Friday 26 July 2024 16:04 There's a generic issue with counters in Domoticz.

Values stored in short and long term tables (for example Meter and Meter_Calendar) are based on last interval highest and lowest values difference.

If, for some reason (like changing battery, rebooting device or more commonly clearing counter at midnight) a counter is reset, then last interval value is stored as old (high) counter value (minus new reset counter), giving a (very) high value.

As of now, until a fix is done in Domoticz code, the only way to fix this is to have 2 devices and a small script which stores previous counter value, and compare new counter with previous one. If new counter is higher, then difference (new - previous) is added to second counter value, else (new counter is lower, meaning counter has been reset), only new counter value is added to second counter value.

I'll propose implementing such kind of change in a future version of Domoticz, eventually with an "always incrementing counter" flag.
uhm.. no. The shortlog is simply a 5 minute interval audit trail of device state. If you see spikes in the day graph this is either because you received corrupted data or you did not receive data for some time (which appears to be the case here) and when valid data is eventually received the usage increase will be superimposed on that specific 5 minute interval, i.e. the graphing tool does not include some clause that says if higher than limit do linear regression all the way back to previous known increment.

You are right about the long term log. Calculations are done here and in the case of P1 this sets day usage as last known value minus first known value. Typically this means you will miss a small amount of usage every day (10 seconds if your meter is < ESMR 5). Somewhat of an annoyance is that month views are created by summing the days, so if your system was down around midnight on some days Domoticz will never recover the lost data. I believe that this is a deliberate choice to allow meter swap, however I don't think meter swaps occur more often than restarts and crashes...

Re: P1 meter connection problems

Posted: Tuesday 30 July 2024 11:21
by FlyingDomotic
You're right!

I checked in updateMeter code, last read value from deviceStatus is effectively stored in short term log.

Hue change i saw if due to automatic change of device offset by a script to keep value in line with physical counter.

My mistake...

However, issue still exists for long term log. To mitigate it, I added a second counter, same type, and increment it from difference between last value and current one, except for reset where I add current value.

I think I'll open an issue/enhancement request for that.

Re: P1 meter connection problems

Posted: Tuesday 30 July 2024 14:13
by waltervl
FlyingDomotic wrote: Tuesday 30 July 2024 11:21 I think I'll open an issue/enhancement request for that.
Better first make a new forum topic in suggestions subforum describing your situation and what you like to fix. Because I still don't get it and this is not the place to discuss. https://www.domoticz.com/forum/viewforum.php?f=31

Re: P1 meter connection problems

Posted: Tuesday 30 July 2024 14:35
by FlyingDomotic
waltervl wrote: Tuesday 30 July 2024 14:13
FlyingDomotic wrote: Tuesday 30 July 2024 11:21 I think I'll open an issue/enhancement request for that.
Better first make a new forum topic in suggestions subforum describing your situation and what you like to fix. Because I still don't get it and this is not the place to discuss. https://www.domoticz.com/forum/viewforum.php?f=31
Done!
Thx!