diff --git a/zha/application/platforms/fan/__init__.py b/zha/application/platforms/fan/__init__.py index e01bf7c8..765d1257 100644 --- a/zha/application/platforms/fan/__init__.py +++ b/zha/application/platforms/fan/__init__.py @@ -28,7 +28,6 @@ PRESET_MODES_TO_NAME, SPEED_OFF, SPEED_RANGE, - SUPPORT_SET_SPEED, FanEntityFeature, ) from zha.application.platforms.fan.helpers import ( @@ -65,7 +64,7 @@ class FanEntityInfo(BaseEntityInfo): """Fan entity info.""" preset_modes: list[str] - supported_features: int + supported_features: FanEntityFeature speed_count: int speed_list: list[str] @@ -75,7 +74,11 @@ class BaseFan(BaseEntity): PLATFORM = Platform.FAN - _attr_supported_features = FanEntityFeature.SET_SPEED + _attr_supported_features: FanEntityFeature = ( + FanEntityFeature.SET_SPEED + | FanEntityFeature.TURN_OFF + | FanEntityFeature.TURN_ON + ) _attr_translation_key: str = "fan" @functools.cached_property @@ -109,9 +112,9 @@ def speed_count(self) -> int: return int_states_in_range(self.speed_range) @functools.cached_property - def supported_features(self) -> int: + def supported_features(self) -> FanEntityFeature: """Flag supported features.""" - return SUPPORT_SET_SPEED + return self._attr_supported_features @property def is_on(self) -> bool: @@ -440,7 +443,12 @@ def default_on_percentage(self) -> int: class KofFan(Fan): """Representation of a fan made by King Of Fans.""" - _attr_supported_features = FanEntityFeature.SET_SPEED | FanEntityFeature.PRESET_MODE + _attr_supported_features = ( + FanEntityFeature.SET_SPEED + | FanEntityFeature.PRESET_MODE + | FanEntityFeature.TURN_OFF + | FanEntityFeature.TURN_ON + ) @functools.cached_property def speed_range(self) -> tuple[int, int]: diff --git a/zha/application/platforms/fan/const.py b/zha/application/platforms/fan/const.py index 3f703797..72c7789e 100644 --- a/zha/application/platforms/fan/const.py +++ b/zha/application/platforms/fan/const.py @@ -31,8 +31,6 @@ ATTR_PRESET_MODE: Final[str] = "preset_mode" ATTR_PRESET_MODES: Final[str] = "preset_modes" -SUPPORT_SET_SPEED: Final[int] = 1 - SPEED_OFF: Final[str] = "off" SPEED_LOW: Final[str] = "low" SPEED_MEDIUM: Final[str] = "medium" @@ -49,3 +47,5 @@ class FanEntityFeature(IntFlag): OSCILLATE = 2 DIRECTION = 4 PRESET_MODE = 8 + TURN_OFF = 16 + TURN_ON = 32