P1 device python plugin, how to populate ?

Python and python framework

Moderator: leecollings

Post Reply
willemd
Posts: 735
Joined: Saturday 21 September 2019 17:55
Target OS: Raspberry Pi / ODroid
Domoticz version: 2024.1
Location: The Netherlands
Contact:

P1 device python plugin, how to populate ?

Post by willemd »

In a python plugin I am reading a P1 devices and am getting 3 values:
1) a current actual power value (watts), either positive or negative
2) a total lifetime usage counter kWh
3) a total lifetime return counter kWh
This meter does not give me a high or low tariff usage/return, just a total, which is fine with me.
Currently I am loading those values on 3 separate devices, but I would like to use a P1 device instead.

In the python plugin wiki the P1 description is as show below, so total 10 fields available.

I am gessing the power needs to be put on either CONS or PROD, depending on the sign.
But where to put the 2 other values? On the counter fields and, if so, which ones?

Or on the return/usage fields?
But there the description mentions that it is a "tariff" fields. I would not expect to put financial data in here.
Or should it say "energy usage meter reading for tariff 1" instead of "energy usage meter tariff 1" in the description?
On the other hand, if I would use DZvents or JSON, then I would use usage/return fields for lifetime counter values.
But then, what are the counter fields used for?
Very inconsistent or at least confusing.

And what to do with the other fields, leave blank or fill with zero?

Can't find it here in the forum, since I cannot search for P1, search term too short.

Any advice?

Thanks

Code: Select all

For multi meters (P1 Smart Meter, CM113, Electrisave and CM180i):

Devices[Unit].Update(nValue=nValue, sValue="USAGE1;USAGE2;RETURN1;RETURN2;CONS;PROD;DATE")
USAGE1= energy usage meter tariff 1, This is an incrementing counter
USAGE2= energy usage meter tariff 2, This is an incrementing counter
RETURN1= energy return meter tariff 1, This is an incrementing counter
RETURN2= energy return meter tariff 2, This is an incrementing counter
CONS= actual usage power (Watt)
PROD= actual return power (Watt)
DATE = date with %Y-%m-%d format (for instance 2019-09-24) to put data in last week/month/year history log, or "%Y-%m-%d %H:%M:%S" format (for instance 2019-10-03 14:00:00) to put data in last days history log
or

Devices[Unit].Update(nValue=nValue, sValue="USAGE1;USAGE2;RETURN1;RETURN2;CONS;PROD;COUNTER1;COUNTER2;COUNTER3;COUNTER4;DATE")
as previously, plus absolute counter values
User avatar
waltervl
Posts: 6677
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2025.1
Location: NL
Contact:

Re: P1 device python plugin, how to populate ?

Post by waltervl »

I am gessing the power needs to be put on either CONS or PROD, depending on the sign.
Correct, and if no value, the value = 0
If you only use Tariff1 set the tariff2 values to 0

Code: Select all

sValue="USAGE1;0;RETURN1;0;CONS;PROD"
USAGE1 is your 2) a total lifetime usage counter kWh *1000
RETURN1 is your 3) a total lifetime return counter kWh *1000

Edit: added *1000
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
willemd
Posts: 735
Joined: Saturday 21 September 2019 17:55
Target OS: Raspberry Pi / ODroid
Domoticz version: 2024.1
Location: The Netherlands
Contact:

Re: P1 device python plugin, how to populate ?

Post by willemd »

Thanks for the clarification.

So I just ignore the COUNTER1 to COUNTER4 fields? Out of curiosity, what was their purpose if you have already usage1/2 and return 1/2 fields?

And why does this update require a timestamp while all the other device update in a plugin can do without?
willemd
Posts: 735
Joined: Saturday 21 September 2019 17:55
Target OS: Raspberry Pi / ODroid
Domoticz version: 2024.1
Location: The Netherlands
Contact:

Re: P1 device python plugin, how to populate ?

Post by willemd »

Well, after a full afternoon trying to get this to work, it turns out that you should NOT include a date in the sValue.

So the wiki is wrong. If you include a date the values shows "Invalid!".
User avatar
waltervl
Posts: 6677
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2025.1
Location: NL
Contact:

Re: P1 device python plugin, how to populate ?

Post by waltervl »

You should only add a date if you want the value to land on a specific date in history as you indicated yourself......
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
willemd
Posts: 735
Joined: Saturday 21 September 2019 17:55
Target OS: Raspberry Pi / ODroid
Domoticz version: 2024.1
Location: The Netherlands
Contact:

Re: P1 device python plugin, how to populate ?

Post by willemd »

I created an issue on github to get the wiki corrected. Gizmocuz has already seen it.
User avatar
waltervl
Posts: 6677
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2025.1
Location: NL
Contact:

Re: P1 device python plugin, how to populate ?

Post by waltervl »

Why, the wiki is correct. The part where the date is mentioned is especially for putting counter data in the history log.
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
User avatar
waltervl
Posts: 6677
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2025.1
Location: NL
Contact:

Re: P1 device python plugin, how to populate ?

Post by waltervl »

I updated the wiki to explain it better.
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
willemd
Posts: 735
Joined: Saturday 21 September 2019 17:55
Target OS: Raspberry Pi / ODroid
Domoticz version: 2024.1
Location: The Netherlands
Contact:

Re: P1 device python plugin, how to populate ?

Post by willemd »

Did you check and test ?

The wiki is still incorrect.

The wiki still mentions
Devices[Unit].Update(nValue=nValue, sValue="USAGE1;USAGE2;RETURN1;RETURN2;CONS;PROD;DATE") and
DATE = date with %Y-%m-%d format (for instance 2019-09-24) to put data in last week/month/year history log, or "%Y-%m-%d %H:%M:%S" format (for instance 2019-10-03 14:00:00) to put data in last days history log

Even in latest beta version, any attempt to do an update of P1 using a plugin, with a date+time included in the sValue, results in a "Invalid!" value.
User avatar
waltervl
Posts: 6677
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2025.1
Location: NL
Contact:

Re: P1 device python plugin, how to populate ?

Post by waltervl »

No, I did not test as I did not create that part of the wiki.
But did you set the "AddDBLogEntry" device option to "true"? As that seems to be the way to do when using the extra date.
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
willemd
Posts: 735
Joined: Saturday 21 September 2019 17:55
Target OS: Raspberry Pi / ODroid
Domoticz version: 2024.1
Location: The Netherlands
Contact:

Re: P1 device python plugin, how to populate ?

Post by willemd »

I see that a line has been added to explanation of type 250 as follows:

250 P1 Smart Meter 1 Energy nValue=0, sValue="USAGE1;USAGE2;RETURN1;RETURN2;CONS;PROD" see for more info Domoticz API/JSON URL's#Electricity P1 smart meter

That should do it, since that is the normal and working update statement for P1 meters, although I use it with nValue=the actual CONS/PROD of the moment (based on the info in the section below that). Maybe that does not make a difference.
User avatar
waltervl
Posts: 6677
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2025.1
Location: NL
Contact:

Re: P1 device python plugin, how to populate ?

Post by waltervl »

As stated on the section above the device table python device update commands follow in general the API update rules.
No idea what nvalue does for P1, I think it is ignored but needs a valid numeric value eg 0.
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
willemd
Posts: 735
Joined: Saturday 21 September 2019 17:55
Target OS: Raspberry Pi / ODroid
Domoticz version: 2024.1
Location: The Netherlands
Contact:

Re: P1 device python plugin, how to populate ?

Post by willemd »

waltervl wrote: Saturday 14 February 2026 16:34 As stated on the section above the device table python device update commands follow in general the API update rules.
No idea what nvalue does for P1, I think it is ignored but needs a valid numeric value eg 0.
Yes, tested, nValue 0 or actual power does not make a difference.
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest