Skip to content

Commit

Permalink
Also store initial boiler temperature when warming up
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexwijn committed Dec 23, 2023
1 parent 9245b46 commit 0800e76
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions custom_components/sat/climate.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,9 @@ async def async_setup_entry(_hass: HomeAssistant, _config_entry: ConfigEntry, _a


class SatWarmingUp:
def __init__(self, error: float, started: int = None):
def __init__(self, error: float, boiler_temperature: float = None, started: int = None):
self.error = error
self.boiler_temperature = boiler_temperature
self.started = started if started is not None else int(time())

@property
Expand Down Expand Up @@ -284,7 +285,7 @@ async def _restore_previous_state_or_set_defaults(self):
self._attr_preset_mode = old_state.attributes.get(ATTR_PRESET_MODE)

if warming_up := old_state.attributes.get(ATTR_WARMING_UP):
self._warming_up_data = SatWarmingUp(warming_up["error"], warming_up["started"])
self._warming_up_data = SatWarmingUp(warming_up["error"], warming_up["boiler_temperature"], warming_up["started"])

if old_state.attributes.get(ATTR_WARMING_UP_DERIVATIVE):
self._warming_up_derivative = old_state.attributes.get(ATTR_WARMING_UP_DERIVATIVE)
Expand Down Expand Up @@ -778,7 +779,7 @@ async def _async_control_pid(self, reset: bool = False) -> None:

# Determine if we are warming up
if self.max_error > DEADBAND:
self._warming_up_data = SatWarmingUp(self.max_error)
self._warming_up_data = SatWarmingUp(self.max_error, self._coordinator.boiler_temperature)
_LOGGER.info("Outside of deadband, we are warming up")

self.async_write_ha_state()
Expand Down

0 comments on commit 0800e76

Please sign in to comment.