Skip to content
Open
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
61 changes: 2 additions & 59 deletions zhaquirks/candeo/__init__.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,13 @@
"""Module for Candeo quirks implementations."""

import math
from typing import Final

import zigpy.types as t
from zigpy.zcl.clusters.general import Basic, LevelControl, OnOff
from zigpy.zcl.clusters.general import Basic
from zigpy.zcl.clusters.lighting import Color
from zigpy.zcl.clusters.measurement import IlluminanceMeasurement
from zigpy.zcl.clusters.security import IasZone
from zigpy.zcl.foundation import (
BaseCommandDefs,
DataTypeId,
ZCLAttributeDef,
ZCLCommandDef,
)
from zigpy.zcl.foundation import DataTypeId, ZCLAttributeDef

from zhaquirks.clusters import CustomCluster
from zhaquirks.const import ZONE_TYPE
Expand All @@ -28,13 +22,6 @@ class CandeoSwitchType(t.enum8):
Toggle = 0x01


class CandeoRemoteDirection(t.enum8):
"""Candeo Remote Direction."""

Right = 0x00
Left = 0x01


class CandeoIlluminanceMeasurementCluster(IlluminanceMeasurement, CustomCluster):
"""Candeo Illuminance Measurement Cluster."""

Expand Down Expand Up @@ -118,47 +105,3 @@ class CandeoRGBCCTColorCluster(Color, CustomCluster):
Color.AttributeDefs.color_capabilities.id: Color.ColorCapabilities.XY_attributes
+ Color.ColorCapabilities.Color_temperature
}


class CandeoOnOffRemoteCluster(OnOff, CustomCluster):
"""Candeo OnOff Remote Cluster."""

class ServerCommandDefs(BaseCommandDefs):
"""overwrite ServerCommandDefs."""

double: Final = ZCLCommandDef(
id=0x00,
schema={},
)
press: Final = ZCLCommandDef(
id=0x01,
schema={},
)
hold: Final = ZCLCommandDef(
id=0x02,
schema={},
)
release: Final = ZCLCommandDef(
id=0x03,
schema={},
)


class CandeoLevelControlRemoteCluster(LevelControl, CustomCluster):
"""Candeo LevelControl Remote Cluster."""

class ServerCommandDefs(BaseCommandDefs):
"""overwrite ServerCommandDefs."""

started_rotating: Final = ZCLCommandDef(
id=0x05,
schema={"direction": CandeoRemoteDirection},
)
continued_rotating: Final = ZCLCommandDef(
id=0x06,
schema={"direction": CandeoRemoteDirection},
)
stopped_rotating: Final = ZCLCommandDef(
id=0x03,
schema={},
)
168 changes: 162 additions & 6 deletions zhaquirks/candeo/rotary_dimmer_switches.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,20 @@
"""Candeo rotary dimmer switches."""

from typing import Final

from zigpy.quirks import CustomCluster

Check warning on line 5 in zhaquirks/candeo/rotary_dimmer_switches.py

View workflow job for this annotation

GitHub Actions / shared-ci / Run tests Python 3.13

`zigpy.quirks.CustomCluster` is deprecated, import `CustomCluster` from `zhaquirks.clusters` instead

Check warning on line 5 in zhaquirks/candeo/rotary_dimmer_switches.py

View workflow job for this annotation

GitHub Actions / shared-ci / Run tests Python 3.13

`zigpy.quirks.CustomCluster` is deprecated, import `CustomCluster` from `zhaquirks.clusters` instead

Check warning on line 5 in zhaquirks/candeo/rotary_dimmer_switches.py

View workflow job for this annotation

GitHub Actions / shared-ci / Run tests Python 3.13

`zigpy.quirks.CustomCluster` is deprecated, import `CustomCluster` from `zhaquirks.clusters` instead

Check warning on line 5 in zhaquirks/candeo/rotary_dimmer_switches.py

View workflow job for this annotation

GitHub Actions / shared-ci / Run tests Python 3.13

`zigpy.quirks.CustomCluster` is deprecated, import `CustomCluster` from `zhaquirks.clusters` instead

Check warning on line 5 in zhaquirks/candeo/rotary_dimmer_switches.py

View workflow job for this annotation

GitHub Actions / shared-ci / Run tests Python 3.12

`zigpy.quirks.CustomCluster` is deprecated, import `CustomCluster` from `zhaquirks.clusters` instead

Check warning on line 5 in zhaquirks/candeo/rotary_dimmer_switches.py

View workflow job for this annotation

GitHub Actions / shared-ci / Run tests Python 3.12

`zigpy.quirks.CustomCluster` is deprecated, import `CustomCluster` from `zhaquirks.clusters` instead

Check warning on line 5 in zhaquirks/candeo/rotary_dimmer_switches.py

View workflow job for this annotation

GitHub Actions / shared-ci / Run tests Python 3.12

`zigpy.quirks.CustomCluster` is deprecated, import `CustomCluster` from `zhaquirks.clusters` instead

Check warning on line 5 in zhaquirks/candeo/rotary_dimmer_switches.py

View workflow job for this annotation

GitHub Actions / shared-ci / Run tests Python 3.12

`zigpy.quirks.CustomCluster` is deprecated, import `CustomCluster` from `zhaquirks.clusters` instead
import zigpy.types as t
from zigpy.zcl import ClusterType
from zigpy.zcl.clusters.general import Identify, Ota
from zigpy.zcl.clusters.general import Identify, LevelControl, OnOff, Ota
from zigpy.zcl.foundation import (
BaseCommandDefs,
DataTypeId,
ZCLAttributeDef,
ZCLCommandDef,
)

