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