From 09189ff0f8dabcda958e2efff310d897839fce98 Mon Sep 17 00:00:00 2001 From: Andre Basche Date: Sat, 30 Mar 2024 17:29:25 +0100 Subject: [PATCH] Change to new climate enity style, fix #165 --- custom_components/hon/climate.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/custom_components/hon/climate.py b/custom_components/hon/climate.py index 958465c..ddbce50 100644 --- a/custom_components/hon/climate.py +++ b/custom_components/hon/climate.py @@ -126,6 +126,7 @@ async def async_setup_entry( class HonACClimateEntity(HonEntity, ClimateEntity): entity_description: HonACClimateEntityDescription + _enable_turn_on_off_backwards_compatibility = False def __init__( self, @@ -211,6 +212,14 @@ class HonACClimateEntity(HonEntity, ClimateEntity): await self._device.commands["settings"].send() self.async_write_ha_state() + async def async_turn_on(self, **kwargs: Any) -> None: + await self._device.commands["startProgram"].send() + self._device.sync_command("startProgram", "settings") + + async def async_turn_off(self, **kwargs: Any) -> None: + await self._device.commands["stopProgram"].send() + self._device.sync_command("stopProgram", "settings") + @property def preset_mode(self) -> str | None: """Return the current Preset for this channel.""" @@ -286,6 +295,7 @@ class HonACClimateEntity(HonEntity, ClimateEntity): class HonClimateEntity(HonEntity, ClimateEntity): entity_description: HonClimateEntityDescription + _enable_turn_on_off_backwards_compatibility = False def __init__( self, @@ -363,6 +373,14 @@ class HonClimateEntity(HonEntity, ClimateEntity): self._attr_hvac_mode = hvac_mode self.async_write_ha_state() + async def async_turn_on(self) -> None: + """Set the HVAC State to on.""" + await self._device.commands["startProgram"].send() + + async def async_turn_off(self) -> None: + """Set the HVAC State to off.""" + await self._device.commands["stopProgram"].send() + @property def preset_mode(self) -> str | None: """Return the current Preset for this channel."""