Skip to content

Commit

Permalink
update(smart_thermostat): restore last integral after reboot.
Browse files Browse the repository at this point in the history
  • Loading branch information
ScratMan committed Nov 6, 2021
1 parent b5851d9 commit 49d78f0
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
5 changes: 3 additions & 2 deletions custom_components/smart_thermostat/climate.py
Original file line number Diff line number Diff line change
Expand Up @@ -280,10 +280,11 @@ def _async_startup(event):
else:
if old_state.attributes[ATTR_TEMPERATURE]:
self._target_temp = float(old_state.attributes[ATTR_TEMPERATURE])
# if old_state.attributes.get(ATTR_PRESET_MODE) == PRESET_AWAY:
# self._is_away = True
if old_state.attributes.get(ATTR_PRESET_MODE) is not None:
self._attr_preset_mode = old_state.attributes.get(ATTR_PRESET_MODE)
if old_state.attributes.get('pid_i') is not None:
self.i = old_state.attributes.get('pid_i')
self.pidController.integral = self.i
if not self._hvac_mode and old_state.state:
self._hvac_mode = old_state.state

Expand Down
9 changes: 9 additions & 0 deletions custom_components/smart_thermostat/pid_controller/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,15 @@ def mode(self, mode):
assert mode.upper() in ['AUTO', 'OFF']
self._mode = mode.upper()

@property
def integral(self):
return self._integral

@integral.setter
def integral(self, i):
assert isinstance(i, float), "Integral should be a float"
self._integral = i

def calc(self, input_val, set_point, input_time=None, last_input_time=None):
"""Adjusts and holds the given setpoint.
Expand Down

0 comments on commit 49d78f0

Please sign in to comment.