From 75f89222c7519dd4b4ee72e81f488bbdca1d8f39 Mon Sep 17 00:00:00 2001 From: mampfes Date: Wed, 27 Sep 2023 16:44:23 +0200 Subject: [PATCH] rename entities to be compliant with latest export.txt --- custom_components/bayernluefter/binary_sensor.py | 6 +++++- custom_components/bayernluefter/fan.py | 13 +++++++------ 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/custom_components/bayernluefter/binary_sensor.py b/custom_components/bayernluefter/binary_sensor.py index 48a01f6..e3e01d1 100644 --- a/custom_components/bayernluefter/binary_sensor.py +++ b/custom_components/bayernluefter/binary_sensor.py @@ -41,7 +41,11 @@ ), BinarySensorEntityDescription( key="_MaxMode", - name="MaxMode", + name="TimerAktiv", + ), + BinarySensorEntityDescription( + key="_Frozen", + name="SpeedFrozen", ), ) diff --git a/custom_components/bayernluefter/fan.py b/custom_components/bayernluefter/fan.py index ebfcc0f..7e51eda 100644 --- a/custom_components/bayernluefter/fan.py +++ b/custom_components/bayernluefter/fan.py @@ -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] @@ -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.""" @@ -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: