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:
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
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 .