fix: re-align dead-band on sync

This commit is contained in:
Björn Stormwall
2026-06-06 19:19:22 +02:00
parent a695c47c62
commit 98466056c6
2 changed files with 19 additions and 7 deletions
@@ -127,19 +127,20 @@ class EaseeSolarCoordinator(DataUpdateCoordinator):
"""Return True only when the target warrants a new service call.
- First run: always send.
- Transitions to/from 0: always send (start/stop events).
- Transitions to/from 0: always send immediately (start/stop events).
- Outside dead-band: send immediately.
- Inside dead-band: send once per minute so gradual solar drift is applied.
- Inside dead-band (including same value): re-align once per minute so
the charger is periodically re-confirmed even if the target hasn't changed.
- 0 → 0: never resend (charger is already off).
"""
if self._last_sent_current is None:
return True
if target == self._last_sent_current:
return False
# Start / stop transitions fire immediately; 0→0 is a no-op.
if target == 0 or self._last_sent_current == 0:
return True
return target != self._last_sent_current
if abs(target - self._last_sent_current) >= HYSTERESIS_A:
return True
# Within dead-band: resync once per minute
# Within dead-band or same value: re-align once per minute.
return (
self._last_sent_at is None
or datetime.now(timezone.utc) - self._last_sent_at >= _DEAD_BAND_RESYNC