fix generic_thermostat bug when restore state from HA start up (#12134)

* fix generic_thermostat bug when restore state from HA start up

if you don't set "initial_operation_mode" in config, you will get
`self._enabled = True` when init GenericThermostat. And then you will
miss the `if self._current_operation != STATE_OFF` statement and the
self._enabled still keep `True`. That's the problem

* add a test to describe the restore case
This commit is contained in:
ruohan.chen 2018-02-03 23:59:19 +08:00 committed by Pascal Vizeli
parent c144a3339f
commit 4ac9e7edf4
2 changed files with 86 additions and 3 deletions

View file

@ -173,8 +173,8 @@ class GenericThermostat(ClimateDevice):
old_state.attributes[ATTR_OPERATION_MODE] is not None):
self._current_operation = \
old_state.attributes[ATTR_OPERATION_MODE]
if self._current_operation != STATE_OFF:
self._enabled = True
self._enabled = self._current_operation != STATE_OFF
else:
# No previous state, try and restore defaults
if self._target_temp is None: