Summary
When the SPAN panel briefly goes offline and reconnects within ~1 second (network blip, panel internal restart, etc.), a race condition causes dip compensation offsets to be missing for the first coordinator update. HA statistics treats the resulting value drop as a counter reset, adding the raw panel counter value to the running sum — permanently inflating cumulative energy totals for every circuit.
Root Cause
SpanEnergySensorBase.async_added_to_hass() restored the dip compensation offset (_energy_offset) after calling super().async_added_to_hass(). The super() call registers the coordinator listener. If the panel reconnects fast enough, async_set_updated_data() → async_update_listeners() fires synchronously during listener registration, before async_get_last_extra_data() can restore the offset. The first _process_raw_value() call therefore runs with _energy_offset = 0, reports the raw panel counter, and HA statistics interprets the drop from the previous compensated value as a counter reset.
The bug only triggers when both conditions are met:
- The integration fully reloads (entities go through
unavailable → destroy → recreate)
- The panel comes back online in under ~1 second
A slow reconnect (panel offline for several seconds or more) works correctly because restoration completes before the first coordinator push.
Symptoms
- Energy sensors for all circuits show a large, instantaneous spike in HA statistics (Developer Tools → Statistics)
- The spike amount equals the raw panel counter value for each circuit at the time of the event
- Cumulative totals in the Energy Dashboard are permanently inflated from that point forward
- The issue is silent — no error is logged
Fix
Committed in 385d59b (release/v2.0.7): dip compensation state is now restored from async_get_last_extra_data() before super().async_added_to_hass() registers the coordinator listener, eliminating the race.
Affected Versions
Any version with energy dip compensation enabled (introduced in 2.0.x). Requires dip compensation to be enabled in integration options.
Recovery
If you experienced this (sudden spike in energy statistics around the time of a panel reconnect), the inflated statistics can be corrected manually:
- Stop Home Assistant
- Copy
/config/home-assistant_v2.db locally
- For each affected
statistics_short_term and statistics record from the spike bucket onwards, subtract the raw sensor value that was reported at the moment of the reset (visible as a sudden state drop in Developer Tools → Statistics)
- Restore the corrected database and restart
The spike amount per sensor equals (compensated value just before the event) − (raw value reported immediately after).
Summary
When the SPAN panel briefly goes offline and reconnects within ~1 second (network blip, panel internal restart, etc.), a race condition causes dip compensation offsets to be missing for the first coordinator update. HA statistics treats the resulting value drop as a counter reset, adding the raw panel counter value to the running sum — permanently inflating cumulative energy totals for every circuit.
Root Cause
SpanEnergySensorBase.async_added_to_hass()restored the dip compensation offset (_energy_offset) after callingsuper().async_added_to_hass(). Thesuper()call registers the coordinator listener. If the panel reconnects fast enough,async_set_updated_data()→async_update_listeners()fires synchronously during listener registration, beforeasync_get_last_extra_data()can restore the offset. The first_process_raw_value()call therefore runs with_energy_offset = 0, reports the raw panel counter, and HA statistics interprets the drop from the previous compensated value as a counter reset.The bug only triggers when both conditions are met:
unavailable→ destroy → recreate)A slow reconnect (panel offline for several seconds or more) works correctly because restoration completes before the first coordinator push.
Symptoms
Fix
Committed in
385d59b(release/v2.0.7): dip compensation state is now restored fromasync_get_last_extra_data()beforesuper().async_added_to_hass()registers the coordinator listener, eliminating the race.Affected Versions
Any version with energy dip compensation enabled (introduced in 2.0.x). Requires dip compensation to be enabled in integration options.
Recovery
If you experienced this (sudden spike in energy statistics around the time of a panel reconnect), the inflated statistics can be corrected manually:
/config/home-assistant_v2.dblocallystatistics_short_termandstatisticsrecord from the spike bucket onwards, subtract the raw sensor value that was reported at the moment of the reset (visible as a sudden state drop in Developer Tools → Statistics)The spike amount per sensor equals
(compensated value just before the event) − (raw value reported immediately after).