from zhaquirks.builder import QuirkBuilder
from zhaquirks.candeo import (
CANDEO,
CandeoLevelControlRemoteCluster,
CandeoOnOffRemoteCluster,
)
from zhaquirks.candeo import CANDEO
from zhaquirks.const import (
CLUSTER_ID,
COMMAND,
Expand All @@ -33,6 +39,147 @@
STOPPED_ROTATING,
)


class CandeoRemoteDirection(t.enum8):
"""Candeo Remote Direction."""

Right = 0x00
Left = 0x01


class CandeoRemoteLiteEP2Functionality(t.enum8):
"""Candeo remote lite EP2 functionality enum."""

disabled = False
enabled = True


class CandeoOnOffRemoteCluster(OnOff, CustomCluster):
"""Candeo OnOff Remote Cluster."""

class ServerCommandDefs(BaseCommandDefs):
"""overwrite ServerCommandDefs."""

double: Final = ZCLCommandDef(
id=0x00,
schema={},
)
press: Final = ZCLCommandDef(
id=0x01,
schema={},
)
hold: Final = ZCLCommandDef(
id=0x02,
schema={},
)
release: Final = ZCLCommandDef(
id=0x03,
schema={},
)


class CandeoLevelControlRemoteCluster(LevelControl, CustomCluster):
"""Candeo LevelControl Remote Cluster."""

class ServerCommandDefs(BaseCommandDefs):
"""overwrite ServerCommandDefs."""

started_rotating: Final = ZCLCommandDef(
id=0x05,
schema={"direction": CandeoRemoteDirection},
)
continued_rotating: Final = ZCLCommandDef(
id=0x06,
schema={"direction": CandeoRemoteDirection},
)
stopped_rotating: Final = ZCLCommandDef(
id=0x03,
schema={},
)


class CandeoOnOffRemoteLiteEP2FunctionalityCluster(OnOff, CustomCluster):
"""Candeo OnOff Remote Lite EP2 Functionality Cluster."""

class AttributeDefs(OnOff.AttributeDefs):
"""Attribute Definitions."""

rem_lite_ep2_functionality = ZCLAttributeDef(
id=0x8000,
type=CandeoRemoteLiteEP2Functionality,
zcl_type=DataTypeId.bool_,
access="rw",
)

_VALID_ATTRIBUTES = {
AttributeDefs.rem_lite_ep2_functionality.id,
}


class CandeoOnOffRemoteLiteCluster(OnOff, CustomCluster):
"""Candeo OnOff Remote Lite Cluster."""

class ServerCommandDefs(BaseCommandDefs):
"""overwrite ServerCommandDefs."""

double: Final = ZCLCommandDef(
id=0x00,
schema={},
)
hold: Final = ZCLCommandDef(
id=0x02,
schema={},
)
release: Final = ZCLCommandDef(
id=0x03,
schema={},
)


remote_lite_quirk = (
QuirkBuilder()
.replaces(
CandeoOnOffRemoteLiteEP2FunctionalityCluster,
endpoint_id=1,
)
.replaces(
CandeoOnOffRemoteLiteCluster,
endpoint_id=2,
cluster_type=ClusterType.Client,
)
.removes(
OnOff.cluster_id,
endpoint_id=3,
)
.enum(
attribute_name=CandeoOnOffRemoteLiteEP2FunctionalityCluster.AttributeDefs.rem_lite_ep2_functionality.name,
cluster_id=CandeoOnOffRemoteLiteEP2FunctionalityCluster.cluster_id,
endpoint_id=1,
translation_key="rem_lite_ep2_functionality",
fallback_name="Extra button commands",
enum_class=CandeoRemoteLiteEP2Functionality,
)
.device_automation_triggers(
{
(DOUBLE_PRESS, ROTARY_KNOB): {
COMMAND: COMMAND_DOUBLE,
CLUSTER_ID: 6,
ENDPOINT_ID: 2,
},
(LONG_PRESS, ROTARY_KNOB): {
COMMAND: COMMAND_HOLD,
CLUSTER_ID: 6,
ENDPOINT_ID: 2,
},
(LONG_RELEASE, ROTARY_KNOB): {
COMMAND: COMMAND_RELEASE,
CLUSTER_ID: 6,
ENDPOINT_ID: 2,
},
}
)
)

remote_quirk = (
QuirkBuilder()
.replaces(
Expand Down Expand Up @@ -107,9 +254,17 @@
.add_to_registry()
)

(
remote_lite_quirk.clone()
.applies_to(CANDEO, "C-ZB-RD1Pv2-DIM")
.removes(Ota.cluster_id)
.add_to_registry()
)

(
remote_quirk.clone()
.applies_to(CANDEO, "C-ZB-RD1P-REM")
.applies_to(CANDEO, "C-ZB-RD1Pv2-REM")
.removes(Identify.cluster_id, endpoint_id=1)
.removes(Identify.cluster_id, endpoint_id=2)
.removes(Ota.cluster_id)
Expand All @@ -119,6 +274,7 @@
(
remote_quirk.clone()
.applies_to(CANDEO, "C-ZB-RD1P-DPM")
.applies_to(CANDEO, "C-ZB-RD1Pv2-DPM")
.removes(Ota.cluster_id)
.add_to_registry()
)
Loading