diff --git a/homeassistant/components/climate/sensibo.py b/homeassistant/components/climate/sensibo.py index 624729249aa..ed23d91587c 100644 --- a/homeassistant/components/climate/sensibo.py +++ b/homeassistant/components/climate/sensibo.py @@ -13,11 +13,12 @@ import async_timeout import voluptuous as vol from homeassistant.const import ( - ATTR_TEMPERATURE, CONF_API_KEY, CONF_ID, TEMP_CELSIUS, TEMP_FAHRENHEIT) + ATTR_TEMPERATURE, CONF_API_KEY, CONF_ID, STATE_OFF, TEMP_CELSIUS, + TEMP_FAHRENHEIT) from homeassistant.components.climate import ( ATTR_CURRENT_HUMIDITY, ClimateDevice, PLATFORM_SCHEMA, SUPPORT_TARGET_TEMPERATURE, SUPPORT_OPERATION_MODE, - SUPPORT_FAN_MODE, SUPPORT_AWAY_MODE, SUPPORT_SWING_MODE, + SUPPORT_FAN_MODE, SUPPORT_SWING_MODE, SUPPORT_AUX_HEAT) from homeassistant.exceptions import PlatformNotReady from homeassistant.helpers import config_validation as cv @@ -41,9 +42,13 @@ _FETCH_FIELDS = ','.join([ 'acState', 'connectionStatus{isAlive}', 'temperatureUnit']) _INITIAL_FETCH_FIELDS = 'id,' + _FETCH_FIELDS -SUPPORT_FLAGS = (SUPPORT_TARGET_TEMPERATURE | SUPPORT_OPERATION_MODE | - SUPPORT_FAN_MODE | SUPPORT_AWAY_MODE | SUPPORT_SWING_MODE | - SUPPORT_AUX_HEAT) +FIELD_TO_FLAG = { + 'fanLevel': SUPPORT_FAN_MODE, + 'mode': SUPPORT_OPERATION_MODE, + 'swing': SUPPORT_SWING_MODE, + 'targetTemperature': SUPPORT_TARGET_TEMPERATURE, + 'on': SUPPORT_AUX_HEAT, +} @asyncio.coroutine @@ -85,7 +90,14 @@ class SensiboClimate(ClimateDevice): @property def supported_features(self): """Return the list of supported features.""" - return SUPPORT_FLAGS + return self._supported_features + + @property + def state(self): + """Return the current state.""" + if not self.is_aux_heat_on: + return STATE_OFF + return super().state def _do_update(self, data): self._name = data['room']['name'] @@ -106,6 +118,10 @@ class SensiboClimate(ClimateDevice): else: self._temperature_unit = self.unit_of_measurement self._temperatures_list = [] + self._supported_features = 0 + for key in self._ac_states: + if key in FIELD_TO_FLAG: + self._supported_features |= FIELD_TO_FLAG[key] @property def device_state_attributes(self): @@ -196,13 +212,13 @@ class SensiboClimate(ClimateDevice): def min_temp(self): """Return the minimum temperature.""" return self._temperatures_list[0] \ - if len(self._temperatures_list) else super.min_temp() + if len(self._temperatures_list) else super().min_temp() @property def max_temp(self): """Return the maximum temperature.""" return self._temperatures_list[-1] \ - if len(self._temperatures_list) else super.max_temp() + if len(self._temperatures_list) else super().max_temp() @asyncio.coroutine def async_set_temperature(self, **kwargs):