I do play around with power metering and the new energy dashboard using ESPHome Devices. Some of my devices do have a metering unit integrated which report the “power” needed to populate data with the “Total Daily Energy Sensor”
No I have some ESPHome devices which do not have any metering option, but I know the sources connected to it. Those are mainly light bulbs which have a fixed power usage which I could simply measure.
I read about people using HA to get the data calculated, but I would rather let ESPHome Devices report it directly to HA - which I find is more useful (perhaps also only in my scenario).
Can somebody help me in getting this working, some links would already be good.
What I found, but I am struggling to understand how and if I can convert this to ESPHome:
Also I am wondering if I really need Integration - Riemann sum integral - Home Assistant because it seems like the Energy Dashboard is doing this if the correct sensor “Total Daily Energy Sensor” is used with ESPHome Devices.
I know you want to implement something within ESPHome itself, but take a look at this HACS repository, I use it almost exclusivley for all my sensors on the network as its extremely easy to use and does everthing for you.
Its called Power Calc https://github.com/bramstroker/homeassistant-powercalc
Looks great, little too much for what I am looking for, but I take it into consideration
Anyhow, as you have stated, want to get this into ESPHome directly would be my preferred route.
thanks that helped me, even though I have some questions but first what I have used to accomplish a power and energy information for devices without an energy sensor
It seems to work, but the lambda feature is a little mystery for me, or especially the if statement the id part I get, referencing to the relay but the state behavior is unclear if it is true or false.
I tried to use things like on_turn_on or turn_on instead because I thought this would be the right one to get the this validated but I was too stupid.
Anyhow it seems to work but I cannot find information when state is true or false perhaps someone can help me and / or make the yaml even “better”
The state of the relay is declared as a bool in the source code for a switch. So it considered as a c++ boolean. So that actually means that it ‘0’ when false and something else when it true.
So esphome is working by generating c++ code that is compiled. So if you want answerers you can checkout the source code.
Here is the state for the switch:
I hope it helps you with your understanding .
/Mattias