Skip to content

Commit

Permalink
Fix climate power off data
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexxIT committed Dec 17, 2020
1 parent b150b98 commit 7e5fb98
Showing 1 changed file with 18 additions and 6 deletions.
24 changes: 18 additions & 6 deletions custom_components/xiaomi_gateway3/climate.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,16 +81,28 @@ def update(self, data: dict = None):
try:
if 'power' in data: # 0 - off, 1 - on
self._is_on = data['power']
if 'mode' in data: # 0 - heat, 1 - cool
self._hvac_mode = HVAC_MODES[data['mode']]
if 'fan_mode' in data: # 0 - low, 3 - auto
self._fan_mode = FAN_MODES[data['fan_mode']]

# with power off all data come with empty values
# https://github.com/AlexxIT/XiaomiGateway3/issues/101#issuecomment-747305596
if self._is_on:
if 'mode' in data: # 0 - heat, 1 - cool, 15 - off
self._hvac_mode = HVAC_MODES[data['mode']]
if 'fan_mode' in data: # 0 - low, 3 - auto, 15 - off
self._fan_mode = FAN_MODES[data['fan_mode']]
if 'target_temperature' in data: # 255 - off
self._target_temp = data['target_temperature']

else:
self._fan_mode = None
self._hvac_mode = None
self._target_temp = None

This comment has been minimized.

Copy link
@ptbsare

ptbsare Jan 11, 2021

Maybe add some numerical value here? #101


if 'current_temperature' in data:
self._current_temp = data['current_temperature']
if 'target_temperature' in data:
self._target_temp = data['target_temperature']

if self._attr in data:
self._state = bytearray(data[self._attr].to_bytes(4, 'big'))

except:
_LOGGER.exception(f"Can't read climate data: {data}")

Expand Down

0 comments on commit 7e5fb98

Please sign in to comment.