Skip to content

fix: restart-inflation & init-race

Choose a tag to compare

@hoizi89 hoizi89 released this 28 Apr 11:11

🐛 Bug Fixes

Two related bugs that caused energy values to inflate after HA reload or HACS update.

Fixes #4Self-Consumption equals Total PV Production

If your Export-Sensor was momentarily unavailable when the integration initialised, `_initialize_from_sensors()` silently treated export as 0 and set `self_consumption = pv_total`. Now the init bails out cleanly and waits for the first state-update where all sensors are available.

Fixes the values inflate after restart class of bugs

  • `_last_pv_production_kwh` / `_last_grid_export_kwh` / `_last_grid_import_kwh` are now persisted in storage and restored on startup. After a reload, deltas are computed against the real previous reading — not 0.
  • `async_start()` no longer overwrites the `None` defaults with `0` when sensors are unavailable at boot. The defensive None-check in `_process_energy_update()` now actually fires and re-baselines on the first valid reading.
  • `_process_energy_update()` init guard now checks all three `last*` variables — a missing `grid_export_kwh` would have crashed delta computation.

✅ No breaking changes

  • Config flow unchanged
  • Existing storage data preserved
  • Users who already have inflated values from the previous bug can use the existing Reset functions in the Options to re-initialise

🩺 If you were affected

If you see weird historical jumps in your statistics after a previous reload, you can manually trim them via HA's Developer Tools → Statistics page (Adjust sum). Or use one of the reset options under integration settings.

Full Changelog: v2.0.1...v2.0.2