Simplify FanEntity preset_mode shorthand attributes (#130930)

This commit is contained in:
epenet
2024-11-19 09:11:47 +01:00
committed by GitHub
parent b6d79415fe
commit 7dc2102545

View File

@@ -235,8 +235,8 @@ class FanEntity(ToggleEntity, cached_properties=CACHED_PROPERTIES_WITH_ATTR_):
_attr_current_direction: str | None = None
_attr_oscillating: bool | None = None
_attr_percentage: int | None
_attr_preset_mode: str | None
_attr_preset_modes: list[str] | None
_attr_preset_mode: str | None = None
_attr_preset_modes: list[str] | None = None
_attr_speed_count: int
_attr_supported_features: FanEntityFeature = FanEntityFeature(0)
@@ -538,9 +538,7 @@ class FanEntity(ToggleEntity, cached_properties=CACHED_PROPERTIES_WITH_ATTR_):
Requires FanEntityFeature.SET_SPEED.
"""
if hasattr(self, "_attr_preset_mode"):
return self._attr_preset_mode
return None
@cached_property
def preset_modes(self) -> list[str] | None:
@@ -548,9 +546,7 @@ class FanEntity(ToggleEntity, cached_properties=CACHED_PROPERTIES_WITH_ATTR_):
Requires FanEntityFeature.SET_SPEED.
"""
if hasattr(self, "_attr_preset_modes"):
return self._attr_preset_modes
return None
# These can be removed if no deprecated constant are in this module anymore