Skip to content

Commit

Permalink
Add support thermostat
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexxIT committed Dec 5, 2020
1 parent 2850222 commit 396fe87
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 22 deletions.
1 change: 1 addition & 0 deletions custom_components/yandex_station/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
25 changes: 3 additions & 22 deletions custom_components/yandex_station/climate.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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
Expand All @@ -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)

Expand All @@ -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):
Expand Down

0 comments on commit 396fe87

Please sign in to comment.