I have a sensor that mesures the current used at all time, so i want to transform it to kWh, which i have done with a template sensor (see code at the bottom), the template sensor works fine, but it doesn’t turn up as a device in the energy management. Somebody suggested using “last_reset” but that doesn’t seem to be possible with a template sensor? I get a config error if i use “last_reset”. Any tips?
this is the first version, data goes into the new statistics database, I’m sure we’ll be able to do what we want with data. the default view is the daily one.
Thanks a lot, I will try that out. Do you know if they have plans to change this? Seems like quite a roundabout way to do it, and not all that intuitive (at least not for me :))
Sensors for long-term statistics need specific attributes in order to be managed correctly. The last_reset attribute is needed in order to understand if it’s a lifetime sensor (it never resets) or if it has to be treated like a daily cumulative sensor, that resets at a specific time. The state_class attribute is needed in order to treat appropriately with the new long-term statistics db: Sensor Entity | Home Assistant Developer Docs
These workarounds with template and customize are not a solution. the thing to do is ask the dev of the integration/component that creates the sensor you use, to set the appropriate attributes on all energy sensors, that’s all. These workarounds are needed in this initial period, hoping that all these integrations get updated to support these new features.
The sensor isn’t an energy sensor, it just measures the current (Amps) of the device. But hopefully the energy measurement will support that kind of sensor in the future, I really like the energy feature
It won’t. An energy integration has to be fed with energy sensors, not current sensors.
What’s the point of measuring only current? What about power? In your template, you multiply by 240, like power is a constant, but it isn’t. If you measure Voltage, you’ll notice it can be +/- 5-10% respect to what you think. So your templeate sensor will never be accurate.
I hope you prediction isn’t right, It should be pretty easy to calculate in the energy from the current (or power for that matter). But we will see, I am at least hopeful.
That is what is measured by the device, sure, it would be nice if it also measured kWH, but you work with the hardware you have. I guess they have a somewhat purist approach as it (as many things like this) only actually measures current, and can’t handle reactive power and the like very good, even if it can assume there is only active power.
Yeah, proper energy meters do that, quite a few of the simple ones integrated in devices that does other things doesn’t measure power factor. But you are right, we can’t be sure the energy is right when just measuring the current.
That’s why the approach is: feed the energy integration with energy sensors, and it’s your responsibility to make sure those sensors provide accurate values. What you get out of the energy card depends on what you put in, excluding bugs, obviously…
On to something else: Is it possible to give energy measurement devices a “class” so i can see a breakdown of my energy use (example, having energy going to heating being colored in red in the bar, and the rest having the standard blue color?) or eventually coloring different individual devices in a different color?
Well u probably could use grafana to do this together with influx db.
Or just use code editor.
for example: By assign the current sensor.energy to blue and other sensor.energy to red, so classes are not needed.
Or use the attributes of a sensor if they have one, containing your data what u need