From 396fe8753b958668d929f32a8f98ee2ad47b8be2 Mon Sep 17 00:00:00 2001 From: Alexey Khit Date: Sat, 5 Dec 2020 08:45:29 +0300 Subject: [PATCH] Add support thermostat --- custom_components/yandex_station/__init__.py | 1 + custom_components/yandex_station/climate.py | 25 +++----------------- 2 files changed, 4 insertions(+), 22 deletions(-) diff --git a/custom_components/yandex_station/__init__.py b/custom_components/yandex_station/__init__.py index 0e596b8..4168fa3 100644 --- a/custom_components/yandex_station/__init__.py +++ b/custom_components/yandex_station/__init__.py @@ -46,6 +46,7 @@ YANDEX_DEVICES = { 'devices.types.thermostat.ac': 'climate', + 'devices.types.thermostat': 'climate', 'devices.types.media_device.tv': 'media_player', 'devices.types.light': 'light', 'devices.types.other': 'remote', diff --git a/custom_components/yandex_station/climate.py b/custom_components/yandex_station/climate.py index beb1730..c11b262 100644 --- a/custom_components/yandex_station/climate.py +++ b/custom_components/yandex_station/climate.py @@ -16,7 +16,7 @@ async def async_setup_platform(hass, config, add_entities, return quasar = hass.data[DOMAIN]['quasar'] - add_entities([YandexClimate(quasar, discovery_info)]) + add_entities([YandexClimate(quasar, discovery_info)], True) class YandexClimate(ClimateEntity): @@ -27,7 +27,6 @@ class YandexClimate(ClimateEntity): _hvac_modes = None _is_on = None _temp = None - _name = None _fan_mode = None _fan_modes = None _supported = 0 @@ -36,79 +35,63 @@ def __init__(self, quasar: YandexQuasar, device: dict): self.quasar = quasar self.device = device - async def async_added_to_hass(self): - self._name = self.device['name'] - self.async_schedule_update_ha_state(True) - @property def unique_id(self): return self.device['id'].replace('-', '') @property def name(self): - return self._name + return self.device['name'] @property - def should_poll(self) -> bool: + def should_poll(self): return True @property def precision(self): - """Return the precision of the system.""" return self._precision @property def temperature_unit(self): - """Return the unit of measurement used by the platform.""" return TEMP_CELSIUS @property def hvac_mode(self): - """Return current operation ie. heat, cool, idle.""" return self._hvac_mode if self._is_on else HVAC_MODE_OFF @property def hvac_modes(self): - """Return the list of available operation modes.""" return self._hvac_modes @property def current_temperature(self): - """Return the current temperature.""" return self._temp @property def target_temperature(self): - """Return the temperature we try to reach.""" return self._temp @property def fan_mode(self): - """Return the fan setting.""" return self._fan_mode @property def fan_modes(self): - """Return the list of available fan modes.""" return self._fan_modes @property def supported_features(self): - """Return the list of supported features.""" return self._supported @property def min_temp(self): - """Return the minimum temperature.""" return self._min_temp @property def max_temp(self): - """Return the maximum temperature.""" return self._max_temp async def async_set_hvac_mode(self, hvac_mode): - """Set new target operation mode.""" if hvac_mode == HVAC_MODE_OFF: await self.quasar.device_action(self.device['id'], on=False) @@ -117,12 +100,10 @@ async def async_set_hvac_mode(self, hvac_mode): thermostat=hvac_mode) async def async_set_temperature(self, **kwargs): - """Set new target temperature.""" await self.quasar.device_action(self.device['id'], temperature=kwargs[ATTR_TEMPERATURE]) async def async_set_fan_mode(self, fan_mode): - """Set new target fan mode.""" await self.quasar.device_action(self.device['id'], fan_speed=fan_mode) async def init_params(self, capabilities: dict):