Sorry for the inprecise title - I just don’t know how to put it better…
So what I want to do is really simple in theory.
I have a Sensor which sends values, and I want home assistant to simply add them endlessly.
So it initially sends 5, home assistant shows 5
it sends 7, home asistant shows 12
it sends 2, home asistsant shows 14
it sends 0.25, home asistsant shows 14.25
and so on
What I’m trying to do with this, is to create a theoretical power consumption sensor. After having tried that within HA last year (Calculate a device's theoretical power comsumption by the time it's on), I now made a simple Node Red flow which just outputs kWh from the time the device was on the last period. BUT I can’t add these numbers within Node Red (which would be even more elegant)…
Basically I want to simulate a Smart plug that counts kWhs by itself, like my trusty Xiaomi mi Smart Plug
Yes, buying additional smart plugs would be an option, but I don’t really see why, for devices that operate at the same wattage all the time (light bulbs, dehumidifiers, space heaters, fans, and so on)
Anyone got an Idea?
EDIT: It would be cool if Home Assistsant had this feature built in, so you can just activate theoretical power consumption for all switches
No the picture is just an example for what I want to do. Tracking the consumption from the Xiaomi switch works just as it should.
What I want to do is to simulate a power-meter for a switch, that does NOT have one built in. (in my case mostly Osram Smart+ Plugs, or Shelly 1)
The only thing I know about them is how long they are on - and I know how much Watt the devices connected to them use. That would be enough to calculate the power consumption … my space heater with 750W was on for 2 hours - that’s 1.5kWh power consumption. Simple… but how do I make a sensor that makes these calculations for me?!
the upper part is for when the switch was on and got tuned off (so it outputs the on time)
The lower part is for the off time (because amrt plugs also use energy when turned off )
The join node shows the rated power comsumption 300 and the time on in milliseconds - the function calculates kWh - this value I will send as an MQTT mesage to Home Assistant
(if you speak German, ignore the naming - it doesn’t make sense right now, because I just copied nodes)
hmmm - I’ll look into that, but I’m pretty sure I already tried it this way
It doesn’t matter if it gets reset every day or so, because the Utility Meter only cares about positive changes - so if it gets set to 0 at midnight and starts from new, the Utility meter still shows correct values
This didn’t work for some reason… the template sensor only showed the same thing my mqtt sensor showed. It didn’t att the values up
I managed to solve it within Node Red - the solution is very simple, I just had to send “0” after sending the last kWh, so the utility_meter always had a positive value to work with
I put the solution in my old thread, because some people might be interested in this too