Skip to content

Commit

Permalink
Fix climate turn_on #561 #577
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexxIT committed Nov 22, 2024
1 parent 4d78fd2 commit d39e478
Showing 1 changed file with 14 additions and 12 deletions.
26 changes: 14 additions & 12 deletions custom_components/yandex_station/climate.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,16 +169,18 @@ async def async_set_preset_mode(self, preset_mode: str):
await self.quasar.device_action(self.device, self.preset_instance, preset_mode)

async def internal_set_hvac_mode(self, value: str):
try:
await self.quasar.device_action(self.device, self.hvac_instance, value)
except Exception as e:
# AssertionError: {'request_id': 'xxx', 'status': 'error',
# 'code': 'DEVICE_OFF', 'message': 'Сначала нужно включить устройство'}
if "DEVICE_OFF" in str(e):
await self.quasar.device_action(self.device, "on", True)
for _ in range(3):
if self._attr_hvac_mode == HVACMode.OFF:
await asyncio.sleep(1)
# https://github.com/AlexxIT/YandexStation/issues/577
if self._attr_hvac_mode == HVACMode.OFF:
await self.quasar.device_action(self.device, "on", True)
await asyncio.sleep(1)

for _ in range(3):
try:
await self.quasar.device_action(self.device, self.hvac_instance, value)
else:
raise e
except Exception as e:
# https://github.com/AlexxIT/YandexStation/issues/561
if "DEVICE_OFF" in str(e):
await self.quasar.device_action(self.device, "on", True)
await asyncio.sleep(1)
else:
raise e

0 comments on commit d39e478

Please sign in to comment.