Skip to content

Commit

Permalink
Merge pull request #2 from Caius-Bonus/RemoveCustomClusters
Browse files Browse the repository at this point in the history
Remove custom clusters
  • Loading branch information
Caius-Bonus authored Sep 29, 2023
2 parents 4ea28e7 + b8b90e5 commit 7a955a0
Show file tree
Hide file tree
Showing 7 changed files with 131 additions and 34 deletions.
15 changes: 12 additions & 3 deletions homeassistant/components/zha/binary_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,10 @@ class AqaraLinkageAlarmState(BinarySensor, id_suffix="linkage_alarm_state"):
_attr_device_class: BinarySensorDeviceClass = BinarySensorDeviceClass.SMOKE


@MULTI_MATCH(cluster_handler_names="danfoss_trv_cluster")
@MULTI_MATCH(
cluster_handler_names="thermostat",
quirk_classes={"thermostat.DanfossThermostat"},
)
class DanfossMountingModeActive(BinarySensor, id_suffix="mounting_mode_active"):
"""Danfoss TRV Proprietary attribute exposing whether in mounting mode."""

Expand All @@ -349,15 +352,21 @@ class DanfossMountingModeActive(BinarySensor, id_suffix="mounting_mode_active"):
_attr_name: str = "Mounting Mode Active"


@MULTI_MATCH(cluster_handler_names="danfoss_trv_cluster")
@MULTI_MATCH(
cluster_handler_names="thermostat",
quirk_classes={"thermostat.DanfossThermostat"},
)
class DanfossHeatRequired(BinarySensor, id_suffix="heat_required"):
"""Danfoss TRV Proprietary attribute exposing whether heat is required."""

SENSOR_ATTR = "heat_required"
_attr_name: str = "Heat Required"


@MULTI_MATCH(cluster_handler_names="danfoss_trv_cluster")
@MULTI_MATCH(
cluster_handler_names="thermostat",
quirk_classes={"thermostat.DanfossThermostat"},
)
class DanfossPreheatStatus(BinarySensor, id_suffix="preheat_status"):
"""Danfoss TRV Proprietary attribute exposing whether in pre-heating mode."""

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -377,11 +377,26 @@ class IkeaRemote(ClusterHandler):
REPORT_CONFIG = ()


@registries.CLUSTER_HANDLER_ONLY_CLUSTERS.register(registries.DANFOSS_TRV_CLUSTER)
@registries.ZIGBEE_CLUSTER_HANDLER_REGISTRY.register(registries.DANFOSS_TRV_CLUSTER)
DANFOSS_TRVS = {
"Danfoss",
"D5X84YU",
}


@registries.CLUSTER_HANDLER_ONLY_CLUSTERS.register(
zigpy.zcl.clusters.hvac.Thermostat.cluster_id
)
@registries.ZIGBEE_CLUSTER_HANDLER_REGISTRY.register(
zigpy.zcl.clusters.hvac.Thermostat.cluster_id
)
class DanfossTRVChannel(ClusterHandler):
"""TRV Channel class for the Danfoss TRV and derivatives."""

@classmethod
def matches(cls, cluster: zigpy.zcl.Cluster, endpoint: Endpoint) -> bool:
"""Filter the cluster match for specific devices."""
return cluster.endpoint.device.manufacturer in DANFOSS_TRVS

