diff --git a/zha/application/platforms/number/__init__.py b/zha/application/platforms/number/__init__.py index bb8c1d264..549f5ecd0 100644 --- a/zha/application/platforms/number/__init__.py +++ b/zha/application/platforms/number/__init__.py @@ -12,7 +12,7 @@ from zigpy.quirks.v2 import NumberMetadata from zigpy.zcl.clusters.general import AnalogOutput, Basic, LevelControl from zigpy.zcl.clusters.hvac import Thermostat -from zigpy.zcl.clusters.lighting import Color +from zigpy.zcl.clusters.lighting import Ballast, Color from zigpy.zcl.clusters.measurement import OccupancySensing from zha.application import Platform @@ -33,6 +33,7 @@ AQARA_OPPLE_CLUSTER, CLUSTER_HANDLER_ANALOG_OUTPUT, CLUSTER_HANDLER_ATTRIBUTE_UPDATED, + CLUSTER_HANDLER_BALLAST, CLUSTER_HANDLER_BASIC, CLUSTER_HANDLER_COLOR, CLUSTER_HANDLER_INOVELLI, @@ -446,6 +447,38 @@ def recompute_capabilities(self) -> None: self._attr_native_max_value = self._cluster_handler.max_mireds +@register_entity(Ballast.cluster_id) +class BallastMinLevel(NumberConfigurationEntity): + """Ballast minimum level configuration entity.""" + + _unique_id_suffix = "ballast_min_level" + _attr_entity_category = EntityCategory.CONFIG + _attr_native_min_value: float = 0x01 + _attr_native_max_value: float = 0xFE + _attribute_name = "min_level" + _attr_translation_key: str = "minimum_dimming_level" + + _cluster_handler_match = ClusterHandlerMatch( + cluster_handlers=frozenset({CLUSTER_HANDLER_BALLAST}) + ) + + +@register_entity(Ballast.cluster_id) +class BallastMaxLevel(NumberConfigurationEntity): + """Ballast maximum level configuration entity.""" + + _unique_id_suffix = "ballast_max_level" + _attr_entity_category = EntityCategory.CONFIG + _attr_native_min_value: float = 0x01 + _attr_native_max_value: float = 0xFE + _attribute_name = "max_level" + _attr_translation_key: str = "maximum_dimming_level" + + _cluster_handler_match = ClusterHandlerMatch( + cluster_handlers=frozenset({CLUSTER_HANDLER_BALLAST}) + ) + + @register_entity(OccupancySensing.cluster_id) class PIROccupiedToUnoccupiedDelayConfigurationEntity(NumberConfigurationEntity): """Representation of a ZHA PIR occupied to unoccupied delay configuration entity.""" diff --git a/zha/zigbee/cluster_handlers/const.py b/zha/zigbee/cluster_handlers/const.py index 5cdae12c7..a032bb639 100644 --- a/zha/zigbee/cluster_handlers/const.py +++ b/zha/zigbee/cluster_handlers/const.py @@ -44,6 +44,7 @@ CLUSTER_HANDLER_ANALOG_INPUT: Final[str] = "analog_input" CLUSTER_HANDLER_ANALOG_OUTPUT: Final[str] = "analog_output" CLUSTER_HANDLER_ATTRIBUTE: Final[str] = "attribute" +CLUSTER_HANDLER_BALLAST: Final[str] = "light_ballast" CLUSTER_HANDLER_BASIC: Final[str] = "basic" CLUSTER_HANDLER_COLOR: Final[str] = "light_color" CLUSTER_HANDLER_COVER: Final[str] = "window_covering" diff --git a/zha/zigbee/cluster_handlers/lighting.py b/zha/zigbee/cluster_handlers/lighting.py index cfe0020ad..6220f2312 100644 --- a/zha/zigbee/cluster_handlers/lighting.py +++ b/zha/zigbee/cluster_handlers/lighting.py @@ -17,6 +17,11 @@ class BallastClusterHandler(ClusterHandler): """Ballast cluster handler.""" + ZCL_INIT_ATTRS = { + Ballast.AttributeDefs.min_level.name: True, + Ballast.AttributeDefs.max_level.name: True, + } + @registries.CLIENT_CLUSTER_HANDLER_REGISTRY.register(Color.cluster_id) class ColorClientClusterHandler(ClientClusterHandler):