Hello,
I have a sensor, which counts the gas/energy consumption over the whole day and resets on midnight (see below). Now I want another sensor, which gives me the total energy consomption for the whole day, e.g., the max value from the sensor shown for a wohle day. It is possible to get the max value for the last 24h hours, but I need the max-value from midnight to midnight? I possible, I don’t want to work with automations, since the data might get broken, if Hassio doesn’t work at midnight (due to server restarts, backup etc.).
The best way would a template like
{{ max(states('sensor.energy_consumption_heating') from('midnight_two_days_ago') to('midnight_last_day') ) }}
The start and end timestamps are easy to get, but I don’t know how to use them in combination with max
{% set midnight_last_day = 86400*((as_timestamp(now())/86400) | int(0)) %}
{% set midnight_two_days_ago = 86400*((as_timestamp(now())/86400) | int(0) - 1) %}
{{ midnight_last_day }}
{{ midnight_two_days_ago }}