From b996debbcd0cd480db4c50263ad2134bf9150c2d Mon Sep 17 00:00:00 2001 From: shironeko Date: Sun, 15 Sep 2024 13:13:56 -0400 Subject: [PATCH] Add more Inovelli blue switch entities --- zha/application/platforms/number/__init__.py | 36 +++++++++++++++++++ zha/application/platforms/select.py | 19 ++++++++++ zha/application/platforms/sensor/__init__.py | 31 ++++++++++++++++ .../cluster_handlers/manufacturerspecific.py | 7 ++-- 4 files changed, 91 insertions(+), 2 deletions(-) diff --git a/zha/application/platforms/number/__init__.py b/zha/application/platforms/number/__init__.py index 6c3edec6..097c0e9d 100644 --- a/zha/application/platforms/number/__init__.py +++ b/zha/application/platforms/number/__init__.py @@ -650,6 +650,42 @@ class InovelliAutoShutoffTimer(NumberConfigurationEntity): _attr_translation_key: str = "auto_off_timer" +@CONFIG_DIAGNOSTIC_MATCH(cluster_handler_names=CLUSTER_HANDLER_INOVELLI) +class InovelliLocalDefaultLevel(NumberConfigurationEntity): + """Inovelli local default dimming/fan level configuration entity.""" + + _unique_id_suffix = "default_level_local" + _attr_entity_category = EntityCategory.CONFIG + _attr_native_min_value: float = 0 + _attr_native_max_value: float = 255 + _attribute_name = "default_level_local" + _attr_translation_key: str = "default_level_local" + + +@CONFIG_DIAGNOSTIC_MATCH(cluster_handler_names=CLUSTER_HANDLER_INOVELLI) +class InovelliRemoteDefaultLevel(NumberConfigurationEntity): + """Inovelli remote default dimming/fan level configuration entity.""" + + _unique_id_suffix = "default_level_remote" + _attr_entity_category = EntityCategory.CONFIG + _attr_native_min_value: float = 0 + _attr_native_max_value: float = 255 + _attribute_name = "default_level_remote" + _attr_translation_key: str = "default_level_remote" + + +@CONFIG_DIAGNOSTIC_MATCH(cluster_handler_names=CLUSTER_HANDLER_INOVELLI) +class InovelliStartupDefaultLevel(NumberConfigurationEntity): + """Inovelli start-up default dimming/fan level configuration entity.""" + + _unique_id_suffix = "state_after_power_restored" + _attr_entity_category = EntityCategory.CONFIG + _attr_native_min_value: float = 0 + _attr_native_max_value: float = 255 + _attribute_name = "state_after_power_restored" + _attr_translation_key: str = "state_after_power_restored" + + @CONFIG_DIAGNOSTIC_MATCH( cluster_handler_names=CLUSTER_HANDLER_INOVELLI, models={"VZM35-SN"} ) diff --git a/zha/application/platforms/select.py b/zha/application/platforms/select.py index e9c532fe..d0c7d09d 100644 --- a/zha/application/platforms/select.py +++ b/zha/application/platforms/select.py @@ -637,6 +637,25 @@ class InovelliNonNeutralOutputEntity(ZCLEnumSelectEntity): _attr_translation_key: str = "increased_non_neutral_output" +class InovelliDimmingMode(types.enum1): + """Inovelli dimming mode selection.""" + + LeadingEdge = 0x00 + TrailingEdge = 0x01 + + +@CONFIG_DIAGNOSTIC_MATCH( + cluster_handler_names=CLUSTER_HANDLER_INOVELLI, models={"VZM31-SN", "VZM36"} +) +class InovelliDimmingModeEntity(ZCLEnumSelectEntity): + """Inovelli dimming mode control.""" + + _unique_id_suffix = "leading_or_trailing_edge" + _attribute_name = "leading_or_trailing_edge" + _enum = InovelliDimmingMode + _attr_translation_key: str = "leading_or_trailing_edge" + + class AqaraFeedingMode(types.enum8): """Feeding mode.""" diff --git a/zha/application/platforms/sensor/__init__.py b/zha/application/platforms/sensor/__init__.py index 2c807208..d572e5b3 100644 --- a/zha/application/platforms/sensor/__init__.py +++ b/zha/application/platforms/sensor/__init__.py @@ -64,6 +64,7 @@ CLUSTER_HANDLER_ELECTRICAL_MEASUREMENT, CLUSTER_HANDLER_HUMIDITY, CLUSTER_HANDLER_ILLUMINANCE, + CLUSTER_HANDLER_INOVELLI, CLUSTER_HANDLER_LEAF_WETNESS, CLUSTER_HANDLER_POWER_CONFIGURATION, CLUSTER_HANDLER_PRESSURE, @@ -1140,6 +1141,36 @@ class DeviceTemperature(Sensor): _attr_entity_category = EntityCategory.DIAGNOSTIC +@MULTI_MATCH(cluster_handler_names=CLUSTER_HANDLER_INOVELLI) +class InovelliInternalTemperature(Sensor): + """Switch Internal Temperature Sensor.""" + + _attribute_name = "internal_temp_monitor" + _attr_device_class: SensorDeviceClass = SensorDeviceClass.TEMPERATURE + _attr_state_class: SensorStateClass = SensorStateClass.MEASUREMENT + _attr_translation_key: str = "internal_temp_monitor" + _attr_native_unit_of_measurement = UnitOfTemperature.CELSIUS + _attr_entity_category = EntityCategory.DIAGNOSTIC + + +class InovelliOverheatedState(types.enum8): + """Inovelli overheat protection state.""" + + Normal = 0x00 + Overheated = 0x01 + + +@MULTI_MATCH(cluster_handler_names=CLUSTER_HANDLER_INOVELLI) +class InovelliOverheated(EnumSensor): + """Sensor that displays the overheat protection state.""" + + _attribute_name = "overheated" + _unique_id_suffix = "overheated" + _attr_translation_key: str = "overheated" + _enum = InovelliOverheatedState + _attr_entity_category = EntityCategory.DIAGNOSTIC + + @MULTI_MATCH(cluster_handler_names="carbon_dioxide_concentration") class CarbonDioxideConcentration(Sensor): """Carbon Dioxide Concentration sensor.""" diff --git a/zha/zigbee/cluster_handlers/manufacturerspecific.py b/zha/zigbee/cluster_handlers/manufacturerspecific.py index 5f65b17f..da6eb4be 100644 --- a/zha/zigbee/cluster_handlers/manufacturerspecific.py +++ b/zha/zigbee/cluster_handlers/manufacturerspecific.py @@ -261,12 +261,12 @@ def __init__(self, cluster: zigpy.zcl.Cluster, endpoint: Endpoint) -> None: self.ZCL_INIT_ATTRS = { "dimming_speed_up_remote": True, "dimming_speed_up_local": True, - "ramp_rate_off_to_on_local": True, "ramp_rate_off_to_on_remote": True, + "ramp_rate_off_to_on_local": True, "dimming_speed_down_remote": True, "dimming_speed_down_local": True, - "ramp_rate_on_to_off_local": True, "ramp_rate_on_to_off_remote": True, + "ramp_rate_on_to_off_local": True, "minimum_level": True, "maximum_level": True, "invert_switch": True, @@ -281,6 +281,9 @@ def __init__(self, cluster: zigpy.zcl.Cluster, endpoint: Endpoint) -> None: "power_type": False, "switch_type": False, "increased_non_neutral_output": True, + "leading_or_trailing_edge": True, + "internal_temp_monitor": True, + "overheated": True, "button_delay": False, "smart_bulb_mode": False, "double_tap_up_enabled": True,