Fixes away_mode error on startup (#12121)

* Fixes away_mode error on startup

* Updated based on feedback
pull/12148/head
Marius 2018-02-02 10:05:19 +02:00 committed by Daniel Høyer Iversen
parent 30ad591a59
commit 6d5a87afb6
1 changed files with 2 additions and 2 deletions

View File

@ -156,7 +156,7 @@ class GenericThermostat(ClimateDevice):
# If we have no initial temperature, restore
if self._target_temp is None:
# If we have a previously saved temperature
if old_state.attributes[ATTR_TEMPERATURE] is None:
if old_state.attributes.get(ATTR_TEMPERATURE) is None:
if self.ac_mode:
self._target_temp = self.max_temp
else:
@ -166,7 +166,7 @@ class GenericThermostat(ClimateDevice):
else:
self._target_temp = float(
old_state.attributes[ATTR_TEMPERATURE])
if old_state.attributes[ATTR_AWAY_MODE] is not None:
if old_state.attributes.get(ATTR_AWAY_MODE) is not None:
self._is_away = str(
old_state.attributes[ATTR_AWAY_MODE]) == STATE_ON
if (self._initial_operation_mode is None and