Hi Tom, I appreciate your help,
I compared all 3 devices -they are identical wifi-plugs. All 3 source sensors that I am using in the Reimann Sum have the device_class power. The first 2 devices Reimann Sum generate the device_class: energy, the 3rd one doesn’t.
After tinkering with setting the cusomize.yml to add the device_class: energy to the 3rd device’s Reimann Sum helper, it still doesn’t pick it up.
Now randomly the 2nd device no longer has device_class: energy.
I’ve attached an image of the diff of the data files that are generated when clicking “Download Diagnostics” on the device screen.
The left is the plug that is not working, the right is the plug that is working. The only diff between them, (besides the dates and names) is the device_class.
I can’t see any reason that this plug would not pick up the device_class based on the information in this thread.
Has anyone got some pointers for how to dig deeper into home assistant to uncover whats happening here?
EDIT:
Ok so reading the code for the helper, it seems the device_class is only updated when the source state updates. This device_class state on the helper doesn’t seem to persist on server restarts, so it has to wait for a new change in the source state.
You can trigger the helper state to update by using the developer console to update the source state.
What is strange though is that while the other 2 devices appear to update the helper state within a few mins, this 3rd one didn’t, ironically this one has much higher usage.
EDIT 2:
Ok so I figured out what’s causing me grief. After realising that the helper won’t be tagged with “device_class: energy” until the source sensor receives an update, I went hunting down for issues related to updates and my device.
I’m using a Kogan Smart Plug device with the Tuya Smart Life app. I found that this is a common problem using Tuya Cloud Tuya smart plug energy monitoring values not updating · Issue #61224 · home-assistant/core · GitHub
I’ve switched to using tuya local and updates are now fairly quick.