diff --git a/custom_components/boiler_aux_heater_3phase/coordinator.py b/custom_components/boiler_aux_heater_3phase/coordinator.py index 3eefea5..4730317 100644 --- a/custom_components/boiler_aux_heater_3phase/coordinator.py +++ b/custom_components/boiler_aux_heater_3phase/coordinator.py @@ -174,6 +174,10 @@ class BoilerAuxHeaterCoordinator: # B4: Restore persisted boost state await self._async_restore_boost_state() + # Sync relay to current decision immediately, without waiting for a + # state change event (handles relay left ON before a restart). + self._recalculate() + async def _async_restore_boost_state(self) -> None: """Restore bath boost state from storage after HA restart.""" data = await self._store.async_load() @@ -431,7 +435,6 @@ class BoilerAuxHeaterCoordinator: allowed = hp_aux_off and allow_usage and boiler_temp_ok # F1: Compute decision reason - old_decision = self.decision if manual_override: self.decision = True self.decision_reason = "Manual override" @@ -463,7 +466,7 @@ class BoilerAuxHeaterCoordinator: self.decision = False self.decision_reason = "OFF: No heating demand" - if self.decision != old_decision: + if self.decision != relay_on: self.hass.async_create_task(self._async_control_relay(self.decision)) self._notify_listeners()