I am logging power usage data via ESPhome, excerpt of my .yaml file:
- platform: total_daily_energy
name: Heat Pump Total kWh
power_id: heatPumpTotalWatts
filters:
- multiply: 0.001
unit_of_measurement: kWhtime:
- platform: homeassistant
id: homeassistant_time
This works great, dumps into influxdb. In Grafana I’m using 2 queries, query A finds the max() per hour interval, B finds the min() per hour interval, then I plot the expression ($A-$B) as a bar chart. Displays how I want, but there’s an issue at midnight. Specifically, total kWh resets to zero at midnight, but sometimes it resets just prior to midnight, so when I plot max() - min() in 1h intervals, min() for the 23:00-23:59:59 interval returns zero and causes a big spike for the hour interval just before midnight.
I suppose it could also happen where the reset occurs just after midnight causing a big spike for the 0:00-0:59:59 interval.
What are my options for fixing this?