Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add more Inovelli blue switch entities #203

Merged
merged 1 commit into from
Sep 25, 2024
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
36 changes: 36 additions & 0 deletions zha/application/platforms/number/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"}
)
Expand Down
19 changes: 19 additions & 0 deletions zha/application/platforms/select.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should start migrating the Inovelli attributes in the quirk to the new Zigpy format, this will keep enums like this out of ZHA:

class LeadingOrTrailingEdge(t.enum8):
    LeadingEdge = 0x00
    TrailingEdge = 0x01


class InovelliVZM31SNCluster(CustomCluster):
    name = "InovelliVZM31SNCluster"

    class AttributeDefs(BaseAttributeDefs):
        """Attribute definitions."""
        ...

        leading_or_trailing_edge = ZCLAttributeDef(
            id=0x001A,
            type=LeadingOrTrailingEdge,
            zcl_type=DataTypeId.bool, # It's really a bool on the device
            is_manufacturer_specific=True,
        )

        ...



@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."""

Expand Down
31 changes: 31 additions & 0 deletions zha/application/platforms/sensor/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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."""
Expand Down
7 changes: 5 additions & 2 deletions zha/zigbee/cluster_handlers/manufacturerspecific.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand Down
Loading