Skip to content

Commit

Permalink
Fix target temp is not restored correctly. Closes #127
Browse files Browse the repository at this point in the history
  • Loading branch information
ScratMan committed Feb 6, 2023
1 parent 445824b commit f40e1bf
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions custom_components/smart_thermostat/climate.py
Original file line number Diff line number Diff line change
Expand Up @@ -381,18 +381,17 @@ def _async_startup(event):
# Check If we have an old state
old_state = await self.async_get_last_state()
if old_state is not None:
# If we have no initial temperature, restore
if self._target_temp is None:
# If we have a previously saved temperature
if old_state.attributes.get(ATTR_TEMPERATURE) is None:
# If we have a previously saved temperature
if old_state.attributes.get(ATTR_TEMPERATURE) is None:
if self._target_temp is None:
if self._ac_mode:
self._target_temp = self.max_temp
else:
self._target_temp = self.min_temp
_LOGGER.warning("%s: No setpoint available in old state, falling back to %s",
self.entity_id, self._target_temp)
else:
self._target_temp = float(old_state.attributes.get(ATTR_TEMPERATURE))
_LOGGER.warning("%s: No setpoint available in old state, falling back to %s",
self.entity_id, self._target_temp)
else:
self._target_temp = float(old_state.attributes.get(ATTR_TEMPERATURE))
for preset_mode in ['away_temp', 'eco_temp', 'boost_temp', 'comfort_temp', 'home_temp',
'sleep_temp', 'activity_temp']:
if old_state.attributes.get(preset_mode) is not None:
Expand Down

0 comments on commit f40e1bf

Please sign in to comment.