Add_ele, smart plugs and energy consumption monitoring, log every arriving data packet for data points, smart meters2

Smart Plugs like GNCC SP12 do have full energy consumption monitoring even though they don’t have a “total_forward_electricty” data point like the smartmeters have. The only datapoint they have is “add_ele” (add_electricity), which in fact provides the information how many Wh have been consumed since the arrival of the previous add_ele data point data packet. Usually such a packet arrives every 30 minutes.

In the Tuya Cloud the device log records every single arriving data packet in the last week, and this permits to filter the device log for all add_ele packets having arrived at the Tuya Cloud, sum all these values up and that way get your “total_forward_electricity” energy consumption, and this is very accurate even with fluctuating amperage and power.

So the formula is:

total_forward_electricity=sum of all transmitted add_ele packets

Now, Home Assistant does appear to NOT support this behaviour. It only depends on “change of the value” to trigger events, I can not find any trigger upon arrival of a packet for a specific device, specific data point within that device irrespective of its value. Yes, if the value changes, then it triggers indeed, but not, if add_ele instructs to add say 17Wh (0.017kWh) four times in a row or so, meaning in two hours it adds 0,068kWh (or if you like, add_ele reads 1000 four times in a row, meaning it adds 4kWh within 2 hours).

Requests therefore for both Home Assistand and Local-Tuya:

Permit energy monitoring to be fully supported (also see below).

Permit add_ele to be fully supported, so that whenever an add_ele packet arrives from whatever device, trigger (in general: upon arrival of a datapacket activate a trigger if so requested, regardless of whether the value has changed or not).

Permit a construct similiar to Tuya’s original device log logging every single data backet with its data points, and actually, make this default behaviour and accessible via REST API etc. of Home Assistant for every single device and datapoint just like the Tuya cloud. I am sure, that the value of add_ele, being a mystery for so many years and not being understood for years, would have been discovered very quickly with such a tool.

With the phase_a field in the smart meters, base64 encoded voltage, current and power fields, we have a similiar issue that Home Assistant and local-tuya don’t support this natively despite the generic nature of this field. It took me a whole day to finally find out how to implement this decoding and implement this (with the same problem as above, not all arriving packets trigger the update and decoding!)

Energy Monitoring by taking the power fields and multiple by time also don’t work reliably because repeated same values do get lost.

So overall, Home Assistant, other than the Tuya Cloud which does permit tracking of each single data packet arriving, does NOT support energy consumption monitoring unless a total_forward_electricity (or similiar) field is being provided by the device and its sensors.

And this is the reason for this urgent request so that the tracking (and summation) of each single packet, even if seemingly transmitting the same value over and over, becomes possible.

Thank you!

Thanks for this suggestion, I have the exact same problem with several Konyks (Tuya compatible) sockets and also some Tuya compatible cirtcuit breakers (with power metering). I reported one problem to the new Tuya integration Github here (add_ele was not declared in sockets) and tried adding it manually. But then I noticed the issue with the duplicate value being skipped, causing incorrect sum in HA. And I spent a couple days looking at the code and trying other things (like “total” and “measurement” as state_class) but couldn’t fix the problem.

Seeing how all of my power metering devices from two different brands bought several years apart all have the same data reporting, I expected this would be a solved problem in HA so I was quite surprised. Maybe we missed something here?

How are we (or the integration developers) supposed to deal with such sensor returning delta kWh to avoid the dedup of similar values?

I have 25 devices (konyks smart plug, tongou rail din) with the same issue.
This is request made long time ago by several people in other topics.
upvote ++

Just an idea: could the integration trigger an additional sensor change to zero with each add_ele packet?

I also bought a Tuya device to now find out about this issue.

I join the request

upvote, please a solution/tip?

Could you use a very recent value for
last_reset:
in the sensors attributes?
I imagine always saying its been reset will result in it adding the difference between 0 and the value rather than last value and current value.

Hi,

Looking forward to having this data integrated in HA.