Skip to content

Commit

Permalink
Change to new climate enity style, fix #165
Browse files Browse the repository at this point in the history
  • Loading branch information
Andre0512 committed Mar 30, 2024
1 parent 0e26b4a commit 09189ff
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions custom_components/hon/climate.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -211,6 +212,14 @@ async def async_set_hvac_mode(self, hvac_mode: HVACMode) -> None:
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."""
Expand Down Expand Up @@ -286,6 +295,7 @@ def _handle_coordinator_update(self, update: bool = True) -> None:

class HonClimateEntity(HonEntity, ClimateEntity):
entity_description: HonClimateEntityDescription
_enable_turn_on_off_backwards_compatibility = False

def __init__(
self,
Expand Down Expand Up @@ -363,6 +373,14 @@ async def async_set_hvac_mode(self, hvac_mode: HVACMode) -> None:
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."""
Expand Down

0 comments on commit 09189ff

Please sign in to comment.