Skip to content

Commit

Permalink
rename entities to be compliant with latest export.txt
Browse files Browse the repository at this point in the history
  • Loading branch information
mampfes committed Sep 27, 2023
1 parent b9ac794 commit 75f8922
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
6 changes: 5 additions & 1 deletion custom_components/bayernluefter/binary_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,11 @@
),
BinarySensorEntityDescription(
key="_MaxMode",
name="MaxMode",
name="TimerAktiv",
),
BinarySensorEntityDescription(
key="_Frozen",
name="SpeedFrozen",
),
)

Expand Down
13 changes: 7 additions & 6 deletions custom_components/bayernluefter/fan.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,10 @@ class FanMode(StrEnum):
Auto = "Auto"
Timer = "Timer"


SYSTEM_MODES_WITH_AUTO = {SystemMode.Kellermode, SystemMode.Behaglichkeitsmode}


async def async_setup_entry(hass, config_entry, async_add_entities):
"""Set up fan entries."""
coordinator: DataUpdateCoordinator = hass.data[DOMAIN][config_entry.entry_id]
Expand All @@ -56,21 +58,18 @@ class BayernluefterFan(BayernluefterEntity, FanEntity):
# These fan specific attributes are not (yet) part of FanEntityDescription
_attr_speed_count = int_states_in_range(FAN_SPEED_RANGE)
_attr_supported_features = FanEntityFeature.SET_SPEED | FanEntityFeature.PRESET_MODE
#_attr_preset_modes = [e.value for e in FanMode]
# _attr_preset_modes = [e.value for e in FanMode]

def __init__(
self,
coordinator: DataUpdateCoordinator,
) -> None:
"""Initialize a switch entity for a Bayernluefter device."""
"""Initialize a fan entity for a Bayernluefter device."""
super().__init__(coordinator, self.entity_description)
self._attr_preset_modes = [FanMode.Timer]
if self._device.raw_converted()["SystemMode"] in SYSTEM_MODES_WITH_AUTO:
self._attr_preset_modes.append(FanMode.Auto)

def _current_speed(self):
return self._device.raw_converted()["Speed_Out"]

@property
def is_on(self) -> bool:
"""Return the fan on status."""
Expand All @@ -79,7 +78,9 @@ def is_on(self) -> bool:
@property
def percentage(self) -> int:
"""Return the speed of the fan-"""
return ranged_value_to_percentage(FAN_SPEED_RANGE, self._current_speed())
return ranged_value_to_percentage(
FAN_SPEED_RANGE, self._device.raw_converted()["Speed_Out"]
)

@property
def preset_mode(self) -> str | None:
Expand Down

0 comments on commit 75f8922

Please sign in to comment.