Domoticz device Electricity(Instant + counter), how it works ?

Moderator: leecollings

Post Reply
Michel13
Posts: 77
Joined: Thursday 07 January 2016 19:31
Target OS: Raspberry Pi / ODroid
Domoticz version: 2024.7
Location: France
Contact:

Domoticz device Electricity(Instant + counter), how it works ?

Post by Michel13 »

Hello,

I have setup one dummy device Electricity(Instant + counter) where I send values collected from a ShellyEM by MQTT.
The available data I collect are instant power and total power (persistent recording).

I have no problem with the instant value. The counter part is an other story and I don't understand how it works. On the device itself this value is noted as Daily so I supposed it is the daily consumption. But it is not clear to me if that is really a counter or a simple indication.

For the time being, I am able to send the svalue <instantpower>;<countervalue> to the device but counter part reported is different from the value transmitted and apparently not working as a counter as well (not increasing at the same pace than the value transmitted). The <countervalue> I send is treated differently by the device.

Is there in the Domoticz wiki or somewhere else a clear explanation how this counter works ? Is it incremental ? If so, what value is expected and on which base the increment works ? Is there a daily reset ?

Thanks for your help.
HvdW
Posts: 663
Joined: Sunday 01 November 2015 22:45
Target OS: Raspberry Pi / ODroid
Domoticz version: 2023.2
Location: Twente
Contact:

Re: Domoticz device Electricity(Instant + counter), how it works ?

Post by HvdW »

Maybe just send one value. That is instant. The device does the counting.
Want till the next day and see. 00:01
Bugs bug me.
Michel13
Posts: 77
Joined: Thursday 07 January 2016 19:31
Target OS: Raspberry Pi / ODroid
Domoticz version: 2024.7
Location: France
Contact:

Re: Domoticz device Electricity(Instant + counter), how it works ?

Post by Michel13 »

Thank you for the reply.

The problem is not to send a value. This is ok. I would like to know which value to send.

For the time being, the one I send to the counter part of the device is the daily power consumption calculated from the actual total power minus the total power recorded at midnight. Hence, this calculation gives the daily consumption at present time. While this value is properly sent to the device, this last one use it on a way unclear to me.
Obviously, the calculated value is quite big and increases at each step. So using it for incrementing the previous value would give a very big total. Moreover this could be tremendous because measurements are made at short period of time. It is not the case. So I wonder what this counter is expected to receive in order to work properly.
Apparently, there is a sort of counting because the value reported is different from the one sent. The question is, how it works.
User avatar
gizmocuz
Posts: 2709
Joined: Thursday 11 July 2013 18:59
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: Top of the world
Contact:

Re: Domoticz device Electricity(Instant + counter), how it works ?

Post by gizmocuz »

You should provide an incremental counter... not a counter that is being reset on a daily basis...
I also have shelly devices (em), and they are not reset.
If you want to be able to support a resetting counter, I advise to use the latest beta version, and use MQTT Auto Discovery, as this detects a wrap and continue counting.

I hereby give you two config topics for kWh/Watt


homeassistant/sensor/0x842e14fffe12676e/power/config
{"availability":[{"topic":"zigbee2mqtt/bridge/state","value_template":"{{ value_json.state }}"}],"device":{"hw_version":1,"identifiers":["zigbee2mqtt_0x842e14fffe12676e"],"manufacturer":"Tuya","model":"10A UK or 16A EU smart plug","model_id":"TS0121_plug","name":"WCD_PC_Rob","via_device":"zigbee2mqtt_bridge_0x00124b0021cc4112"},"device_class":"power","enabled_by_default":true,"object_id":"wcd_pc_rob_power","origin":{"name":"Zigbee2MQTT","sw":"2.6.0-dev","url":"https://www.zigbee2mqtt.io"},"state_class":"measurement","state_topic":"zigbee2mqtt/WCD_PC_Rob","unique_id":"0x842e14fffe12676e_power_zigbee2mqtt","unit_of_measurement":"W","value_template":"{{ value_json.power }}"}

