mirror of
https://github.com/home-assistant/core.git
synced 2025-04-24 09:17:53 +00:00
Simplify FanEntity percentage and speed_count shorthand attributes (#130935)
This commit is contained in:
parent
c1f03f34b2
commit
ea989f7ca1
@ -234,10 +234,10 @@ class FanEntity(ToggleEntity, cached_properties=CACHED_PROPERTIES_WITH_ATTR_):
|
||||
entity_description: FanEntityDescription
|
||||
_attr_current_direction: str | None = None
|
||||
_attr_oscillating: bool | None = None
|
||||
_attr_percentage: int | None
|
||||
_attr_percentage: int | None = 0
|
||||
_attr_preset_mode: str | None = None
|
||||
_attr_preset_modes: list[str] | None = None
|
||||
_attr_speed_count: int
|
||||
_attr_speed_count: int = 100
|
||||
_attr_supported_features: FanEntityFeature = FanEntityFeature(0)
|
||||
|
||||
__mod_supported_features: FanEntityFeature = FanEntityFeature(0)
|
||||
@ -463,16 +463,12 @@ class FanEntity(ToggleEntity, cached_properties=CACHED_PROPERTIES_WITH_ATTR_):
|
||||
@cached_property
|
||||
def percentage(self) -> int | None:
|
||||
"""Return the current speed as a percentage."""
|
||||
if hasattr(self, "_attr_percentage"):
|
||||
return self._attr_percentage
|
||||
return 0
|
||||
return self._attr_percentage
|
||||
|
||||
@cached_property
|
||||
def speed_count(self) -> int:
|
||||
"""Return the number of speeds the fan supports."""
|
||||
if hasattr(self, "_attr_speed_count"):
|
||||
return self._attr_speed_count
|
||||
return 100
|
||||
return self._attr_speed_count
|
||||
|
||||
@property
|
||||
def percentage_step(self) -> float:
|
||||
|
Loading…
x
Reference in New Issue
Block a user