Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit

Permalink
Using async_update_ha_state withtrue
Browse files Browse the repository at this point in the history
  • Loading branch information
iprak committed Jun 14, 2023
1 parent 947b6d1 commit e1c6507
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions custom_components/winix/fan.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ async def async_set_percentage(self, percentage: int) -> None:
percentage_to_ordered_list_item(ORDERED_NAMED_FAN_SPEEDS, percentage)
)

await self.async_update_ha_state() # Update state without forcing a refresh
await self.async_update_ha_state(True) # Update state

async def async_turn_on(
self,
Expand All @@ -226,28 +226,27 @@ async def async_turn_on(

if percentage:
await self.async_set_percentage(percentage)
return
if preset_mode:
await self._wrapper.async_set_preset_mode(preset_mode)
else:
await self._wrapper.async_turn_on()

await self.async_update_ha_state()
await self.async_update_ha_state(True)

async def async_turn_off(self, **kwargs: Any) -> None:
"""Turn off the purifier."""
await self._wrapper.async_turn_off()
await self.async_update_ha_state()
await self.async_update_ha_state(True)

async def async_plasmawave_on(self) -> None:
"""Turn on plasma wave."""
await self._wrapper.async_plasmawave_on()
await self.async_update_ha_state()
await self.async_update_ha_state(True)

async def async_plasmawave_off(self) -> None:
"""Turn off plasma wave."""
await self._wrapper.async_plasmawave_off()
await self.async_update_ha_state()
await self.async_update_ha_state(True)

async def async_plasmawave_toggle(self) -> None:
"""Toggle plasma wave."""
Expand All @@ -257,9 +256,9 @@ async def async_plasmawave_toggle(self) -> None:
else:
await self._wrapper.async_plasmawave_on()

await self.async_update_ha_state()
await self.async_update_ha_state(True)

async def async_set_preset_mode(self, preset_mode: str) -> None:
"""Set new preset mode."""
await self._wrapper.async_set_preset_mode(preset_mode)
await self.async_update_ha_state()
await self.async_update_ha_state(True)

0 comments on commit e1c6507

Please sign in to comment.