REPORT_CONFIG = (
AttrReportConfig(attr="open_window_detection", config=REPORT_CONFIG_DEFAULT),
AttrReportConfig(attr="heat_required", config=REPORT_CONFIG_ASAP),
Expand Down Expand Up @@ -410,26 +425,36 @@ class DanfossTRVChannel(ClusterHandler):


@registries.CLUSTER_HANDLER_ONLY_CLUSTERS.register(
registries.DANFOSS_TRV_DIAGNOSTIC_CLUSTER
zigpy.zcl.clusters.hvac.UserInterface.cluster_id
)
@registries.ZIGBEE_CLUSTER_HANDLER_REGISTRY.register(
registries.DANFOSS_TRV_INTERFACE_CLUSTER
zigpy.zcl.clusters.hvac.UserInterface.cluster_id
)
class DanfossTRVInterfaceChannel(ClusterHandler):
"""Interface Channel class for the Danfoss TRV and derivatives."""

@classmethod
def matches(cls, cluster: zigpy.zcl.Cluster, endpoint: Endpoint) -> bool:
"""Filter the cluster match for specific devices."""
return cluster.endpoint.device.manufacturer in DANFOSS_TRVS

ZCL_INIT_ATTRS = {"viewing_direction": True}


@registries.CLUSTER_HANDLER_ONLY_CLUSTERS.register(
registries.DANFOSS_TRV_DIAGNOSTIC_CLUSTER
zigpy.zcl.clusters.homeautomation.Diagnostic.cluster_id
)
@registries.ZIGBEE_CLUSTER_HANDLER_REGISTRY.register(
registries.DANFOSS_TRV_DIAGNOSTIC_CLUSTER
zigpy.zcl.clusters.homeautomation.Diagnostic.cluster_id
)
class DanfossTRVDiagnosticChannel(ClusterHandler):
"""Diagnostic Channel class for the Danfoss TRV and derivatives."""

@classmethod
def matches(cls, cluster: zigpy.zcl.Cluster, endpoint: Endpoint) -> bool:
"""Filter the cluster match for specific devices."""
return cluster.endpoint.device.manufacturer in DANFOSS_TRVS

REPORT_CONFIG = (
AttrReportConfig(attr="sw_error_code", config=REPORT_CONFIG_DEFAULT),
AttrReportConfig(attr="motor_step_counter", config=REPORT_CONFIG_DEFAULT),
Expand Down
3 changes: 0 additions & 3 deletions homeassistant/components/zha/core/registries.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,6 @@
SMARTTHINGS_HUMIDITY_CLUSTER = 0xFC45
TUYA_MANUFACTURER_CLUSTER = 0xEF00
VOC_LEVEL_CLUSTER = 0x042E
DANFOSS_TRV_CLUSTER = 0xFC05
DANFOSS_TRV_INTERFACE_CLUSTER = 0xFC06
DANFOSS_TRV_DIAGNOSTIC_CLUSTER = 0xFC07

REMOTE_DEVICE_TYPES = {
zigpy.profiles.zha.PROFILE_ID: [
Expand Down
25 changes: 20 additions & 5 deletions homeassistant/components/zha/number.py
Original file line number Diff line number Diff line change
Expand Up @@ -1023,7 +1023,10 @@ class MinHeatSetpointLimit(
max_source = "max_heat_setpoint_limit"


@CONFIG_DIAGNOSTIC_MATCH(cluster_handler_names="danfoss_trv_cluster")
@CONFIG_DIAGNOSTIC_MATCH(
cluster_handler_names="thermostat",
quirk_classes={"thermostat.DanfossThermostat"},
)
# pylint: disable-next=hass-invalid-inheritance # needs fixing
class DanfossExerciseTriggerTime(
ZHANumberConfigurationEntity, id_suffix="exercise_trigger_time"
Expand All @@ -1039,7 +1042,10 @@ class DanfossExerciseTriggerTime(
_attr_icon: str = "mdi:clock"


@CONFIG_DIAGNOSTIC_MATCH(cluster_handler_names="danfoss_trv_cluster")
@CONFIG_DIAGNOSTIC_MATCH(
cluster_handler_names="thermostat",
quirk_classes={"thermostat.DanfossThermostat"},
)
# pylint: disable-next=hass-invalid-inheritance # needs fixing
class DanfossExternalMeasuredRoomSensor(
ZCLTemperatureEntity, id_suffix="external_measured_room_sensor"
Expand All @@ -1053,7 +1059,10 @@ class DanfossExternalMeasuredRoomSensor(
_attr_icon: str = "mdi:thermometer"


@CONFIG_DIAGNOSTIC_MATCH(cluster_handler_names="danfoss_trv_cluster")
@CONFIG_DIAGNOSTIC_MATCH(
cluster_handler_names="thermostat",
quirk_classes={"thermostat.DanfossThermostat"},
)
# pylint: disable-next=hass-invalid-inheritance # needs fixing
class DanfossLoadRoomMean(ZHANumberConfigurationEntity, id_suffix="load_room_mean"):
"""Danfoss Proprietary Attribute to set a value for the load."""
Expand All @@ -1066,7 +1075,10 @@ class DanfossLoadRoomMean(ZHANumberConfigurationEntity, id_suffix="load_room_mea
_attr_icon: str = "mdi:scale-balance"


@CONFIG_DIAGNOSTIC_MATCH(cluster_handler_names="danfoss_trv_cluster")
@CONFIG_DIAGNOSTIC_MATCH(
cluster_handler_names="thermostat",
quirk_classes={"thermostat.DanfossThermostat"},
)
# pylint: disable-next=hass-invalid-inheritance # needs fixing
class DanfossControlAlgorithmScaleFactor(
ZHANumberConfigurationEntity, id_suffix="control_algorithm_scale_factor"
Expand All @@ -1081,7 +1093,10 @@ class DanfossControlAlgorithmScaleFactor(
_attr_icon: str = "mdi:knob"


@CONFIG_DIAGNOSTIC_MATCH(cluster_handler_names="danfoss_trv_cluster")
@CONFIG_DIAGNOSTIC_MATCH(
cluster_handler_names="thermostat",
quirk_classes={"thermostat.DanfossThermostat"},
)
# pylint: disable-next=hass-invalid-inheritance # needs fixing
class DanfossRegulationSetpointOffset(
ZHANumberConfigurationEntity, id_suffix="regulation_setpoint_offset"
Expand Down
20 changes: 16 additions & 4 deletions homeassistant/components/zha/select.py
Original file line number Diff line number Diff line change
Expand Up @@ -607,7 +607,10 @@ class DanfossExerciseDayOfTheWeekEnum(types.enum8):
Saturday = 6


@CONFIG_DIAGNOSTIC_MATCH(cluster_handler_names="danfoss_trv_cluster")
@CONFIG_DIAGNOSTIC_MATCH(
cluster_handler_names="thermostat",
quirk_classes={"thermostat.DanfossThermostat"},
)
class DanfossExerciseDayOfTheWeek(
ZCLEnumSelectEntity, id_suffix="exercise_day_of_week"
):
Expand All @@ -626,7 +629,10 @@ class DanfossOrientationEnum(types.enum8):
Vertical = 0x01


@CONFIG_DIAGNOSTIC_MATCH(cluster_handler_names="danfoss_trv_cluster")
@CONFIG_DIAGNOSTIC_MATCH(
cluster_handler_names="thermostat",
quirk_classes={"thermostat.DanfossThermostat"},
)
class DanfossOrientation(ZCLEnumSelectEntity, id_suffix="orientation"):
"""Danfoss Proprietary attribute for setting the orientation of the valve.
Expand All @@ -646,7 +652,10 @@ class DanfossAdaptationRunControlEnum(types.enum8):
Cancel = 0x02


@CONFIG_DIAGNOSTIC_MATCH(cluster_handler_names="danfoss_trv_cluster")
@CONFIG_DIAGNOSTIC_MATCH(
cluster_handler_names="thermostat",
quirk_classes={"thermostat.DanfossThermostat"},
)
class DanfossAdaptationRunControl(
ZCLEnumSelectEntity, id_suffix="adaptation_run_control"
):
Expand All @@ -664,7 +673,10 @@ class DanfossViewingDirectionEnum(types.enum8):
Inverted = 0x01


@CONFIG_DIAGNOSTIC_MATCH(cluster_handler_names="danfoss_trv_interface_cluster")
@CONFIG_DIAGNOSTIC_MATCH(
cluster_handler_names="thermostat_ui",
quirk_classes={"thermostat.DanfossThermostat"},
)
class DanfossViewingDirection(ZCLEnumSelectEntity, id_suffix="viewing_direction"):
"""Danfoss Proprietary attribute for setting the viewing direction of the screen."""

Expand Down
30 changes: 24 additions & 6 deletions homeassistant/components/zha/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -1111,7 +1111,10 @@ class DanfossOpenWindowDetectionEnum(types.enum8):
External = 0x04


@MULTI_MATCH(cluster_handler_names="danfoss_trv_cluster")
@MULTI_MATCH(
cluster_handler_names="thermostat",
quirk_classes={"thermostat.DanfossThermostat"},
)
# pylint: disable-next=hass-invalid-inheritance # needs fixing
class DanfossOpenWindowDetection(Sensor, id_suffix="open_window_detection"):
"""Danfoss Proprietary attribute.
Expand All @@ -1129,7 +1132,10 @@ def formatter(self, value: int) -> str:
return DanfossOpenWindowDetectionEnum(value).name


@MULTI_MATCH(cluster_handler_names="danfoss_trv_cluster")
@MULTI_MATCH(
cluster_handler_names="thermostat",
quirk_classes={"thermostat.DanfossThermostat"},
)
# pylint: disable-next=hass-invalid-inheritance # needs fixing
class DanfossLoadEstimate(Sensor, id_suffix="load_estimate"):
"""Danfoss Proprietary attribute for communicating its estimate of the radiator load."""
Expand All @@ -1139,7 +1145,10 @@ class DanfossLoadEstimate(Sensor, id_suffix="load_estimate"):
_attr_icon: str = "mdi:scale-balance"


@MULTI_MATCH(cluster_handler_names="danfoss_trv_cluster")
@MULTI_MATCH(
cluster_handler_names="thermostat",
quirk_classes={"thermostat.DanfossThermostat"},
)
# pylint: disable-next=hass-invalid-inheritance # needs fixing
class DanfossAdaptationRunStatus(Sensor, id_suffix="adaptation_run_status"):
"""Danfoss Proprietary attribute for showing the status of the adaptation run."""
Expand Down Expand Up @@ -1167,7 +1176,10 @@ def extra_state_attributes(self) -> dict[str, Any]:
}


@MULTI_MATCH(cluster_handler_names="danfoss_trv_cluster")
@MULTI_MATCH(
cluster_handler_names="thermostat",
quirk_classes={"thermostat.DanfossThermostat"},
)
# pylint: disable-next=hass-invalid-inheritance # needs fixing
class DanfossPreheatTime(Sensor, id_suffix="preheat_time"):
"""Danfoss Proprietary attribute for communicating the time when it starts pre-heating."""
Expand All @@ -1178,7 +1190,10 @@ class DanfossPreheatTime(Sensor, id_suffix="preheat_time"):
_attr_entity_registry_enabled_default = False


@MULTI_MATCH(cluster_handler_names="danfoss_trv_diagnostic_cluster")
@MULTI_MATCH(
cluster_handler_names="diagnostic",
quirk_classes={"thermostat.DanfossThermostat"},
)
# pylint: disable-next=hass-invalid-inheritance # needs fixing
class DanfossSoftwareErrorCode(Sensor, id_suffix="sw_error_code"):
"""Danfoss Proprietary attribute for communicating the error code."""
Expand Down Expand Up @@ -1219,7 +1234,10 @@ def extra_state_attributes(self) -> dict[str, Any]:
}


@MULTI_MATCH(cluster_handler_names="danfoss_trv_diagnostic_cluster")
@MULTI_MATCH(
cluster_handler_names="diagnostic",
quirk_classes={"thermostat.DanfossThermostat"},
)
# pylint: disable-next=hass-invalid-inheritance # needs fixing
class DanfossMotorStepCounter(Sensor, id_suffix="motor_step_counter"):
"""Danfoss Proprietary attribute for communicating the motor step counter."""
Expand Down
35 changes: 28 additions & 7 deletions homeassistant/components/zha/switch.py
Original file line number Diff line number Diff line change
Expand Up @@ -589,7 +589,10 @@ class TuyaChildLockSwitch(ZHASwitchConfigurationEntity, id_suffix="child_lock"):
_attr_icon: str = "mdi:account-lock"


@CONFIG_DIAGNOSTIC_MATCH(cluster_handler_names="danfoss_trv_cluster")
@CONFIG_DIAGNOSTIC_MATCH(
cluster_handler_names="thermostat",
quirk_classes={"thermostat.DanfossThermostat"},
)
class DanfossExternalOpenWindowDetected(
ZHASwitchConfigurationEntity, id_suffix="external_open_window_detected"
):
Expand All @@ -600,7 +603,10 @@ class DanfossExternalOpenWindowDetected(
_attr_icon: str = "mdi:window-open"


@CONFIG_DIAGNOSTIC_MATCH(cluster_handler_names="danfoss_trv_cluster")
@CONFIG_DIAGNOSTIC_MATCH(
cluster_handler_names="thermostat",
quirk_classes={"thermostat.DanfossThermostat"},
)
class DanfossWindowOpenFeature(
ZHASwitchConfigurationEntity, id_suffix="window_open_feature"
):
Expand All @@ -611,7 +617,10 @@ class DanfossWindowOpenFeature(
_attr_icon: str = "mdi:window-open"


@CONFIG_DIAGNOSTIC_MATCH(cluster_handler_names="danfoss_trv_cluster")
@CONFIG_DIAGNOSTIC_MATCH(
cluster_handler_names="thermostat",
quirk_classes={"thermostat.DanfossThermostat"},
)
class DanfossMountingModeControl(
ZHASwitchConfigurationEntity, id_suffix="mounting_mode_control"
):
Expand All @@ -621,7 +630,10 @@ class DanfossMountingModeControl(
_attr_name: str = "Mounting Mode Control"


@CONFIG_DIAGNOSTIC_MATCH(cluster_handler_names="danfoss_trv_cluster")
@CONFIG_DIAGNOSTIC_MATCH(
cluster_handler_names="thermostat",
quirk_classes={"thermostat.DanfossThermostat"},
)
class DanfossRadiatorCovered(
ZHASwitchConfigurationEntity, id_suffix="radiator_covered"
):
Expand All @@ -632,7 +644,10 @@ class DanfossRadiatorCovered(
_attr_icon: str = "mdi:thermometer"


@CONFIG_DIAGNOSTIC_MATCH(cluster_handler_names="danfoss_trv_cluster")
@CONFIG_DIAGNOSTIC_MATCH(
cluster_handler_names="thermostat",
quirk_classes={"thermostat.DanfossThermostat"},
)
class DanfossHeatAvailable(ZHASwitchConfigurationEntity, id_suffix="heat_available"):
"""Danfoss Proprietary attribute for communicating available heat."""

Expand All @@ -641,7 +656,10 @@ class DanfossHeatAvailable(ZHASwitchConfigurationEntity, id_suffix="heat_availab
_attr_icon: str = "mdi:water-boiler"


@CONFIG_DIAGNOSTIC_MATCH(cluster_handler_names="danfoss_trv_cluster")
@CONFIG_DIAGNOSTIC_MATCH(
cluster_handler_names="thermostat",
quirk_classes={"thermostat.DanfossThermostat"},
)
class DanfossLoadBalancingEnable(
ZHASwitchConfigurationEntity, id_suffix="load_balancing_enable"
):
Expand All @@ -652,7 +670,10 @@ class DanfossLoadBalancingEnable(
_attr_icon: str = "mdi:scale-balance"


@CONFIG_DIAGNOSTIC_MATCH(cluster_handler_names="danfoss_trv_cluster")
@CONFIG_DIAGNOSTIC_MATCH(
cluster_handler_names="thermostat",
quirk_classes={"thermostat.DanfossThermostat"},
)
class DanfossAdaptationRunSettings(
ZHASwitchConfigurationEntity, id_suffix="adaptation_run_settings"
):
Expand Down

0 comments on commit 7a955a0

Please sign in to comment.