diff --git a/homeassistant/components/zha/core/channels/manufacturerspecific.py b/homeassistant/components/zha/core/channels/manufacturerspecific.py index f31c7f51371..3bcab38e026 100644 --- a/homeassistant/components/zha/core/channels/manufacturerspecific.py +++ b/homeassistant/components/zha/core/channels/manufacturerspecific.py @@ -1,7 +1,9 @@ """Manufacturer specific channels module for Zigbee Home Automation.""" +import logging + from homeassistant.core import callback -from .. import registries +from .. import registries, typing as zha_typing from ..const import ( ATTR_ATTRIBUTE_ID, ATTR_ATTRIBUTE_NAME, @@ -14,6 +16,8 @@ from ..const import ( ) from .base import ClientChannel, ZigbeeChannel +_LOGGER = logging.getLogger(__name__) + @registries.ZIGBEE_CHANNEL_REGISTRY.register(registries.SMARTTHINGS_HUMIDITY_CLUSTER) class SmartThingsHumidity(ZigbeeChannel): @@ -50,6 +54,26 @@ class OppleRemote(ZigbeeChannel): REPORT_CONFIG = [] + def __init__( + self, cluster: zha_typing.ZigpyClusterType, ch_pool: zha_typing.ChannelPoolType + ) -> None: + """Initialize Opple channel.""" + super().__init__(cluster, ch_pool) + if self.cluster.endpoint.model == "lumi.motion.ac02": + self.ZCL_INIT_ATTRS = { # pylint: disable=C0103 + "detection_interval": True, + "motion_sensitivity": True, + "trigger_indicator": True, + } + + async def async_initialize_channel_specific(self, from_cache: bool) -> None: + """Initialize channel specific.""" + if self.cluster.endpoint.model == "lumi.motion.ac02": + interval = self.cluster.get("detection_interval", self.cluster.get(0x0102)) + if interval is not None: + self.debug("Loaded detection interval at startup: %s", interval) + self.cluster.endpoint.ias_zone.reset_s = int(interval) + @registries.ZIGBEE_CHANNEL_REGISTRY.register( registries.SMARTTHINGS_ACCELERATION_CLUSTER diff --git a/homeassistant/components/zha/number.py b/homeassistant/components/zha/number.py index bece4bc894d..216b9974df6 100644 --- a/homeassistant/components/zha/number.py +++ b/homeassistant/components/zha/number.py @@ -433,6 +433,17 @@ class ZHANumberConfigurationEntity(ZhaEntity, NumberEntity): _LOGGER.debug("read value=%s", value) +@CONFIG_DIAGNOSTIC_MATCH(channel_names="opple_cluster", models={"lumi.motion.ac02"}) +class AqaraMotionDetectionInterval( + ZHANumberConfigurationEntity, id_suffix="detection_interval" +): + """Representation of a ZHA on off transition time configuration entity.""" + + _attr_min_value: float = 2 + _attr_max_value: float = 65535 + _zcl_attribute: str = "detection_interval" + + @CONFIG_DIAGNOSTIC_MATCH(channel_names=CHANNEL_LEVEL) class OnOffTransitionTimeConfigurationEntity( ZHANumberConfigurationEntity, id_suffix="on_off_transition_time" diff --git a/homeassistant/components/zha/select.py b/homeassistant/components/zha/select.py index afa2ee18da9..8714d804790 100644 --- a/homeassistant/components/zha/select.py +++ b/homeassistant/components/zha/select.py @@ -5,6 +5,7 @@ from enum import Enum import functools import logging +from zigpy import types from zigpy.zcl.clusters.general import OnOff from zigpy.zcl.clusters.security import IasWd @@ -208,3 +209,19 @@ class ZHAStartupOnOffSelectEntity( _select_attr = "start_up_on_off" _enum: Enum = OnOff.StartUpOnOff + + +class AqaraMotionSensitivities(types.enum8): + """Aqara motion sensitivities.""" + + Low = 0x01 + Medium = 0x02 + High = 0x03 + + +@CONFIG_DIAGNOSTIC_MATCH(channel_names="opple_cluster", models={"lumi.motion.ac02"}) +class AqaraMotionSensitivity(ZCLEnumSelectEntity, id_suffix="motion_sensitivity"): + """Representation of a ZHA on off transition time configuration entity.""" + + _select_attr = "motion_sensitivity" + _enum: Enum = AqaraMotionSensitivities diff --git a/homeassistant/components/zha/switch.py b/homeassistant/components/zha/switch.py index 800c42eb932..d9199ed77c8 100644 --- a/homeassistant/components/zha/switch.py +++ b/homeassistant/components/zha/switch.py @@ -155,6 +155,7 @@ class SwitchGroup(ZhaGroupEntity, SwitchEntity): class ZHASwitchConfigurationEntity(ZhaEntity, SwitchEntity): """Representation of a ZHA switch configuration entity.""" + _attr_entity_category = EntityCategory.CONFIG _zcl_attribute: str _zcl_inverter_attribute: str = "" @@ -260,8 +261,16 @@ class ZHASwitchConfigurationEntity(ZhaEntity, SwitchEntity): class OnOffWindowDetectionFunctionConfigurationEntity( ZHASwitchConfigurationEntity, id_suffix="on_off_window_opened_detection" ): - """Representation of a ZHA on off transition time configuration entity.""" + """Representation of a ZHA window detection configuration entity.""" - _attr_entity_category = EntityCategory.CONFIG _zcl_attribute = "window_detection_function" _zcl_inverter_attribute = "window_detection_function_inverter" + + +@CONFIG_DIAGNOSTIC_MATCH(channel_names="opple_cluster", models={"lumi.motion.ac02"}) +class P1MotionTriggerIndicatorSwitch( + ZHASwitchConfigurationEntity, id_suffix="trigger_indicator" +): + """Representation of a ZHA motion triggering configuration entity.""" + + _zcl_attribute = "trigger_indicator"