How to add-up running time

I have installed a solar collector on my rooof. The temperature of the water in the boiler (which go to the waterheater for my shower) and the solarcollector are measured. In case the solarcollector temperature is higher than the water temperature the pump is started.

Because the solarcollector is a little too small, the pump is switch on and off. What I would like to report in homeassistant is the total running time every day. So I need to add up the running times (status is on) and reset to zero at midnight.

How do I get the on and off times and add up the times and how do I do a reset at midnight


You should use the History Statistics component.

Your config would look something like this:

 - platform: history_stats
   name: Solar Heater Pump - Time Running Today
   entity_id: your_entity_id
   state: 'on'
   start: '{{ now().replace(hour=0).replace(minute=0).replace(second=0) }}'
   end: '{{ now() }}'

To get the time that the solar pump was not running you’d create a second sensor and change it to track the state when it’s off.

Thanks, it worked