#Indirect power consumption tracking

1 messages · Page 1 of 1 (latest)

woeful zealot
#

Hey. I'm fairly new to HA. I want to track my oil heater/boilers oil consumption. It's a single stage device. It's either on or off. I hooked up a shelly EM so I get good data for it's electricity use.

What I would like HA to do is. Read the power consumption. If consumption is above ~260W f.e. record time above said power reading. Then this time has to be stored and with some simple math converted to litres/hr.

I have no idea how I can setup such thing that ultimately gives me a calculated reading on the oil consumption. Who can help point me the right direction?

unreal zinc
#

You could make a threshold sensor. And you can apply a history stats to that to get the runtime.

Only downside, you are limited by the length of the recorder for the runtime periode... You could make it a weekly resetting sensor (for example, make start always Sunday 24:00) and apply a utility meter to get an all time sensor.

woeful zealot
#

Thanks a lot I will look into it

woeful zealot
#

ok i tried my best. threshold sensor is up and running. collecting the right data that way works but i fail on the history stats part

#

looks like it has to be timestamp but that would include a specific day which i would need to replace with "today" again. Well trying to figure out how to do that
edit: i could have thought of that - to fix the history stats error you have to remove the start " "

woeful zealot
#

i removed the time .. the blue numbers.. now it appears to function correctly.. interesting

#

ok i could put the numbers back and it still works. now im confused 😄

woeful zealot
#

Water heating i could isolate. had a little mistake in the heating one so i need to wait to see if it catches those as well now.
To get better Data i would like add f.e. 4min to every event so that i catch the full time the heater is burning oil? i guess there is another helper that can do that - i will dig around a little

woeful zealot
#

Ok. Got the measurement for heating and warm water split and also history stats is no working. For history stats to work the state needs to be lowercase only

#

Still trying to figure out how I could cleanly track warm water as I would either need to add a fixed amount of minutes to every event or alternatively track just all events and subtract the heating events to get the resulting warm water events. Likely requires a template sensor that does the math. Now I will need to figure out how to do that

#

Programming is not my thing 😅

woeful zealot
#

Just tried to collect the recorded ON states with the utility meter. Number it got is correct but the internal conversion seems off 0.xxx results in multiple hrs :/ looks like it's counting in days but ive set it to count hrs.. maybe need to play with it a little more

woeful zealot
#

fixed - so the history stats has to collect the time in days so that the utility meter will get the data in the right format. things you learn along the line

woeful zealot
#

What did I miss here? I tried to isolate water heating but due to how the power usage graph that won't work. So alternatively I can get the water heating by taking all heating even and subtract all Events that are non water heating to get a correct number but it doesn't work yet.. I guess I need to have a more sophisticated script in the binary template sensor but I don't know what I would need :/

wide cape
#

Quickly reading through this thread, it looks to me like you’re creating problems faster than you can solve them. Is this template binary sensor related to your original problem?

#

If I just focus on solving your very last issue:
A template binary sensor needs to resolve to true or false. I believe if it resolves to a number, 0 will be false and all other numbers will be true.
Additionally, states are always strings, and if you want to perform math on two states, you must cast them to numbers (float or int) first

woeful zealot
#

this template sensor should calculated what i see here. The top sensor in the screenshot is showing all heating events while the bottom one filters for the ones for room heating. as you can see there is one event that is not in the bottom one - thats the water heating one. I want to substract top from bottom to get the resulting water heating events.
Adding the int/float to the states in the sensor didnt work unfortunately. Its still saying the sensor is unavailable.

#

ok ok .. ive just gemini for help. looks like it did provide something that actually maybe works 😄 maybe you could verify that this is an appropriate script?

{% set sensor2_state = states('binary_sensor.em_detect_heizen_2') | float(0) %}
{% set differenz = sensor1_state - sensor2_state %} ```
woeful zealot
#

That above script was accepted by ha but doesn't work unfortunately. I mean I'm sitting here with the docu and chat gpt and try to make sense out of that but somehow it doesn't give me the correct results. The above template sensor returns 'off' even if it should be on

wide cape
#

That template doesn’t output anything

#

Try this:

{% set sensor1_state = states('binary_sensor.em_heizung_gesamt') | float(0) %}
{% set sensor2_state = states('binary_sensor.em_detect_heizen_2') | float(0) %}
{{ sensor1_state - sensor2_state }}

Again, this will only be off when the result is exactly zero. In all other cases it will be true

woeful zealot
#

That should work as most of the time the sensor would do either 0-0 or 1-1 which results both to zero whereas the remaining cases it's is 1-0 scenario