Page 1 of 1
Domoticz device Electricity(Instant + counter), how it works ?
Posted: Tuesday 09 December 2025 13:51
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.
Re: Domoticz device Electricity(Instant + counter), how it works ?
Posted: Tuesday 09 December 2025 15:03
by HvdW
Maybe just send one value. That is instant. The device does the counting.
Want till the next day and see. 00:01
Re: Domoticz device Electricity(Instant + counter), how it works ?
Posted: Tuesday 09 December 2025 15:28
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.
Re: Domoticz device Electricity(Instant + counter), how it works ?
Posted: Tuesday 09 December 2025 16:13
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
Re: Domoticz device Electricity(Instant + counter), how it works ?
Posted: Tuesday 09 December 2025 17:18
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.
Re: Domoticz device Electricity(Instant + counter), how it works ?
Posted: Thursday 11 December 2025 11:40
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.
Re: Domoticz device Electricity(Instant + counter), how it works ?
Posted: Thursday 11 December 2025 12:11
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.
Re: Domoticz device Electricity(Instant + counter), how it works ?
Posted: Thursday 11 December 2025 15:31
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.
Re: Domoticz device Electricity(Instant + counter), how it works ?
Posted: Thursday 11 December 2025 16:06
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.