Need to measure theoretical power consumption of a device

I need to measure power consumption stats of a device that consume 400w/h and it connected to the power only on certain days so only time template won’t work.
My goal is to create a template that compute the time this device is ‘on’ (as it can be connected but off) and return the theoretical power consumption value in kw/h/

thank you.

No need for a template. Use this integration to calculate the on time:

1 Like

thank you, i will look into it.
but then how do i convert this data into the power used?

Multiply the time on by the assumed power in a template sensor.

1 Like

I’m assuming that {now ()} is the time that the switch turen on an off? the docs dosnt say clearly.
another quasion if i may - for how long this data is saved? is it resets every cycle of ‘on-off’?

start: '{{ 0 }}'
end: '{{ now() }}'

Will tell you how long it has been on since the statistics sensor was created or as far back as your recorder component is set to store without purging (see this note on the page):

If the duration exceeds the number of days of history stored by the recorder component ( purge_keep_days ), the history statistics sensor will not have all the information it needs to look at the entire duration.

1 Like