Skip to content

Commit

Permalink
fix: fix fan async_set_direction error
Browse files Browse the repository at this point in the history
  • Loading branch information
topsworld committed Jan 22, 2025
1 parent 035edcd commit 1867614
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions custom_components/xiaomi_home/fan.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
from homeassistant.components.fan import (
FanEntity,
FanEntityFeature,
DIRECTION_FORWARD,
DIRECTION_REVERSE
)
from homeassistant.util.percentage import (
Expand Down Expand Up @@ -269,7 +270,7 @@ async def async_set_direction(self, direction: str) -> None:
prop=self._prop_wind_reverse,
value=(
self._prop_wind_reverse_reverse
if self.current_direction == DIRECTION_REVERSE
if direction == DIRECTION_REVERSE
else self._prop_wind_reverse_forward))

async def async_oscillate(self, oscillating: bool) -> None:
Expand Down Expand Up @@ -298,9 +299,9 @@ def current_direction(self) -> Optional[str]:
"""Return the current direction of the fan."""
if not self._prop_wind_reverse:
return None
return 'reverse' if self.get_prop_value(
return DIRECTION_REVERSE if self.get_prop_value(
prop=self._prop_wind_reverse
) == self._prop_wind_reverse_reverse else 'forward'
) == self._prop_wind_reverse_reverse else DIRECTION_FORWARD

@property
def percentage(self) -> Optional[int]:
Expand Down

0 comments on commit 1867614

Please sign in to comment.