v1.1.3
Bug fix: first energy delta after cost reset no longer lost (#215)
Affected users: Anyone with a cumulative energy sensor (e.g. a grid import meter or utility meter that keeps incrementing) paired with a daily/weekly/monthly cost reset.
What happened
After a cost reset (daily/weekly/monthly), the internal energy baseline was being cleared to None. The first energy reading after the reset would then set a new baseline and return without calculating any cost — meaning the first energy increase of the new period was silently lost.
This was originally fixed in v0.9.10, but the fix was reverted in v1.0.1 to address a separate bug (#216) where users with daily-resetting source energy sensors were seeing incorrect values.
Root cause
The v1.0.1 fix used a single strategy (_last_energy_reading = None) that works for daily-resetting sensors but breaks cumulative ones.
Fix
EnergyCostSensor.async_reset() now reads the current energy sensor value at reset time and uses it as the new baseline. This means:
- Cumulative sensors (total_increasing): baseline is preserved → first delta after reset is correctly counted
- Daily-resetting sensors already at 0 at reset time: baseline is set to 0 → first delta counted correctly
- Daily-resetting sensors that reset slightly after the cost reset: the existing
current_energy == 0guard handles it - Sensor unavailable at reset: falls back to
Nonebaseline (same as before — first event after reset sets the baseline)
Upgrading
Update via HACS and restart Home Assistant. No configuration changes needed.