mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 11:17:21 +00:00
Fix insteon fan speeds (#47603)
This commit is contained in:
parent
6af754a7d3
commit
d9ffb65898
@ -1,8 +1,6 @@
|
||||
"""Support for INSTEON fans via PowerLinc Modem."""
|
||||
import math
|
||||
|
||||
from pyinsteon.constants import FanSpeed
|
||||
|
||||
from homeassistant.components.fan import (
|
||||
DOMAIN as FAN_DOMAIN,
|
||||
SUPPORT_SET_SPEED,
|
||||
@ -19,7 +17,7 @@ from .const import SIGNAL_ADD_ENTITIES
|
||||
from .insteon_entity import InsteonEntity
|
||||
from .utils import async_add_insteon_entities
|
||||
|
||||
SPEED_RANGE = (1, FanSpeed.HIGH) # off is not included
|
||||
SPEED_RANGE = (0x00, 0xFF) # off is not included
|
||||
|
||||
|
||||
async def async_setup_entry(hass, config_entry, async_add_entities):
|
||||
@ -52,6 +50,11 @@ class InsteonFanEntity(InsteonEntity, FanEntity):
|
||||
"""Flag supported features."""
|
||||
return SUPPORT_SET_SPEED
|
||||
|
||||
@property
|
||||
def speed_count(self) -> int:
|
||||
"""Flag supported features."""
|
||||
return 3
|
||||
|
||||
async def async_turn_on(
|
||||
self,
|
||||
speed: str = None,
|
||||
@ -60,9 +63,7 @@ class InsteonFanEntity(InsteonEntity, FanEntity):
|
||||
**kwargs,
|
||||
) -> None:
|
||||
"""Turn on the fan."""
|
||||
if percentage is None:
|
||||
percentage = 50
|
||||
await self.async_set_percentage(percentage)
|
||||
await self.async_set_percentage(percentage or 67)
|
||||
|
||||
async def async_turn_off(self, **kwargs) -> None:
|
||||
"""Turn off the fan."""
|
||||
@ -71,7 +72,7 @@ class InsteonFanEntity(InsteonEntity, FanEntity):
|
||||
async def async_set_percentage(self, percentage: int) -> None:
|
||||
"""Set the speed percentage of the fan."""
|
||||
if percentage == 0:
|
||||
await self._insteon_device.async_fan_off()
|
||||
else:
|
||||
on_level = math.ceil(percentage_to_ranged_value(SPEED_RANGE, percentage))
|
||||
await self._insteon_device.async_fan_on(on_level=on_level)
|
||||
await self.async_turn_off()
|
||||
return
|
||||
on_level = math.ceil(percentage_to_ranged_value(SPEED_RANGE, percentage))
|
||||
await self._insteon_device.async_on(group=2, on_level=on_level)
|
||||
|
Loading…
x
Reference in New Issue
Block a user