homeassistant/sensor/0x842e14fffe12676e/energy/config
{"availability":[{"topic":"zigbee2mqtt/bridge/state","value_template":"{{ value_json.state }}"}],"device":{"hw_version":1,"identifiers":["zigbee2mqtt_0x842e14fffe12676e"],"manufacturer":"Tuya","model":"10A UK or 16A EU smart plug","model_id":"TS0121_plug","name":"WCD_PC_Rob","via_device":"zigbee2mqtt_bridge_0x00124b0021cc4112"},"device_class":"energy","enabled_by_default":true,"object_id":"wcd_pc_rob_energy","origin":{"name":"Zigbee2MQTT","sw":"2.6.0-dev","url":"https://www.zigbee2mqtt.io"},"state_class":"total_increasing","state_topic":"zigbee2mqtt/WCD_PC_Rob","unique_id":"0x842e14fffe12676e_energy_zigbee2mqtt","unit_of_measurement":"kWh","value_template":"{{ value_json.energy }}"}

They belong together
Quality outlives Quantity!
Michel13
Posts: 77
Joined: Thursday 07 January 2016 19:31
Target OS: Raspberry Pi / ODroid
Domoticz version: 2024.7
Location: France
Contact:

Re: Domoticz device Electricity(Instant + counter), how it works ?

Post by Michel13 »

Thanks gizmocuz.

Sorry but I don't know what to do with the config you suggest. It is obscur to me.

I have an other device use(electrical) giving the total power. This is the direct reading (in Wh) of this value issued from the shelly. No counting, no calculation, just the value.

The initial choice of the Electricity(instant + counter) device is to get the instant power and daily consumption in a single device (if that is the purpose of this device). So its automatic daily reset (if again available with this device) is what I am looking for.
To be clear, I do not intend to reset the shelly! It works perfectly as is.
Like for the total power, the instant power is straight from the shelly. This works like a charm.
My concern (and I am probably not alone) is the counter part of this device. What require this counter to work properly is what I would like to understand. I can do calculations to send the proper data to this counter but without knowing what is expected, difficult to put in place a proper code to set this value.

Some explanation would be of great help.
Michel13
Posts: 77
Joined: Thursday 07 January 2016 19:31
Target OS: Raspberry Pi / ODroid
Domoticz version: 2024.7
Location: France
Contact:

Re: Domoticz device Electricity(Instant + counter), how it works ?

Post by Michel13 »

I reply to myself.
This is not a counter, only an indicator. The value shown is the value sent. Simple.
The name "counter" and its "daily" status in the device itself are confusing.
Obviously, there is no daily reset, no increment, nothing.
If you want daily consumption then you have to do your own calculation in a script.
User avatar
waltervl
Posts: 6678
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2025.1
Location: NL
Contact:

Re: Domoticz device Electricity(Instant + counter), how it works ?

Post by waltervl »

Michel13 wrote: Thursday 11 December 2025 11:40 If you want daily consumption then you have to do your own calculation in a script.
Domoticz can do this for you without scripting, depends what you can send to domoticz.
For example if you get a Watt value that updates every minute you can put that into a virtual Domoticz Electric (Instant+Counter) device.
That device has a calculate option to calculate the usage (hourly/daily/monthly/yearly) in Kwh from that updating Watt value.
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
Michel13
Posts: 77
Joined: Thursday 07 January 2016 19:31
Target OS: Raspberry Pi / ODroid
Domoticz version: 2024.7
Location: France
Contact:

Re: Domoticz device Electricity(Instant + counter), how it works ?

Post by Michel13 »

@waltervl, interesting.

Is it the single option available "Energy read computed" ?
It is just for my information and also to help others because in the mean time I have found other ways to get instant, daily and total values in devices.

Just a remark regarding the W per minute. This is available in the shelly (value : energy). However, I have used it in an incremental counter and the result is not accurate. There is a slight but constant drift from the total given by the shelly because of the rounding of this value made by the shelly itself. So better to use the total. Even for the daily consumption, better to save the total at midnight in a json and deduct the value from the actual total to get the proper value. Much more accurate at the end of the day.
So I use only instant power value and total power value from the shelly.
User avatar
waltervl
Posts: 6678
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2025.1
Location: NL
Contact:

Re: Domoticz device Electricity(Instant + counter), how it works ?

Post by waltervl »

It is always better to use a running total counter (like the old fashioned electricity meter in your home) to fill a domoticz device. That way you have the most reliable result in Domoticz.
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest