Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 34 additions & 1 deletion zha/application/platforms/number/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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,
Expand Down Expand Up @@ -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."""
Expand Down
1 change: 1 addition & 0 deletions zha/zigbee/cluster_handlers/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
5 changes: 5 additions & 0 deletions zha/zigbee/cluster_handlers/lighting.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
Loading