P1 meter connection problems

Please use template to report bugs and problems. Post here your questions when not sure where else to post
Only for bugs in the Domoticz application! other problems go in different subforums!

Moderators: leecollings, remb0

Forum rules
Before posting here, make sure you are on the latest Beta or Stable version.
If you have problems related to the web gui, clear your browser cache + appcache first.

Use the following template when posting here:

Version: xxxx
Platform: xxxx
Plugin/Hardware: xxxx
Description:
.....

If you are having problems with scripts/blockly, always post the script (in a spoiler or code tag) or screenshots of your blockly

If you are replying, please do not quote images/code from the first post

Please mark your topic as Solved when the problem is solved.
Post Reply
marcovz
Posts: 5
Joined: Tuesday 10 November 2020 20:22
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

P1 meter connection problems

Post 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 919 times
Knipsel.JPG
Knipsel.JPG (62.68 KiB) Viewed 919 times
Knipsel2.JPG
Knipsel2.JPG (80.24 KiB) Viewed 919 times

Anybody an idea how to solve the issue?

Thanks, Marco
User avatar
waltervl
Posts: 5714
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: P1 meter connection problems

Post 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
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
FlyingDomotic
Posts: 349
Joined: Saturday 27 February 2016 0:30
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.2
Contact:

Re: P1 meter connection problems

Post 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.
User avatar
waltervl
Posts: 5714
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: P1 meter connection problems

Post 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.
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
PierreT
Posts: 51
Joined: Wednesday 03 May 2023 10:12
Target OS: NAS (Synology & others)
Domoticz version:
Contact:

Re: P1 meter connection problems

Post 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...
FlyingDomotic
Posts: 349
Joined: Saturday 27 February 2016 0:30
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.2
Contact:

Re: P1 meter connection problems

Post 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.
User avatar
waltervl
Posts: 5714
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: P1 meter connection problems

Post 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
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
FlyingDomotic
Posts: 349
Joined: Saturday 27 February 2016 0:30
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.2
Contact:

Re: P1 meter connection problems

Post 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!
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests