Page 1 of 1

P1 device python plugin, how to populate ?

Posted: Friday 13 February 2026 9:33
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

Re: P1 device python plugin, how to populate ?

Posted: Friday 13 February 2026 10:58
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

Re: P1 device python plugin, how to populate ?

Posted: Friday 13 February 2026 11:31
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?

Re: P1 device python plugin, how to populate ?

Posted: Friday 13 February 2026 16:52
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!".

Re: P1 device python plugin, how to populate ?

Posted: Friday 13 February 2026 18:36
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......

Re: P1 device python plugin, how to populate ?

Posted: Friday 13 February 2026 19:15
by willemd
I created an issue on github to get the wiki corrected. Gizmocuz has already seen it.

Re: P1 device python plugin, how to populate ?

Posted: Friday 13 February 2026 22:21
by waltervl
Why, the wiki is correct. The part where the date is mentioned is especially for putting counter data in the history log.

Re: P1 device python plugin, how to populate ?

Posted: Saturday 14 February 2026 0:05
by waltervl
I updated the wiki to explain it better.

Re: P1 device python plugin, how to populate ?

Posted: Saturday 14 February 2026 7:14
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.

Re: P1 device python plugin, how to populate ?

Posted: Saturday 14 February 2026 11:47
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.

Re: P1 device python plugin, how to populate ?

Posted: Saturday 14 February 2026 15:11
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.

Re: P1 device python plugin, how to populate ?

Posted: Saturday 14 February 2026 16:34
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.

Re: P1 device python plugin, how to populate ?

Posted: Saturday 14 February 2026 16:36
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.