Hi everyone,
I’m trying to create a template sensor in Home Assistant that continuously calculates the average power consumption within fixed 15-minute intervals. The sensor should reset when a new quarter starts and only include values from the current quarter.
What I Want to Achieve:
- The quarter starts at fixed timestamps (e.g., 18:00, 18:15, 18:30, etc.).
- If I check at 18:05, it should calculate the mean power from 18:00 to 18:05.
- If I check at 18:44, it should calculate the mean power from 18:30 to 18:44.
- When a new quarter starts, the sensor should reset and only consider the new period.
The calculation should be based on sensor.p1_meter_power
(real-time power measurement).
The reason I need it, is because the electricity bill here (in Belgium) is partially based on a “capacity tarrif”, which is based on the average power consumption on each of these 15 minute intervals. So if 10 minutes of the 15 minutes have passed, I would like to have a warning from HA to reduce my consumption for the remained of the time.
Does anyone know how to approach this?