Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Handle case where 'mode' and 'fanSpeed' are missing JSON. Based on
changes in commit
wmalgadey/tado_component@adfb608
  • Loading branch information
filcole authored and dethpickle committed Aug 18, 2017
1 parent 2f94973 commit 5807051
Showing 1 changed file with 24 additions and 17 deletions.
41 changes: 24 additions & 17 deletions homeassistant/components/climate/tado.py
Original file line number Diff line number Diff line change
Expand Up @@ -273,31 +273,38 @@ def update(self):
else:
self._device_is_active = True

if self._device_is_active:
overlay = False
overlay_data = None
termination = self._current_operation
cooling = False
fan_speed = CONST_MODE_OFF
overlay = False
overlay_data = None
termination = self._current_operation
cooling = False
fan_speed = CONST_MODE_OFF

if 'overlay' in data:
overlay_data = data['overlay']
overlay = overlay_data is not None

if overlay:
termination = overlay_data['termination']['type']

if 'overlay' in data:
overlay_data = data['overlay']
overlay = overlay_data is not None
if 'setting' in overlay_data:
setting_data = overlay_data['setting']
setting = setting is not None

if overlay:
termination = overlay_data['termination']['type']
if setting:
if 'mode' in setting_data:
cooling = setting_data['mode'] == 'COOL'

if 'setting' in overlay_data:
cooling = overlay_data['setting']['mode'] == 'COOL'
fan_speed = overlay_data['setting']['fanSpeed']
if 'fanSpeed' in setting_data:
fan_speed = setting_data['fanSpeed']

if self._device_is_active:
# If you set mode manualy to off, there will be an overlay
# and a termination, but we want to see the mode "OFF"

self._overlay_mode = termination
self._current_operation = termination
self._cooling = cooling
self._current_fan = fan_speed

self._cooling = cooling
self._current_fan = fan_speed

def _control_heating(self):
"""Send new target temperature to mytado."""
Expand Down

0 comments on commit 5807051

Please sign in to comment.