Fix homekit_controller climate supported operation_list being blank (#23095)

* Fix tado supported operation modes when used with homekit_controller

* Replace with list comp as requested in review

* More list comps
This commit is contained in:
Jc2k
2019-04-15 16:09:21 +01:00
committed by Martin Hjelmare
parent 2f89f88d23
commit e97b2b7015
2 changed files with 48 additions and 5 deletions

View File

@@ -36,12 +36,12 @@ class HomeKitClimateDevice(HomeKitEntity, ClimateDevice):
def __init__(self, *args):
"""Initialise the device."""
super().__init__(*args)
self._state = None
self._current_mode = None
self._valid_modes = []
self._current_temp = None
self._target_temp = None
super().__init__(*args)
def get_characteristic_types(self):
"""Define the homekit characteristics the entity cares about."""
@@ -57,10 +57,26 @@ class HomeKitClimateDevice(HomeKitEntity, ClimateDevice):
def _setup_heating_cooling_target(self, characteristic):
self._features |= SUPPORT_OPERATION_MODE
valid_values = characteristic.get(
'valid-values', DEFAULT_VALID_MODES)
if 'valid-values' in characteristic:
valid_values = [
val for val in DEFAULT_VALID_MODES
if val in characteristic['valid-values']
]
else:
valid_values = DEFAULT_VALID_MODES
if 'minValue' in characteristic:
valid_values = [
val for val in valid_values
if val >= characteristic['minValue']
]
if 'maxValue' in characteristic:
valid_values = [
val for val in valid_values
if val <= characteristic['maxValue']
]
self._valid_modes = [
MODE_HOMEKIT_TO_HASS.get(mode) for mode in valid_values
MODE_HOMEKIT_TO_HASS[mode] for mode in valid_values
]
def _setup_temperature_target(self, characteristic):