Skip to content

Commit

Permalink
Fix daikin entities not refreshing quickly (home-assistant#128230)
Browse files Browse the repository at this point in the history
* Fix daikin entities not refreshing quickly

* Update homeassistant/components/daikin/switch.py

---------

Co-authored-by: Joost Lekkerkerker <[email protected]>
  • Loading branch information
adampetrovic and joostlek authored Oct 13, 2024
1 parent c4ff3f7 commit d15a9a4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
4 changes: 4 additions & 0 deletions homeassistant/components/daikin/climate.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ async def _set(self, settings: dict[str, Any]) -> None:

if values:
await self.device.set(values)
await self.coordinator.async_refresh()

@property
def unique_id(self) -> str:
Expand Down Expand Up @@ -261,6 +262,7 @@ async def async_set_preset_mode(self, preset_mode: str) -> None:
await self.device.set_advanced_mode(
HA_PRESET_TO_DAIKIN[PRESET_ECO], ATTR_STATE_OFF
)
await self.coordinator.async_refresh()

@property
def preset_modes(self) -> list[str]:
Expand All @@ -275,9 +277,11 @@ def preset_modes(self) -> list[str]:
async def async_turn_on(self) -> None:
"""Turn device on."""
await self.device.set({})
await self.coordinator.async_refresh()

async def async_turn_off(self) -> None:
"""Turn device off."""
await self.device.set(
{HA_ATTR_TO_DAIKIN[ATTR_HVAC_MODE]: HA_STATE_TO_DAIKIN[HVACMode.OFF]}
)
await self.coordinator.async_refresh()
6 changes: 6 additions & 0 deletions homeassistant/components/daikin/switch.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,12 @@ def is_on(self) -> bool:
async def async_turn_on(self, **kwargs: Any) -> None:
"""Turn the zone on."""
await self.device.set_zone(self._zone_id, "zone_onoff", "1")
await self.coordinator.async_refresh()

async def async_turn_off(self, **kwargs: Any) -> None:
"""Turn the zone off."""
await self.device.set_zone(self._zone_id, "zone_onoff", "0")
await self.coordinator.async_refresh()


class DaikinStreamerSwitch(DaikinEntity, SwitchEntity):
Expand All @@ -88,10 +90,12 @@ def is_on(self) -> bool:
async def async_turn_on(self, **kwargs: Any) -> None:
"""Turn the zone on."""
await self.device.set_streamer("on")
await self.coordinator.async_refresh()

async def async_turn_off(self, **kwargs: Any) -> None:
"""Turn the zone off."""
await self.device.set_streamer("off")
await self.coordinator.async_refresh()


class DaikinToggleSwitch(DaikinEntity, SwitchEntity):
Expand All @@ -112,7 +116,9 @@ def is_on(self) -> bool:
async def async_turn_on(self, **kwargs: Any) -> None:
"""Turn the zone on."""
await self.device.set({})
await self.coordinator.async_refresh()

async def async_turn_off(self, **kwargs: Any) -> None:
"""Turn the zone off."""
await self.device.set({DAIKIN_ATTR_MODE: "off"})
await self.coordinator.async_refresh()

0 comments on commit d15a9a4

Please sign in to comment.