1 """Support for ISY fans."""
3 from __future__
import annotations
8 from pyisy.constants
import ISY_VALUE_UNKNOWN, PROTO_INSTEON
17 percentage_to_ranged_value,
18 ranged_value_to_percentage,
22 from .const
import _LOGGER, DOMAIN
23 from .entity
import ISYNodeEntity, ISYProgramEntity
24 from .models
import IsyData
26 SPEED_RANGE = (1, 255)
30 hass: HomeAssistant, entry: ConfigEntry, async_add_entities: AddEntitiesCallback
32 """Set up the ISY fan platform."""
33 isy_data: IsyData = hass.data[DOMAIN][entry.entry_id]
34 devices: dict[str, DeviceInfo] = isy_data.devices
35 entities: list[ISYFanEntity | ISYFanProgramEntity] = [
37 for node
in isy_data.nodes[Platform.FAN]
42 for name, status, actions
in isy_data.programs[Platform.FAN]
49 """Representation of an ISY fan device."""
51 _attr_supported_features = (
52 FanEntityFeature.SET_SPEED
53 | FanEntityFeature.TURN_OFF
54 | FanEntityFeature.TURN_ON
56 _enable_turn_on_off_backwards_compatibility =
False
60 """Return the current speed percentage."""
61 if self.
_node_node.status == ISY_VALUE_UNKNOWN:
67 """Return the number of speeds the fan supports."""
68 if self.
_node_node.protocol == PROTO_INSTEON:
74 """Get if the fan is on."""
75 if self.
_node_node.status == ISY_VALUE_UNKNOWN:
80 """Set node to speed percentage for the ISY fan device."""
91 percentage: int |
None =
None,
92 preset_mode: str |
None =
None,
95 """Send the turn on command to the ISY fan device."""
99 """Send the turn off command to the ISY fan device."""
104 """Representation of an ISY fan program."""
108 """Return the current speed percentage."""
109 if self.
_node_node.status == ISY_VALUE_UNKNOWN:
115 """Return the number of speeds the fan supports."""
120 """Get if the fan is on."""
124 """Send the turn on command to ISY fan program."""
125 if not await self.
_actions_actions.run_then():
126 _LOGGER.error(
"Unable to turn off the fan")
130 percentage: int |
None =
None,
131 preset_mode: str |
None =
None,
134 """Send the turn off command to ISY fan program."""
135 if not await self.
_actions_actions.run_else():
136 _LOGGER.error(
"Unable to turn on the fan")
None turn_on(self, int|None percentage=None, str|None preset_mode=None, **Any kwargs)
None async_set_percentage(self, int percentage)
None async_turn_on(self, int|None percentage=None, str|None preset_mode=None, **Any kwargs)
None async_turn_off(self, **Any kwargs)
int|None percentage(self)
None async_set_percentage(self, int percentage)
int|None percentage(self)
None async_turn_on(self, int|None percentage=None, str|None preset_mode=None, **Any kwargs)
None async_turn_off(self, **Any kwargs)
None turn_off(self, **Any kwargs)
None async_setup_entry(HomeAssistant hass, ConfigEntry entry, AddEntitiesCallback async_add_entities)
float percentage_to_ranged_value(tuple[float, float] low_high_range, float percentage)
int ranged_value_to_percentage(tuple[float, float] low_high_range, float value)
int int_states_in_range(tuple[float, float] low_high_range)