mirror of
https://github.com/XiaoMi/ha_xiaomi_home.git
synced 2025-04-05 01:05:31 +08:00
Merge branch 'XiaoMi:main' into main
This commit is contained in:
commit
e83aa9367e
@ -52,7 +52,12 @@ import logging
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
from homeassistant.components.fan import FanEntity, FanEntityFeature
|
||||
from homeassistant.components.fan import (
|
||||
FanEntity,
|
||||
FanEntityFeature,
|
||||
DIRECTION_FORWARD,
|
||||
DIRECTION_REVERSE
|
||||
)
|
||||
from homeassistant.util.percentage import (
|
||||
percentage_to_ranged_value,
|
||||
ranged_value_to_percentage,
|
||||
@ -172,8 +177,9 @@ class Fan(MIoTServiceEntity, FanEntity):
|
||||
self._prop_wind_reverse_reverse = True
|
||||
elif prop.value_list:
|
||||
for item in prop.value_list.items:
|
||||
if item.name in {'foreward'}:
|
||||
if item.name in {'foreward', 'forward'}:
|
||||
self._prop_wind_reverse_forward = item.value
|
||||
elif item.name in {'reversal', 'reverse'}:
|
||||
self._prop_wind_reverse_reverse = item.value
|
||||
if (
|
||||
self._prop_wind_reverse_forward is None
|
||||
@ -202,9 +208,9 @@ class Fan(MIoTServiceEntity, FanEntity):
|
||||
if self._speed_names:
|
||||
await self.set_property_async(
|
||||
prop=self._prop_fan_level,
|
||||
value=self.get_map_value(
|
||||
value=self.get_map_key(
|
||||
map_=self._speed_name_map,
|
||||
key=percentage_to_ordered_list_item(
|
||||
value=percentage_to_ordered_list_item(
|
||||
self._speed_names, percentage)))
|
||||
else:
|
||||
await self.set_property_async(
|
||||
@ -233,9 +239,9 @@ class Fan(MIoTServiceEntity, FanEntity):
|
||||
if self._speed_names:
|
||||
await self.set_property_async(
|
||||
prop=self._prop_fan_level,
|
||||
value=self.get_map_value(
|
||||
value=self.get_map_key(
|
||||
map_=self._speed_name_map,
|
||||
key=percentage_to_ordered_list_item(
|
||||
value=percentage_to_ordered_list_item(
|
||||
self._speed_names, percentage)))
|
||||
else:
|
||||
await self.set_property_async(
|
||||
@ -264,7 +270,7 @@ class Fan(MIoTServiceEntity, FanEntity):
|
||||
prop=self._prop_wind_reverse,
|
||||
value=(
|
||||
self._prop_wind_reverse_reverse
|
||||
if self.current_direction == 'reverse'
|
||||
if direction == DIRECTION_REVERSE
|
||||
else self._prop_wind_reverse_forward))
|
||||
|
||||
async def async_oscillate(self, oscillating: bool) -> None:
|
||||
@ -293,9 +299,9 @@ class Fan(MIoTServiceEntity, FanEntity):
|
||||
"""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]:
|
||||
|
Loading…
x
Reference in New Issue
Block a user