code
stringlengths 501
5.19M
| package
stringlengths 2
81
| path
stringlengths 9
304
| filename
stringlengths 4
145
|
---|---|---|---|
from zigpy.profiles import zha
from zigpy.quirks import CustomDevice
from zigpy.zcl.clusters.general import (
Alarms,
Basic,
BinaryInput,
OnOff,
Ota,
PowerConfiguration,
)
from zigpy.zcl.clusters.measurement import (
IlluminanceMeasurement,
OccupancySensing,
TemperatureMeasurement,
)
from zigpy.zcl.clusters.security import IasZone
from zhaquirks.const import (
DEVICE_TYPE,
ENDPOINTS,
INPUT_CLUSTERS,
MANUFACTURER,
MODEL,
OUTPUT_CLUSTERS,
PROFILE_ID,
SKIP_CONFIGURATION,
)
from zhaquirks.philio import PHILIO, MotionCluster
class Pst03a(CustomDevice):
"""Custom device representing PST03A 4in1 motion/opening/temperature/illuminance sensors."""
signature = {
MODEL: "PST03A-v2.2.5",
ENDPOINTS: {
1: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.IAS_ZONE,
INPUT_CLUSTERS: [
Basic.cluster_id,
PowerConfiguration.cluster_id,
Alarms.cluster_id,
OccupancySensing.cluster_id,
IasZone.cluster_id,
],
OUTPUT_CLUSTERS: [OnOff.cluster_id, Ota.cluster_id],
},
2: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.IAS_ZONE,
INPUT_CLUSTERS: [
Basic.cluster_id,
PowerConfiguration.cluster_id,
Alarms.cluster_id,
BinaryInput.cluster_id,
IasZone.cluster_id,
],
OUTPUT_CLUSTERS: [Ota.cluster_id],
},
},
}
replacement = {
SKIP_CONFIGURATION: True,
MANUFACTURER: PHILIO,
ENDPOINTS: {
1: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.IAS_ZONE,
INPUT_CLUSTERS: [
Basic.cluster_id,
Alarms.cluster_id,
MotionCluster,
TemperatureMeasurement.cluster_id,
IlluminanceMeasurement.cluster_id,
],
OUTPUT_CLUSTERS: [Ota.cluster_id],
},
2: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.IAS_ZONE,
INPUT_CLUSTERS: [
Basic.cluster_id,
Alarms.cluster_id,
IasZone.cluster_id,
],
OUTPUT_CLUSTERS: [Ota.cluster_id],
},
},
} | zha-quirks | /zha_quirks-0.0.103-py3-none-any.whl/zhaquirks/philio/pst03a.py | pst03a.py |
import logging
from zigpy.profiles import zha
from zigpy.quirks import CustomDevice
from zigpy.zcl.clusters.general import (
Basic,
Groups,
Identify,
OnOff,
PowerConfiguration,
Scenes,
)
from zhaquirks import PowerConfigurationCluster
from zhaquirks.const import (
COMMAND,
COMMAND_DOUBLE,
COMMAND_HOLD,
COMMAND_SINGLE,
DEVICE_TYPE,
DOUBLE_PRESS,
ENDPOINTS,
INPUT_CLUSTERS,
LONG_PRESS,
MODELS_INFO,
OUTPUT_CLUSTERS,
PROFILE_ID,
SHORT_PRESS,
)
from zhaquirks.konke import KONKE, KonkeOnOffCluster
KONKE_CLUSTER_ID = 0xFCC0
_LOGGER = logging.getLogger(__name__)
class KonkeButtonRemote1(CustomDevice):
"""Konke 1-button remote device."""
signature = {
# <SimpleDescriptor endpoint=1 profile=260 device_type=2
# device_version=0
# input_clusters=[0, 1, 3, 6, 64704]
# output_clusters=[3, 64704]>
MODELS_INFO: [(KONKE, "3AFE280100510001")],
ENDPOINTS: {
1: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.ON_OFF_OUTPUT,
INPUT_CLUSTERS: [
Basic.cluster_id,
PowerConfiguration.cluster_id,
Identify.cluster_id,
OnOff.cluster_id,
KONKE_CLUSTER_ID,
],
OUTPUT_CLUSTERS: [Identify.cluster_id, KONKE_CLUSTER_ID],
},
},
}
replacement = {
ENDPOINTS: {
1: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.REMOTE_CONTROL,
INPUT_CLUSTERS: [
Basic.cluster_id,
PowerConfigurationCluster,
Identify.cluster_id,
KonkeOnOffCluster,
KONKE_CLUSTER_ID,
],
OUTPUT_CLUSTERS: [
Identify.cluster_id,
KONKE_CLUSTER_ID,
],
},
},
}
device_automation_triggers = {
(DOUBLE_PRESS, DOUBLE_PRESS): {COMMAND: COMMAND_DOUBLE},
(SHORT_PRESS, SHORT_PRESS): {COMMAND: COMMAND_SINGLE},
(LONG_PRESS, LONG_PRESS): {COMMAND: COMMAND_HOLD},
}
class KonkeButtonRemote2(CustomDevice):
"""Konke 1-button remote device 2nd variant."""
signature = {
# <SimpleDescriptor endpoint=1 profile=260 device_type=2
# device_version=0
# input_clusters=[0, 1, 3, 4, 5, 6]
# output_clusters=[3]>
MODELS_INFO: [(KONKE, "3AFE170100510001")],
ENDPOINTS: {
1: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.ON_OFF_OUTPUT,
INPUT_CLUSTERS: [
Basic.cluster_id,
PowerConfiguration.cluster_id,
Identify.cluster_id,
Groups.cluster_id,
Scenes.cluster_id,
OnOff.cluster_id,
],
OUTPUT_CLUSTERS: [Identify.cluster_id],
},
},
}
replacement = {
ENDPOINTS: {
1: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.REMOTE_CONTROL,
INPUT_CLUSTERS: [
Basic.cluster_id,
PowerConfigurationCluster,
Identify.cluster_id,
Groups.cluster_id,
Scenes.cluster_id,
KonkeOnOffCluster,
],
OUTPUT_CLUSTERS: [
Identify.cluster_id,
],
},
},
}
device_automation_triggers = {
(DOUBLE_PRESS, DOUBLE_PRESS): {COMMAND: COMMAND_DOUBLE},
(SHORT_PRESS, SHORT_PRESS): {COMMAND: COMMAND_SINGLE},
(LONG_PRESS, LONG_PRESS): {COMMAND: COMMAND_HOLD},
} | zha-quirks | /zha_quirks-0.0.103-py3-none-any.whl/zhaquirks/konke/button.py | button.py |
from zigpy.profiles import zha
from zigpy.quirks import CustomDevice
from zigpy.zcl.clusters.general import Basic, Identify, PowerConfiguration
from zigpy.zcl.clusters.security import IasZone
from zhaquirks import Bus, PowerConfigurationCluster
from zhaquirks.const import (
DEVICE_TYPE,
ENDPOINTS,
INPUT_CLUSTERS,
MODELS_INFO,
OUTPUT_CLUSTERS,
PROFILE_ID,
)
from zhaquirks.konke import KONKE, MotionCluster, OccupancyCluster
KONKE_CLUSTER_ID = 0xFCC0
class KonkeMotion(CustomDevice):
"""Custom device representing konke motion sensors."""
def __init__(self, *args, **kwargs):
"""Init."""
self.occupancy_bus = Bus()
super().__init__(*args, **kwargs)
signature = {
# <SimpleDescriptor endpoint=1 profile=260 device_type=1026
# device_version=0
# input_clusters=[0, 1, 3, 1280, 64704]
# output_clusters=[3, 64704]>
MODELS_INFO: [
(KONKE, "3AFE28010402000D"),
(KONKE, "3AFE14010402000D"),
(KONKE, "3AFE27010402000D"),
],
ENDPOINTS: {
1: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.IAS_ZONE,
INPUT_CLUSTERS: [
Basic.cluster_id,
PowerConfiguration.cluster_id,
Identify.cluster_id,
IasZone.cluster_id,
KONKE_CLUSTER_ID,
],
OUTPUT_CLUSTERS: [Identify.cluster_id, KONKE_CLUSTER_ID],
}
},
}
replacement = {
ENDPOINTS: {
1: {
INPUT_CLUSTERS: [
Basic.cluster_id,
PowerConfigurationCluster,
Identify.cluster_id,
OccupancyCluster,
MotionCluster,
KONKE_CLUSTER_ID,
],
OUTPUT_CLUSTERS: [Identify.cluster_id, KONKE_CLUSTER_ID],
}
}
}
class KonkeMotionB(CustomDevice):
"""Custom device representing konke motion sensors."""
def __init__(self, *args, **kwargs):
"""Init."""
self.occupancy_bus = Bus()
super().__init__(*args, **kwargs)
signature = {
# <SimpleDescriptor endpoint=1 profile=260 device_type=1026
# device_version=0
# input_clusters=[0, 1, 3, 1280]
# output_clusters=[3]>
MODELS_INFO: [
(KONKE, "3AFE28010402000D"),
(KONKE, "3AFE14010402000D"),
(KONKE, "3AFE27010402000D"),
],
ENDPOINTS: {
1: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.IAS_ZONE,
INPUT_CLUSTERS: [
Basic.cluster_id,
PowerConfiguration.cluster_id,
Identify.cluster_id,
IasZone.cluster_id,
],
OUTPUT_CLUSTERS: [Identify.cluster_id],
}
},
}
replacement = {
ENDPOINTS: {
1: {
INPUT_CLUSTERS: [
Basic.cluster_id,
PowerConfigurationCluster,
Identify.cluster_id,
OccupancyCluster,
MotionCluster,
],
OUTPUT_CLUSTERS: [Identify.cluster_id],
}
}
} | zha-quirks | /zha_quirks-0.0.103-py3-none-any.whl/zhaquirks/konke/motion.py | motion.py |
from zigpy.profiles import zha
from zigpy.quirks import CustomDevice
from zigpy.zcl.clusters.general import Basic, Identify, PowerConfiguration
from zigpy.zcl.clusters.security import IasZone
from zhaquirks import PowerConfigurationCluster
from zhaquirks.const import (
DEVICE_TYPE,
ENDPOINTS,
INPUT_CLUSTERS,
MODELS_INFO,
OUTPUT_CLUSTERS,
PROFILE_ID,
)
from zhaquirks.konke import KONKE
KONKE_CLUSTER_ID = 0xFCC0
class KonkeMagnet(CustomDevice):
"""Custom device representing konke magnet sensors."""
signature = {
# <SimpleDescriptor endpoint=1 profile=260 device_type=1026
# device_version=0
# input_clusters=[0, 1, 3, 1280, 64704]
# output_clusters=[3, 64704]>
MODELS_INFO: [(KONKE, "3AFE270104020015"), (KONKE, "3AFE280104020015")],
ENDPOINTS: {
1: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.IAS_ZONE,
INPUT_CLUSTERS: [
Basic.cluster_id,
PowerConfiguration.cluster_id,
Identify.cluster_id,
IasZone.cluster_id,
KONKE_CLUSTER_ID,
],
OUTPUT_CLUSTERS: [Identify.cluster_id, KONKE_CLUSTER_ID],
}
},
}
replacement = {
ENDPOINTS: {
1: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.IAS_ZONE,
INPUT_CLUSTERS: [
Basic.cluster_id,
PowerConfigurationCluster,
Identify.cluster_id,
IasZone.cluster_id,
KONKE_CLUSTER_ID,
],
OUTPUT_CLUSTERS: [Identify.cluster_id, KONKE_CLUSTER_ID],
}
}
}
class KonkeMagnet2(CustomDevice):
"""Custom device representing konke magnet sensors without custom konke cluster."""
signature = {
# <SimpleDescriptor endpoint=1 profile=260 device_type=1026
# device_version=0
# input_clusters=[0, 1, 3, 1280]
# output_clusters=[3]>
MODELS_INFO: [(KONKE, "3AFE130104020015"), (KONKE, "3AFE140104020015")],
ENDPOINTS: {
1: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.IAS_ZONE,
INPUT_CLUSTERS: [
Basic.cluster_id,
PowerConfiguration.cluster_id,
Identify.cluster_id,
IasZone.cluster_id,
],
OUTPUT_CLUSTERS: [Identify.cluster_id],
}
},
}
replacement = {
ENDPOINTS: {
1: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.IAS_ZONE,
INPUT_CLUSTERS: [
Basic.cluster_id,
PowerConfigurationCluster,
Identify.cluster_id,
IasZone.cluster_id,
],
OUTPUT_CLUSTERS: [Identify.cluster_id],
}
}
} | zha-quirks | /zha_quirks-0.0.103-py3-none-any.whl/zhaquirks/konke/magnet.py | magnet.py |
from typing import Any, List, Optional, Union
import zigpy.types as t
from zigpy.zcl.clusters.general import OnOff
import zigpy.zcl.foundation
from zhaquirks import CustomCluster, LocalDataCluster, MotionWithReset, OccupancyOnEvent
from zhaquirks.const import (
COMMAND_DOUBLE,
COMMAND_HOLD,
COMMAND_ID,
COMMAND_SINGLE,
PRESS_TYPE,
ZHA_SEND_EVENT,
)
KONKE = "Konke"
class KonkeButtonEvent(t.enum8):
Single = 0x80
Double = 0x81
Hold = 0x82
PRESS_TYPES = {
KonkeButtonEvent.Single: COMMAND_SINGLE,
KonkeButtonEvent.Double: COMMAND_DOUBLE,
KonkeButtonEvent.Hold: COMMAND_HOLD,
}
class OccupancyCluster(LocalDataCluster, OccupancyOnEvent):
"""Occupancy cluster."""
reset_s: int = 600
class MotionCluster(MotionWithReset):
"""Motion cluster."""
reset_s: int = 60
send_occupancy_event: bool = True
class KonkeOnOffCluster(CustomCluster):
"""Konke OnOff cluster implementation."""
cluster_id = OnOff.cluster_id
ep_attribute = "konke_on_off"
attributes = OnOff.attributes.copy()
attributes[0x0000] = ("konke_button_event", KonkeButtonEvent)
server_commands = OnOff.server_commands.copy()
client_commands = OnOff.client_commands.copy()
def handle_cluster_general_request(
self,
header: zigpy.zcl.foundation.ZCLHeader,
args: List[Any],
*,
dst_addressing: Optional[
Union[t.Addressing.Group, t.Addressing.IEEE, t.Addressing.NWK]
] = None,
):
"""Handle the cluster command."""
self.info(
"Konke general request - handle_cluster_general_request: header: %s - args: [%s]",
header,
args,
)
if header.command_id != zigpy.zcl.foundation.GeneralCommand.Report_Attributes:
return
attr = args[0][0]
if attr.attrid != self.attributes_by_name["konke_button_event"].id:
return
value = attr.value.value
event_args = {
PRESS_TYPE: PRESS_TYPES[value],
COMMAND_ID: value.value, # to maintain backwards compatibility
}
self.listener_event(ZHA_SEND_EVENT, event_args[PRESS_TYPE], event_args) | zha-quirks | /zha_quirks-0.0.103-py3-none-any.whl/zhaquirks/konke/__init__.py | __init__.py |
import logging
from zigpy.profiles import zha
from zigpy.quirks import CustomDevice
from zigpy.zcl.clusters.general import Basic, Identify, Ota, PollControl
from zigpy.zcl.clusters.homeautomation import Diagnostic
from zigpy.zcl.clusters.measurement import TemperatureMeasurement
from zigpy.zcl.clusters.security import IasZone
from zhaquirks import PowerConfigurationCluster
from zhaquirks.const import (
DEVICE_TYPE,
ENDPOINTS,
INPUT_CLUSTERS,
MODELS_INFO,
OUTPUT_CLUSTERS,
PROFILE_ID,
)
OSRAM_DEVICE = 0x0810 # 2064 base 10
OSRAM_CLUSTER = 0xFD00 # 64768 base 10
_LOGGER = logging.getLogger(__name__)
class CustomPowerConfigurationCluster(PowerConfigurationCluster):
"""Custom PowerConfigurationCluster."""
cluster_id = PowerConfigurationCluster.cluster_id
MIN_VOLTS = 2.1
MAX_VOLTS = 3.0
class MCT340E(CustomDevice):
"""Visonic MCT340E device."""
signature = {
# <SimpleDescriptor endpoint=1 profile=260 device_type=1026
# device_version=0
# input_clusters=[0, 1, 3, 1026, 1280, 32, 2821]
# output_clusters=[25]>
MODELS_INFO: [("Visonic", "MCT-340 E")],
ENDPOINTS: {
1: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.IAS_ZONE,
INPUT_CLUSTERS: [
Basic.cluster_id,
CustomPowerConfigurationCluster.cluster_id,
Identify.cluster_id,
TemperatureMeasurement.cluster_id,
IasZone.cluster_id,
PollControl.cluster_id,
Diagnostic.cluster_id,
],
OUTPUT_CLUSTERS: [Ota.cluster_id],
}
},
}
replacement = {
ENDPOINTS: {
1: {
PROFILE_ID: zha.PROFILE_ID,
INPUT_CLUSTERS: [
Basic.cluster_id,
CustomPowerConfigurationCluster,
Identify.cluster_id,
TemperatureMeasurement.cluster_id,
IasZone.cluster_id,
PollControl.cluster_id,
Diagnostic.cluster_id,
],
OUTPUT_CLUSTERS: [Ota.cluster_id],
}
}
} | zha-quirks | /zha_quirks-0.0.103-py3-none-any.whl/zhaquirks/visonic/mct340e.py | mct340e.py |
from zigpy.profiles import zgp, zha
from zigpy.quirks import CustomCluster, CustomDevice
from zigpy.zcl.clusters.general import (
Basic,
GreenPowerProxy,
Groups,
Identify,
OnOff,
Ota,
Scenes,
Time,
)
from zigpy.zcl.clusters.homeautomation import Diagnostic, ElectricalMeasurement
from zigpy.zcl.clusters.lightlink import LightLink
from zigpy.zcl.clusters.smartenergy import Metering
from zhaquirks.const import (
DEVICE_TYPE,
ENDPOINTS,
INPUT_CLUSTERS,
MODELS_INFO,
OUTPUT_CLUSTERS,
PROFILE_ID,
)
MANUFACTURER = "innr"
MODEL = "SP 234"
class ElectricalMeasurementCluster(CustomCluster, ElectricalMeasurement):
"""Fix divisor."""
cluster_id = ElectricalMeasurement.cluster_id
AC_POWER_DIVISOR = 0x0605
_CONSTANT_ATTRIBUTES = {AC_POWER_DIVISOR: 1}
class SP234(CustomDevice):
"""Innr SP 234 smart plug."""
signature = {
ENDPOINTS: {
1: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.ON_OFF_PLUG_IN_UNIT,
INPUT_CLUSTERS: [
Basic.cluster_id,
Identify.cluster_id,
Groups.cluster_id,
Scenes.cluster_id,
OnOff.cluster_id,
Metering.cluster_id,
ElectricalMeasurement.cluster_id,
Diagnostic.cluster_id,
LightLink.cluster_id,
0xFC57,
0xFC82,
],
OUTPUT_CLUSTERS: [
Identify.cluster_id,
Time.cluster_id,
Ota.cluster_id,
],
},
242: {
PROFILE_ID: zgp.PROFILE_ID,
DEVICE_TYPE: zgp.DeviceType.PROXY_BASIC,
INPUT_CLUSTERS: [],
OUTPUT_CLUSTERS: [GreenPowerProxy.cluster_id],
},
},
MODELS_INFO: [(MANUFACTURER, MODEL)],
}
replacement = {
ENDPOINTS: {
1: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.ON_OFF_PLUG_IN_UNIT,
INPUT_CLUSTERS: [
Basic.cluster_id,
Identify.cluster_id,
Groups.cluster_id,
Scenes.cluster_id,
OnOff.cluster_id,
Metering.cluster_id,
ElectricalMeasurementCluster,
Diagnostic.cluster_id,
LightLink.cluster_id,
0xFC57,
0xFC82,
],
OUTPUT_CLUSTERS: [
Identify.cluster_id,
Time.cluster_id,
Ota.cluster_id,
],
},
242: {
PROFILE_ID: zgp.PROFILE_ID,
DEVICE_TYPE: zgp.DeviceType.PROXY_BASIC,
INPUT_CLUSTERS: [],
OUTPUT_CLUSTERS: [GreenPowerProxy.cluster_id],
},
},
} | zha-quirks | /zha_quirks-0.0.103-py3-none-any.whl/zhaquirks/innr/innr_sp234_plug.py | innr_sp234_plug.py |
from zigpy.profiles import zll
from zigpy.quirks import CustomCluster, CustomDevice
from zigpy.zcl.clusters.general import (
Basic,
Groups,
Identify,
LevelControl,
OnOff,
Ota,
Scenes,
Time,
)
from zigpy.zcl.clusters.homeautomation import ElectricalMeasurement
from zigpy.zcl.clusters.lightlink import LightLink
from zigpy.zcl.clusters.smartenergy import Metering
from zhaquirks.const import (
DEVICE_TYPE,
ENDPOINTS,
INPUT_CLUSTERS,
MODELS_INFO,
OUTPUT_CLUSTERS,
PROFILE_ID,
)
MANUFACTURER = "innr"
MODEL = "SP 120"
class MeteringCluster(CustomCluster, Metering):
"""Fix multiplier and divisor."""
cluster_id = Metering.cluster_id
MULTIPLIER = 0x0301
DIVISOR = 0x0302
_CONSTANT_ATTRIBUTES = {MULTIPLIER: 1, DIVISOR: 100}
class ElectricalMeasurementCluster(CustomCluster, ElectricalMeasurement):
"""Fix multiplier and divisor."""
cluster_id = ElectricalMeasurement.cluster_id
MULTIPLIER = 0x0602
DIVISOR = 0x0603
_CONSTANT_ATTRIBUTES = {MULTIPLIER: 1, DIVISOR: 1000}
class SP120(CustomDevice):
"""Innr SP 120 smart plug."""
signature = {
ENDPOINTS: {
1: {
PROFILE_ID: zll.PROFILE_ID,
DEVICE_TYPE: zll.DeviceType.ON_OFF_PLUGIN_UNIT,
INPUT_CLUSTERS: [
Basic.cluster_id,
ElectricalMeasurement.cluster_id,
Groups.cluster_id,
Identify.cluster_id,
LevelControl.cluster_id,
Metering.cluster_id,
OnOff.cluster_id,
Scenes.cluster_id,
Time.cluster_id,
],
OUTPUT_CLUSTERS: [
Identify.cluster_id,
Ota.cluster_id,
Time.cluster_id,
],
},
2: {
PROFILE_ID: zll.PROFILE_ID,
DEVICE_TYPE: 0x1000,
INPUT_CLUSTERS: [
LightLink.cluster_id,
],
OUTPUT_CLUSTERS: [],
},
},
MODELS_INFO: [(MANUFACTURER, MODEL)],
}
replacement = {
ENDPOINTS: {
1: {
PROFILE_ID: zll.PROFILE_ID,
DEVICE_TYPE: zll.DeviceType.ON_OFF_PLUGIN_UNIT,
INPUT_CLUSTERS: [
Basic.cluster_id,
ElectricalMeasurementCluster,
Groups.cluster_id,
Identify.cluster_id,
LevelControl.cluster_id,
MeteringCluster,
OnOff.cluster_id,
Scenes.cluster_id,
Time.cluster_id,
],
OUTPUT_CLUSTERS: [
Identify.cluster_id,
Ota.cluster_id,
Time.cluster_id,
],
},
2: {
PROFILE_ID: zll.PROFILE_ID,
DEVICE_TYPE: 0x1000,
INPUT_CLUSTERS: [
LightLink.cluster_id,
],
OUTPUT_CLUSTERS: [],
},
},
} | zha-quirks | /zha_quirks-0.0.103-py3-none-any.whl/zhaquirks/innr/innr_sp120_plug.py | innr_sp120_plug.py |
from zigpy.profiles import zgp, zha
from zigpy.profiles.zha import DeviceType
from zigpy.quirks import CustomDevice
from zigpy.zcl.clusters.general import (
Basic,
GreenPowerProxy,
Groups,
Identify,
LevelControl,
OnOff,
Ota,
Scenes,
)
from zigpy.zcl.clusters.lighting import Color
from zigpy.zcl.clusters.lightlink import LightLink
from zhaquirks.const import (
DEVICE_TYPE,
ENDPOINTS,
INPUT_CLUSTERS,
MODELS_INFO,
OUTPUT_CLUSTERS,
PROFILE_ID,
)
class RS228T(CustomDevice):
"""Innr RS 228 T device."""
signature = {
# <SimpleDescriptor endpoint=1 profile=260 device_type=268
# device_version=1
# input_clusters=[0, 3, 4, 5, 6, 8, 768, 4096]
# output_clusters=[25]>
MODELS_INFO: [("innr", "RS 228 T")],
ENDPOINTS: {
1: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: 268,
INPUT_CLUSTERS: [
Basic.cluster_id,
Identify.cluster_id,
Groups.cluster_id,
Scenes.cluster_id,
OnOff.cluster_id,
LevelControl.cluster_id,
Color.cluster_id,
LightLink.cluster_id,
],
OUTPUT_CLUSTERS: [Ota.cluster_id],
},
# <SimpleDescriptor endpoint=242 profile=41440 device_type=97
# device_version=0
# input_clusters=[]
# output_clusters=[33]>
242: {
PROFILE_ID: zgp.PROFILE_ID,
DEVICE_TYPE: zgp.DeviceType.PROXY_BASIC,
INPUT_CLUSTERS: [],
OUTPUT_CLUSTERS: [GreenPowerProxy.cluster_id],
},
},
}
replacement = {
ENDPOINTS: {
1: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: DeviceType.COLOR_DIMMABLE_LIGHT,
INPUT_CLUSTERS: [
Basic.cluster_id,
Identify.cluster_id,
Groups.cluster_id,
Scenes.cluster_id,
OnOff.cluster_id,
LevelControl.cluster_id,
Color.cluster_id,
LightLink.cluster_id,
],
OUTPUT_CLUSTERS: [Ota.cluster_id],
},
242: {
PROFILE_ID: zgp.PROFILE_ID,
DEVICE_TYPE: zgp.DeviceType.PROXY_BASIC,
INPUT_CLUSTERS: [],
OUTPUT_CLUSTERS: [GreenPowerProxy.cluster_id],
},
}
} | zha-quirks | /zha_quirks-0.0.103-py3-none-any.whl/zhaquirks/innr/rs228t.py | rs228t.py |
from zigpy.profiles import zha
from zigpy.quirks import CustomDevice
from zigpy.zcl.clusters.general import (
Alarms,
Basic,
Identify,
LevelControl,
OnOff,
Ota,
PowerConfiguration,
)
from zhaquirks.const import (
BUTTON_1,
BUTTON_2,
CLUSTER_ID,
COMMAND,
COMMAND_OFF,
COMMAND_ON,
DEVICE_TYPE,
ENDPOINT_ID,
ENDPOINTS,
INPUT_CLUSTERS,
MODELS_INFO,
OUTPUT_CLUSTERS,
PROFILE_ID,
SHORT_PRESS,
)
MANUFACTURER = " Echostar"
MODEL = " Bell"
class Bell(CustomDevice):
"""Echostar Bell device."""
signature = {
# <SimpleDescriptor endpoint=18 profile=260 device_type=260
# device_version=0
# input_clusters=[0, 3, 9, 1]
# output_clusters=[3, 6, 8, 25]>
MODELS_INFO: [(MANUFACTURER, MODEL)],
ENDPOINTS: {
18: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.DIMMER_SWITCH,
INPUT_CLUSTERS: [
Basic.cluster_id,
Identify.cluster_id,
Alarms.cluster_id,
PowerConfiguration.cluster_id,
],
OUTPUT_CLUSTERS: [
Identify.cluster_id,
OnOff.cluster_id,
LevelControl.cluster_id,
Ota.cluster_id,
],
}
},
}
replacement = {
ENDPOINTS: {
18: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.ON_OFF_SWITCH,
INPUT_CLUSTERS: [
Basic.cluster_id,
Identify.cluster_id,
Alarms.cluster_id,
PowerConfiguration.cluster_id,
],
OUTPUT_CLUSTERS: [
Identify.cluster_id,
OnOff.cluster_id,
LevelControl.cluster_id,
Ota.cluster_id,
],
}
}
}
device_automation_triggers = {
(SHORT_PRESS, BUTTON_1): {COMMAND: COMMAND_ON, CLUSTER_ID: 6, ENDPOINT_ID: 18},
(SHORT_PRESS, BUTTON_2): {COMMAND: COMMAND_OFF, CLUSTER_ID: 6, ENDPOINT_ID: 18},
} | zha-quirks | /zha_quirks-0.0.103-py3-none-any.whl/zhaquirks/echostar/bell.py | bell.py |
from zigpy.profiles import zgp, zll
from zigpy.quirks import CustomCluster, CustomDevice
from zigpy.zcl.clusters.general import (
Basic,
GreenPowerProxy,
Groups,
Identify,
LevelControl,
OnOff,
Ota,
Scenes,
)
from zigpy.zcl.clusters.homeautomation import Diagnostic
from zigpy.zcl.clusters.lighting import Color
from zigpy.zcl.clusters.lightlink import LightLink
from zhaquirks.const import (
DEVICE_TYPE,
ENDPOINTS,
INPUT_CLUSTERS,
MODELS_INFO,
OUTPUT_CLUSTERS,
PROFILE_ID,
)
from zhaquirks.iluminize import ILUMINIZE
class IluminizeCCTColorCluster(CustomCluster, Color):
"""iluminize CCT Lighting custom cluster."""
# Remove RGB color wheel for CCT Lighting: only expose color temperature
_CONSTANT_ATTRIBUTES = {0x400A: 16}
class CCTLight(CustomDevice):
"""iluminize ZigBee LightLink CCT Lighting device."""
signature = {
MODELS_INFO: [(ILUMINIZE, "CCT Lighting")],
ENDPOINTS: {
1: {
# <SimpleDescriptor endpoint=1 profile=49246 device_type=544
# device_version=1
# input_clusters=[0, 3, 4, 5, 6, 8, 768, 2821, 4096]
# output_clusters=[25]
PROFILE_ID: zll.PROFILE_ID,
DEVICE_TYPE: zll.DeviceType.COLOR_TEMPERATURE_LIGHT,
INPUT_CLUSTERS: [
Basic.cluster_id,
Identify.cluster_id,
Groups.cluster_id,
Scenes.cluster_id,
OnOff.cluster_id,
LevelControl.cluster_id,
Color.cluster_id,
Diagnostic.cluster_id,
LightLink.cluster_id,
],
OUTPUT_CLUSTERS: [Ota.cluster_id],
},
242: {
# <SimpleDescriptor endpoint=242 profile=41440 device_type=102
# device_version=0
# input_clusters=[33]
# output_clusters=[33]
PROFILE_ID: zgp.PROFILE_ID,
DEVICE_TYPE: zgp.DeviceType.COMBO_BASIC,
INPUT_CLUSTERS: [GreenPowerProxy.cluster_id],
OUTPUT_CLUSTERS: [GreenPowerProxy.cluster_id],
},
},
}
replacement = {
ENDPOINTS: {
1: {
PROFILE_ID: zll.PROFILE_ID,
DEVICE_TYPE: zll.DeviceType.COLOR_TEMPERATURE_LIGHT,
INPUT_CLUSTERS: [
Basic.cluster_id,
Identify.cluster_id,
Groups.cluster_id,
Scenes.cluster_id,
OnOff.cluster_id,
LevelControl.cluster_id,
IluminizeCCTColorCluster,
Diagnostic.cluster_id,
LightLink.cluster_id,
],
OUTPUT_CLUSTERS: [Ota.cluster_id],
},
242: {
PROFILE_ID: zgp.PROFILE_ID,
DEVICE_TYPE: zgp.DeviceType.COMBO_BASIC,
INPUT_CLUSTERS: [GreenPowerProxy.cluster_id],
OUTPUT_CLUSTERS: [GreenPowerProxy.cluster_id],
},
}
} | zha-quirks | /zha_quirks-0.0.103-py3-none-any.whl/zhaquirks/iluminize/cct.py | cct.py |
from zigpy.profiles import zgp, zha
from zigpy.quirks import CustomCluster, CustomDevice
from zigpy.zcl.clusters.general import (
Basic,
GreenPowerProxy,
Groups,
Identify,
LevelControl,
OnOff,
Ota,
Scenes,
)
from zigpy.zcl.clusters.homeautomation import Diagnostic
from zigpy.zcl.clusters.lighting import Color
from zigpy.zcl.clusters.lightlink import LightLink
from zhaquirks.const import (
DEVICE_TYPE,
ENDPOINTS,
INPUT_CLUSTERS,
MODELS_INFO,
OUTPUT_CLUSTERS,
PROFILE_ID,
)
from zhaquirks.iluminize import ILUMINIZE
class IluminizeDIMColorCluster(CustomCluster, Color):
"""iluminize DIM Lighting custom cluster."""
# Remove RGB color wheel for DIM Lighting
_CONSTANT_ATTRIBUTES = {0x400A: 0}
class DIMLight(CustomDevice):
"""iluminize ZigBee LightLink DIM Lighting device."""
signature = {
MODELS_INFO: [(ILUMINIZE, "DIM Lighting")],
ENDPOINTS: {
1: {
# <SimpleDescriptor endpoint=1 profile=260 device_type=257
# device_version=1
# input_clusters=[0, 3, 4, 5, 6, 8, 768, 2821, 4096]
# output_clusters=[25]
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.DIMMABLE_LIGHT,
INPUT_CLUSTERS: [
Basic.cluster_id,
Identify.cluster_id,
Groups.cluster_id,
Scenes.cluster_id,
OnOff.cluster_id,
LevelControl.cluster_id,
Color.cluster_id,
Diagnostic.cluster_id,
LightLink.cluster_id,
],
OUTPUT_CLUSTERS: [Ota.cluster_id],
},
242: {
# <SimpleDescriptor endpoint=242 profile=41440 device_type=102
# device_version=0
# input_clusters=[33]
# output_clusters=[33]
PROFILE_ID: zgp.PROFILE_ID,
DEVICE_TYPE: zgp.DeviceType.COMBO_BASIC,
INPUT_CLUSTERS: [GreenPowerProxy.cluster_id],
OUTPUT_CLUSTERS: [GreenPowerProxy.cluster_id],
},
},
}
replacement = {
ENDPOINTS: {
1: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.DIMMABLE_LIGHT,
INPUT_CLUSTERS: [
Basic.cluster_id,
Identify.cluster_id,
Groups.cluster_id,
Scenes.cluster_id,
OnOff.cluster_id,
LevelControl.cluster_id,
IluminizeDIMColorCluster,
Diagnostic.cluster_id,
LightLink.cluster_id,
],
OUTPUT_CLUSTERS: [Ota.cluster_id],
},
242: {
PROFILE_ID: zgp.PROFILE_ID,
DEVICE_TYPE: zgp.DeviceType.COMBO_BASIC,
INPUT_CLUSTERS: [GreenPowerProxy.cluster_id],
OUTPUT_CLUSTERS: [GreenPowerProxy.cluster_id],
},
}
} | zha-quirks | /zha_quirks-0.0.103-py3-none-any.whl/zhaquirks/iluminize/dim.py | dim.py |
from zigpy.profiles import zha
from zigpy.quirks import CustomDevice
from zigpy.zcl.clusters.general import Basic, Identify, Ota, PowerConfiguration
from zigpy.zcl.clusters.measurement import RelativeHumidity, TemperatureMeasurement
from zhaquirks import PowerConfigurationCluster
from zhaquirks.const import (
DEVICE_TYPE,
ENDPOINTS,
INPUT_CLUSTERS,
MODELS_INFO,
OUTPUT_CLUSTERS,
PROFILE_ID,
)
from zhaquirks.plaid import PLAID_SYSTEMS
class PowerConfigurationClusterMains(PowerConfigurationCluster):
"""Common use power configuration cluster."""
MAINS_VOLTAGE_ATTR = 0x0000
ATTR_ID_BATT_SIZE = 0x0031
ATTR_ID_BATT_QTY = 0x0033
_CONSTANT_ATTRIBUTES = {ATTR_ID_BATT_SIZE: 0x08, ATTR_ID_BATT_QTY: 1}
def _update_attribute(self, attrid, value):
super()._update_attribute(attrid, value)
if attrid == self.MAINS_VOLTAGE_ATTR:
super()._update_attribute(self.BATTERY_VOLTAGE_ATTR, round(value / 100))
def _remap(self, attr):
"""Replace battery voltage attribute name/id with mains_voltage."""
if attr in (self.BATTERY_VOLTAGE_ATTR, "battery_voltage"):
return self.MAINS_VOLTAGE_ATTR
return attr
def read_attributes(self, attributes, *args, **kwargs): # pylint: disable=W0221
"""Replace battery voltage with mains voltage."""
return super().read_attributes(
[self._remap(attr) for attr in attributes], *args, **kwargs
)
def configure_reporting(self, attribute, *args, **kwargs): # pylint: disable=W0221
"""Replace battery voltage with mains voltage."""
return super().configure_reporting(self._remap(attribute), *args, **kwargs)
class SoilMoisture(CustomDevice):
"""Custom device representing plaid systems soil sensors."""
signature = {
# <SimpleDescriptor endpoint=1 profile=260 device_type=1029
# device_version=0
# input_clusters=[0, 1, 3, 1026, 1029]
# output_clusters=[3, 25]>
MODELS_INFO: [(PLAID_SYSTEMS, "PS-SPRZMS-SLP3")],
ENDPOINTS: {
1: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: 1029,
INPUT_CLUSTERS: [
Basic.cluster_id,
PowerConfiguration.cluster_id,
Identify.cluster_id,
TemperatureMeasurement.cluster_id,
RelativeHumidity.cluster_id,
],
OUTPUT_CLUSTERS: [Identify.cluster_id, Ota.cluster_id],
}
},
}
replacement = {
ENDPOINTS: {
1: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: 1029,
INPUT_CLUSTERS: [
Basic.cluster_id,
PowerConfigurationClusterMains,
Identify.cluster_id,
TemperatureMeasurement.cluster_id,
RelativeHumidity.cluster_id,
],
OUTPUT_CLUSTERS: [Identify.cluster_id, Ota.cluster_id],
}
}
} | zha-quirks | /zha_quirks-0.0.103-py3-none-any.whl/zhaquirks/plaid/soil.py | soil.py |
from zigpy.profiles import zgp, zha
from zigpy.quirks import CustomDevice
from zigpy.zcl.clusters.general import (
Basic,
GreenPowerProxy,
Identify,
LevelControl,
OnOff,
Ota,
)
from zigpy.zcl.clusters.lighting import Color
from zhaquirks import EventableCluster, PowerConfigurationCluster
from zhaquirks.const import (
ARGS,
CLUSTER_ID,
COMMAND,
COMMAND_STEP,
COMMAND_STEP_COLOR_TEMP,
DEVICE_TYPE,
DIM_DOWN,
DIM_UP,
ENDPOINT_ID,
ENDPOINTS,
INPUT_CLUSTERS,
LEFT,
MODELS_INFO,
OUTPUT_CLUSTERS,
PARAMS,
PROFILE_ID,
RIGHT,
SHORT_PRESS,
)
COLOR_UP = "color_up"
COLOR_DOWN = "color_down"
CURRENT_LEVEL = "current_level"
class AuroraDimmerBatteryPowered(CustomDevice):
"""Aurora dimmer switch, battery powered."""
class WallSwitchOnOffCluster(EventableCluster, OnOff):
"""WallSwitchOnOffCluster: fire events corresponding to press type."""
# prevent creation of junk entities
ep_attribute = "not_on_off"
# as the device is battery powered, whether or not it thinks it is
# on or off is irrelevant
def _update_attribute(self, attrid, value):
return
class WallSwitchLevelControlCluster(EventableCluster, LevelControl):
"""WallSwitchLevelControlCluster: fire events corresponding to level changes."""
# the value reported by the device is always 254, so we may as well
# throw away this report
def _update_attribute(self, attrid, value):
if attrid == CURRENT_LEVEL:
return
else:
super()._update_attribute(attrid, value)
class WallSwitchColorCluster(EventableCluster, Color):
"""WallSwitchColorCluster: fire events corresponding to color changes."""
signature = {
# <SimpleDescriptor endpoint=1 profile=260 device_type=261
# device_version=0 input_clusters=[0, 1, 3, 6, 8, 768]
# output_clusters=[3, 6, 8, 25, 768]>
MODELS_INFO: [("Aurora", "2GBatteryDimmer50AU")],
ENDPOINTS: {
1: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.COLOR_DIMMER_SWITCH,
INPUT_CLUSTERS: [
Basic.cluster_id,
PowerConfigurationCluster.cluster_id,
Identify.cluster_id,
OnOff.cluster_id,
LevelControl.cluster_id,
Color.cluster_id,
],
OUTPUT_CLUSTERS: [
Identify.cluster_id,
OnOff.cluster_id,
LevelControl.cluster_id,
Ota.cluster_id,
Color.cluster_id,
],
},
# <SimpleDescriptor endpoint=2 profile=260 device_type=261
# device_version=0 input_clusters=[0, 3, 6, 8, 768]
# output_clusters=[3, 6, 8, 768]>
2: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.COLOR_DIMMER_SWITCH,
INPUT_CLUSTERS: [
Basic.cluster_id,
Identify.cluster_id,
OnOff.cluster_id,
LevelControl.cluster_id,
Color.cluster_id,
],
OUTPUT_CLUSTERS: [
Identify.cluster_id,
OnOff.cluster_id,
LevelControl.cluster_id,
Color.cluster_id,
],
},
# <SimpleDescriptor endpoint=242 profile=41440 device_type=97
# device_version=0 input_clusters=[] output_clusters=[33])
242: {
# <SimpleDescriptor endpoint=242 profile=41440 device_type=97
# device_version=0
# input_clusters=[]
# output_clusters=[33]
PROFILE_ID: zgp.PROFILE_ID,
DEVICE_TYPE: zgp.DeviceType.PROXY_BASIC,
INPUT_CLUSTERS: [],
OUTPUT_CLUSTERS: [GreenPowerProxy.cluster_id],
},
},
}
replacement = {
ENDPOINTS: {
1: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.COLOR_DIMMER_SWITCH,
INPUT_CLUSTERS: [
Basic.cluster_id,
PowerConfigurationCluster,
Identify.cluster_id,
WallSwitchOnOffCluster,
WallSwitchLevelControlCluster,
WallSwitchColorCluster,
],
OUTPUT_CLUSTERS: [
Identify.cluster_id,
OnOff.cluster_id,
LevelControl.cluster_id,
Ota.cluster_id,
Color.cluster_id,
],
},
2: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.COLOR_DIMMER_SWITCH,
INPUT_CLUSTERS: [
Basic.cluster_id,
Identify.cluster_id,
WallSwitchOnOffCluster,
WallSwitchLevelControlCluster,
WallSwitchColorCluster,
],
OUTPUT_CLUSTERS: [
Identify.cluster_id,
OnOff.cluster_id,
LevelControl.cluster_id,
Color.cluster_id,
],
},
242: {
PROFILE_ID: zgp.PROFILE_ID,
DEVICE_TYPE: zgp.DeviceType.PROXY_BASIC,
INPUT_CLUSTERS: [],
OUTPUT_CLUSTERS: [GreenPowerProxy.cluster_id],
},
}
}
device_automation_triggers = {
(DIM_UP, RIGHT): {
COMMAND: COMMAND_STEP,
CLUSTER_ID: 8,
ENDPOINT_ID: 1,
PARAMS: {"step_mode": 0},
},
(DIM_DOWN, RIGHT): {
COMMAND: COMMAND_STEP,
CLUSTER_ID: 8,
ENDPOINT_ID: 1,
PARAMS: {"step_mode": 1},
},
(COLOR_UP, RIGHT): {
COMMAND: COMMAND_STEP_COLOR_TEMP,
CLUSTER_ID: 768,
ENDPOINT_ID: 1,
PARAMS: {"step_mode": 3},
},
(COLOR_DOWN, RIGHT): {
COMMAND: COMMAND_STEP_COLOR_TEMP,
CLUSTER_ID: 768,
ENDPOINT_ID: 1,
PARAMS: {"step_mode": 1},
},
(DIM_UP, LEFT): {
COMMAND: COMMAND_STEP,
CLUSTER_ID: 8,
ENDPOINT_ID: 2,
PARAMS: {"step_mode": 0},
},
(DIM_DOWN, LEFT): {
COMMAND: COMMAND_STEP,
CLUSTER_ID: 8,
ENDPOINT_ID: 2,
PARAMS: {"step_mode": 1},
},
(COLOR_UP, LEFT): {
COMMAND: COMMAND_STEP_COLOR_TEMP,
CLUSTER_ID: 768,
ENDPOINT_ID: 1,
PARAMS: {"step_mode": 3},
},
(COLOR_DOWN, LEFT): {
COMMAND: COMMAND_STEP_COLOR_TEMP,
CLUSTER_ID: 768,
ENDPOINT_ID: 1,
PARAMS: {"step_mode": 1},
},
(SHORT_PRESS, RIGHT): {
CLUSTER_ID: 6,
ENDPOINT_ID: 1,
ARGS: [],
},
(SHORT_PRESS, LEFT): {
CLUSTER_ID: 6,
ENDPOINT_ID: 2,
ARGS: [],
},
} | zha-quirks | /zha_quirks-0.0.103-py3-none-any.whl/zhaquirks/aurora/aurora_dimmer.py | aurora_dimmer.py |
import zigpy.profiles.zha as zha_p
from zigpy.quirks import CustomDevice
from zigpy.zcl.clusters import general, homeautomation, hvac
from zhaquirks.const import (
DEVICE_TYPE,
ENDPOINTS,
INPUT_CLUSTERS,
MODELS_INFO,
OUTPUT_CLUSTERS,
PROFILE_ID,
)
from zhaquirks.zen import ZEN, ZenPowerConfiguration
class ZenThermostat(CustomDevice):
"""Zen Within Thermostat custom device."""
signature = {
# Node Descriptor: <Optional byte1=2 byte2=64 mac_capability_flags=128
# manufacturer_code=4440 maximum_buffer_size=82
# maximum_incoming_transfer_size=128 server_mask=0
# maximum_outgoing_transfer_size=128 descriptor_capability_field=0>
# <SimpleDescriptor endpoint=1 profile=260 device_type=769 device_version=0
# input_clusters=[0, 1, 3, 4, 5, 32, 513, 514, 516, 2821]
# output_clusters=[10, 25]>
MODELS_INFO: [(ZEN, "Zen-01")],
ENDPOINTS: {
1: {
PROFILE_ID: zha_p.PROFILE_ID,
DEVICE_TYPE: zha_p.DeviceType.THERMOSTAT,
INPUT_CLUSTERS: [
general.Basic.cluster_id,
general.PowerConfiguration.cluster_id,
general.Identify.cluster_id,
general.Groups.cluster_id,
general.Scenes.cluster_id,
general.PollControl.cluster_id,
hvac.Thermostat.cluster_id,
hvac.Fan.cluster_id,
hvac.UserInterface.cluster_id,
homeautomation.Diagnostic.cluster_id,
],
OUTPUT_CLUSTERS: [general.Time.cluster_id, general.Ota.cluster_id],
}
},
}
replacement = {
ENDPOINTS: {
1: {
INPUT_CLUSTERS: [
general.Basic.cluster_id,
ZenPowerConfiguration,
general.Identify.cluster_id,
general.Groups.cluster_id,
general.Scenes.cluster_id,
general.PollControl.cluster_id,
hvac.Thermostat.cluster_id,
hvac.Fan.cluster_id,
hvac.UserInterface.cluster_id,
homeautomation.Diagnostic.cluster_id,
],
OUTPUT_CLUSTERS: [general.Time.cluster_id, general.Ota.cluster_id],
}
}
} | zha-quirks | /zha_quirks-0.0.103-py3-none-any.whl/zhaquirks/zen/thermostat.py | thermostat.py |
import logging
from zigpy.profiles import zha
from zigpy.quirks import CustomCluster, CustomDevice
from zigpy.zcl import foundation
from zigpy.zcl.clusters.general import (
Basic,
Groups,
Identify,
LevelControl,
OnOff,
Ota,
Scenes,
)
from zigpy.zcl.clusters.lighting import Color
from zigpy.zcl.clusters.lightlink import LightLink
from zhaquirks import Bus, LocalDataCluster
from zhaquirks.const import (
DEVICE_TYPE,
ENDPOINTS,
INPUT_CLUSTERS,
MODELS_INFO,
OUTPUT_CLUSTERS,
PROFILE_ID,
)
TINT_SCENE_ATTR = 0x4005
_LOGGER = logging.getLogger(__name__)
class TintRemoteScenesCluster(LocalDataCluster, Scenes):
"""Tint remote cluster."""
cluster_id = Scenes.cluster_id
def __init__(self, *args, **kwargs):
"""Init."""
super().__init__(*args, **kwargs)
self.endpoint.device.scene_bus.add_listener(self)
def change_scene(self, value):
"""Change scene attribute to new value."""
self._update_attribute(self.attributes_by_name["current_scene"].id, value)
class TintRemoteBasicCluster(CustomCluster, Basic):
"""Tint remote cluster."""
cluster_id = Basic.cluster_id
def __init__(self, *args, **kwargs):
"""Init."""
super().__init__(*args, **kwargs)
def handle_cluster_general_request(self, hdr, args, *, dst_addressing=None):
"""Send write_attributes value to TintRemoteSceneCluster."""
if hdr.command_id != foundation.GeneralCommand.Write_Attributes:
return
attr = args[0][0]
if attr.attrid != TINT_SCENE_ATTR:
return
value = attr.value.value
self.endpoint.device.scene_bus.listener_event("change_scene", value)
class TintRemote(CustomDevice):
"""Tint remote quirk."""
def __init__(self, *args, **kwargs):
"""Init."""
self.scene_bus = Bus()
super().__init__(*args, **kwargs)
signature = {
# endpoint=1 profile=260 device_type=2048 device_version=1 input_clusters=[0, 3, 4096]
# output_clusters=[0, 3, 4, 5, 8, 25, 768, 4096]
MODELS_INFO: [("MLI", "ZBT-Remote-ALL-RGBW")],
ENDPOINTS: {
1: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.COLOR_CONTROLLER,
INPUT_CLUSTERS: [
Basic.cluster_id, # 0
Identify.cluster_id, # 3
LightLink.cluster_id, # 4096
],
OUTPUT_CLUSTERS: [
Basic.cluster_id, # 0
Identify.cluster_id, # 3
Groups.cluster_id, # 4
OnOff.cluster_id, # 6
LevelControl.cluster_id, # 8
Ota.cluster_id, # 25
Color.cluster_id, # 768
LightLink.cluster_id, # 4096
],
},
},
}
replacement = {
ENDPOINTS: {
1: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.COLOR_CONTROLLER,
INPUT_CLUSTERS: [
TintRemoteBasicCluster, # 0
Identify.cluster_id, # 3
LightLink.cluster_id, # 4096
],
OUTPUT_CLUSTERS: [
Basic.cluster_id, # 0
Identify.cluster_id, # 3
Groups.cluster_id, # 4
TintRemoteScenesCluster, # 5
OnOff.cluster_id, # 6
LevelControl.cluster_id, # 8
Ota.cluster_id, # 25
Color.cluster_id, # 768
LightLink.cluster_id, # 4096
],
},
},
} | zha-quirks | /zha_quirks-0.0.103-py3-none-any.whl/zhaquirks/mli/tint.py | tint.py |
from zigpy.profiles import zgp, zha
from zigpy.quirks import CustomCluster, CustomDevice
from zigpy.zcl.clusters.general import (
Basic,
GreenPowerProxy,
Groups,
Identify,
LevelControl,
OnOff,
Ota,
Scenes,
)
from zigpy.zcl.clusters.lighting import Color
from zigpy.zcl.clusters.lightlink import LightLink
from zhaquirks.const import (
DEVICE_TYPE,
ENDPOINTS,
INPUT_CLUSTERS,
MODELS_INFO,
OUTPUT_CLUSTERS,
PROFILE_ID,
)
class TintManufacturerSpecificCluster(CustomCluster):
"""Tint manufacturer specific cluster."""
cluster_id = 0x100F # not inside the manufacturer specific cluster range
class TintRGBCCTColorCluster(CustomCluster, Color):
"""Tint RGB+CCT Lighting custom cluster."""
# Set correct capabilities to ct, xy, hs
# Tint bulbs do not correctly report this attribute
_CONSTANT_ATTRIBUTES = {0x400A: 0b11110}
class TintRGBCCTLight(CustomDevice):
"""Tint E14 RGB+CCT Lighting device."""
signature = {
MODELS_INFO: [("MLI", "tint-ExtendedColor")],
ENDPOINTS: {
1: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.EXTENDED_COLOR_LIGHT,
INPUT_CLUSTERS: [
Basic.cluster_id,
Identify.cluster_id,
Groups.cluster_id,
Scenes.cluster_id,
OnOff.cluster_id,
LevelControl.cluster_id,
Color.cluster_id,
LightLink.cluster_id,
TintManufacturerSpecificCluster.cluster_id,
],
OUTPUT_CLUSTERS: [Ota.cluster_id],
},
242: {
PROFILE_ID: zgp.PROFILE_ID,
DEVICE_TYPE: zgp.DeviceType.PROXY_BASIC,
INPUT_CLUSTERS: [],
OUTPUT_CLUSTERS: [GreenPowerProxy.cluster_id],
},
},
}
replacement = {
ENDPOINTS: {
1: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.EXTENDED_COLOR_LIGHT,
INPUT_CLUSTERS: [
Basic.cluster_id,
Identify.cluster_id,
Groups.cluster_id,
Scenes.cluster_id,
OnOff.cluster_id,
LevelControl.cluster_id,
TintRGBCCTColorCluster,
LightLink.cluster_id,
TintManufacturerSpecificCluster,
],
OUTPUT_CLUSTERS: [Ota.cluster_id],
},
242: {
PROFILE_ID: zgp.PROFILE_ID,
DEVICE_TYPE: zgp.DeviceType.PROXY_BASIC,
INPUT_CLUSTERS: [],
OUTPUT_CLUSTERS: [GreenPowerProxy.cluster_id],
},
}
} | zha-quirks | /zha_quirks-0.0.103-py3-none-any.whl/zhaquirks/mli/tintE14rgbcct.py | tintE14rgbcct.py |
from __future__ import annotations
class Bytes(bytes):
"""Bytes serializable class."""
def serialize(self):
"""Serialize Bytes."""
return self
@classmethod
def deserialize(cls, data):
"""Deserialize Bytes."""
return cls(data), b""
class ATCommand(Bytes):
"""AT command serializable class."""
@classmethod
def deserialize(cls, data):
"""Deserialize ATCommand."""
return cls(data[:2]), data[2:]
class BinaryString(str):
"""Class to parse and serialize binary data as string."""
def serialize(self):
"""Serialize string into bytes."""
return bytes(self, encoding="latin1")
@classmethod
def deserialize(cls, data):
"""Interpret data as string."""
data = str(data, encoding="latin1")
return (cls(data), b"")
class IOSample(dict):
"""Parse an XBee IO sample report."""
serialize = None
@classmethod
def deserialize(cls, data):
"""Deserialize an xbee IO sample report.
xbee digital sample format
Sample set count byte 0
Digital mask byte 1, 2
Analog mask byte 3
Digital samples byte 4, 5 (if any sample exists)
Analog Sample, 2 bytes per
"""
sample_sets = int.from_bytes(data[0:1], byteorder="big")
if sample_sets != 1:
raise ValueError("Number of sets is not 1")
digital_mask = data[1:3]
analog_mask = data[3:4]
digital_sample = data[4:6]
num_bits = 15
digital_pins = [
(int.from_bytes(digital_mask, byteorder="big") >> bit) & 1
for bit in range(num_bits - 1, -1, -1)
]
digital_pins = list(reversed(digital_pins))
analog_pins = [
(int.from_bytes(analog_mask, byteorder="big") >> bit) & 1
for bit in range(8 - 1, -1, -1)
]
analog_pins = list(reversed(analog_pins))
if 1 in digital_pins:
digital_samples: list[int | None] = [
(int.from_bytes(digital_sample, byteorder="big") >> bit) & 1
for bit in range(num_bits - 1, -1, -1)
]
digital_samples = list(reversed(digital_samples))
sample_index = 6
else:
# skip digital samples block
digital_samples = digital_pins
sample_index = 4
analog_samples = []
for apin in analog_pins:
if apin == 1:
analog_samples.append(
int.from_bytes(
data[sample_index : sample_index + 2], byteorder="big"
)
)
sample_index += 2
else:
analog_samples.append(None)
for dpin in range(len(digital_pins)):
if digital_pins[dpin] == 0:
digital_samples[dpin] = None
return (
{
"digital_samples": digital_samples,
"analog_samples": analog_samples,
},
data[sample_index:],
) | zha-quirks | /zha_quirks-0.0.103-py3-none-any.whl/zhaquirks/xbee/types.py | types.py |
from zigpy.profiles import zha
from zhaquirks.const import (
DEVICE_TYPE,
ENDPOINTS,
INPUT_CLUSTERS,
OUTPUT_CLUSTERS,
PROFILE_ID,
)
from zhaquirks.xbee import XBEE_PROFILE_ID, XBeeAnalogInput, XBeeCommon, XBeeOnOff
class XBeeSensor(XBeeCommon):
"""XBee Sensor."""
replacement = XBeeCommon.replacement.copy()
replacement["model"] = "XBee2"
replacement[ENDPOINTS] = XBeeCommon.replacement[ENDPOINTS].copy()
replacement[ENDPOINTS].update(
{
0xD0: {
# AD0/DIO0/Commissioning
DEVICE_TYPE: zha.DeviceType.LEVEL_CONTROL_SWITCH,
PROFILE_ID: XBEE_PROFILE_ID,
INPUT_CLUSTERS: [XBeeOnOff, XBeeAnalogInput],
OUTPUT_CLUSTERS: [],
},
0xD1: {
# AD1/DIO1/SPI_nATTN
DEVICE_TYPE: zha.DeviceType.LEVEL_CONTROL_SWITCH,
PROFILE_ID: XBEE_PROFILE_ID,
INPUT_CLUSTERS: [XBeeOnOff, XBeeAnalogInput],
OUTPUT_CLUSTERS: [],
},
0xD2: {
# AD2/DIO2/SPI_CLK
DEVICE_TYPE: zha.DeviceType.LEVEL_CONTROL_SWITCH,
PROFILE_ID: XBEE_PROFILE_ID,
INPUT_CLUSTERS: [XBeeOnOff, XBeeAnalogInput],
OUTPUT_CLUSTERS: [],
},
0xD3: {
# AD3/DIO3
DEVICE_TYPE: zha.DeviceType.LEVEL_CONTROL_SWITCH,
PROFILE_ID: XBEE_PROFILE_ID,
INPUT_CLUSTERS: [XBeeOnOff, XBeeAnalogInput],
OUTPUT_CLUSTERS: [],
},
0xD4: {
# DIO4/SPI_MOSI
DEVICE_TYPE: zha.DeviceType.LEVEL_CONTROL_SWITCH,
PROFILE_ID: XBEE_PROFILE_ID,
INPUT_CLUSTERS: [XBeeOnOff],
OUTPUT_CLUSTERS: [],
},
0xD5: {
# DIO5/Assoc
DEVICE_TYPE: zha.DeviceType.LEVEL_CONTROL_SWITCH,
PROFILE_ID: XBEE_PROFILE_ID,
INPUT_CLUSTERS: [XBeeOnOff],
OUTPUT_CLUSTERS: [],
},
0xD6: {
# DIO6/RTS
DEVICE_TYPE: zha.DeviceType.LEVEL_CONTROL_SWITCH,
PROFILE_ID: XBEE_PROFILE_ID,
INPUT_CLUSTERS: [XBeeOnOff],
OUTPUT_CLUSTERS: [],
},
0xD7: {
# DIO7/CTS
DEVICE_TYPE: zha.DeviceType.LEVEL_CONTROL_SWITCH,
PROFILE_ID: XBEE_PROFILE_ID,
INPUT_CLUSTERS: [XBeeOnOff, XBeeAnalogInput],
OUTPUT_CLUSTERS: [],
},
0xD8: {
# DIO8
DEVICE_TYPE: zha.DeviceType.LEVEL_CONTROL_SWITCH,
PROFILE_ID: XBEE_PROFILE_ID,
INPUT_CLUSTERS: [XBeeOnOff],
OUTPUT_CLUSTERS: [],
},
0xD9: {
# DIO9
DEVICE_TYPE: zha.DeviceType.LEVEL_CONTROL_SWITCH,
PROFILE_ID: XBEE_PROFILE_ID,
INPUT_CLUSTERS: [XBeeOnOff],
OUTPUT_CLUSTERS: [],
},
0xDA: {
# DIO10/PWM0
DEVICE_TYPE: zha.DeviceType.LEVEL_CONTROL_SWITCH,
PROFILE_ID: XBEE_PROFILE_ID,
INPUT_CLUSTERS: [XBeeOnOff],
OUTPUT_CLUSTERS: [],
},
0xDB: {
# DIO11/PWM1
DEVICE_TYPE: zha.DeviceType.LEVEL_CONTROL_SWITCH,
PROFILE_ID: XBEE_PROFILE_ID,
INPUT_CLUSTERS: [XBeeOnOff],
OUTPUT_CLUSTERS: [],
},
0xDC: {
# DIO12/SPI_MISO
DEVICE_TYPE: zha.DeviceType.LEVEL_CONTROL_SWITCH,
PROFILE_ID: XBEE_PROFILE_ID,
INPUT_CLUSTERS: [XBeeOnOff],
OUTPUT_CLUSTERS: [],
},
0xDD: {
# DIO13/DOUT
DEVICE_TYPE: zha.DeviceType.LEVEL_CONTROL_SWITCH,
PROFILE_ID: XBEE_PROFILE_ID,
INPUT_CLUSTERS: [XBeeOnOff],
OUTPUT_CLUSTERS: [],
},
0xDE: {
# DIO14/DIN
DEVICE_TYPE: zha.DeviceType.LEVEL_CONTROL_SWITCH,
PROFILE_ID: XBEE_PROFILE_ID,
INPUT_CLUSTERS: [XBeeOnOff],
OUTPUT_CLUSTERS: [],
},
}
)
signature = {
ENDPOINTS: {
232: {
PROFILE_ID: XBEE_PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.ON_OFF_SWITCH,
INPUT_CLUSTERS: [],
OUTPUT_CLUSTERS: [],
},
230: {
PROFILE_ID: XBEE_PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.ON_OFF_SWITCH,
INPUT_CLUSTERS: [],
OUTPUT_CLUSTERS: [],
},
}
} | zha-quirks | /zha_quirks-0.0.103-py3-none-any.whl/zhaquirks/xbee/xbee_io.py | xbee_io.py |
from zigpy.profiles import zha
from zhaquirks.const import (
DEVICE_TYPE,
ENDPOINTS,
INPUT_CLUSTERS,
OUTPUT_CLUSTERS,
PROFILE_ID,
)
from zhaquirks.xbee import (
XBEE_PROFILE_ID,
XBeeAnalogInput,
XBeeCommon,
XBeeOnOff,
XBeePWM,
)
class XBee3Sensor(XBeeCommon):
"""XBee3 Sensor."""
replacement = XBeeCommon.replacement.copy()
replacement["model"] = "XBee3"
replacement[ENDPOINTS] = XBeeCommon.replacement[ENDPOINTS].copy()
replacement[ENDPOINTS].update(
{
0xD0: {
# AD0/DIO0/Commissioning
DEVICE_TYPE: zha.DeviceType.LEVEL_CONTROL_SWITCH,
PROFILE_ID: XBEE_PROFILE_ID,
INPUT_CLUSTERS: [XBeeOnOff, XBeeAnalogInput],
OUTPUT_CLUSTERS: [],
},
0xD1: {
# AD1/DIO1/SPI_nATTN
DEVICE_TYPE: zha.DeviceType.LEVEL_CONTROL_SWITCH,
PROFILE_ID: XBEE_PROFILE_ID,
INPUT_CLUSTERS: [XBeeOnOff, XBeeAnalogInput],
OUTPUT_CLUSTERS: [],
},
0xD2: {
# AD2/DIO2/SPI_CLK
DEVICE_TYPE: zha.DeviceType.LEVEL_CONTROL_SWITCH,
PROFILE_ID: XBEE_PROFILE_ID,
INPUT_CLUSTERS: [XBeeOnOff, XBeeAnalogInput],
OUTPUT_CLUSTERS: [],
},
0xD3: {
# AD3/DIO3
DEVICE_TYPE: zha.DeviceType.LEVEL_CONTROL_SWITCH,
PROFILE_ID: XBEE_PROFILE_ID,
INPUT_CLUSTERS: [XBeeOnOff, XBeeAnalogInput],
OUTPUT_CLUSTERS: [],
},
0xD4: {
# DIO4/SPI_MOSI
DEVICE_TYPE: zha.DeviceType.LEVEL_CONTROL_SWITCH,
PROFILE_ID: XBEE_PROFILE_ID,
INPUT_CLUSTERS: [XBeeOnOff],
OUTPUT_CLUSTERS: [],
},
0xD5: {
# DIO5/Assoc
DEVICE_TYPE: zha.DeviceType.LEVEL_CONTROL_SWITCH,
PROFILE_ID: XBEE_PROFILE_ID,
INPUT_CLUSTERS: [XBeeOnOff],
OUTPUT_CLUSTERS: [],
},
0xD6: {
# DIO6/RTS
DEVICE_TYPE: zha.DeviceType.LEVEL_CONTROL_SWITCH,
PROFILE_ID: XBEE_PROFILE_ID,
INPUT_CLUSTERS: [XBeeOnOff],
OUTPUT_CLUSTERS: [],
},
0xD7: {
# DIO7/CTS
DEVICE_TYPE: zha.DeviceType.LEVEL_CONTROL_SWITCH,
PROFILE_ID: XBEE_PROFILE_ID,
INPUT_CLUSTERS: [XBeeOnOff, XBeeAnalogInput],
OUTPUT_CLUSTERS: [],
},
0xD8: {
# DIO8
DEVICE_TYPE: zha.DeviceType.LEVEL_CONTROL_SWITCH,
PROFILE_ID: XBEE_PROFILE_ID,
INPUT_CLUSTERS: [XBeeOnOff],
OUTPUT_CLUSTERS: [],
},
0xD9: {
# DIO9
DEVICE_TYPE: zha.DeviceType.LEVEL_CONTROL_SWITCH,
PROFILE_ID: XBEE_PROFILE_ID,
INPUT_CLUSTERS: [XBeeOnOff],
OUTPUT_CLUSTERS: [],
},
0xDA: {
# DIO10/PWM0
DEVICE_TYPE: zha.DeviceType.LEVEL_CONTROL_SWITCH,
PROFILE_ID: XBEE_PROFILE_ID,
INPUT_CLUSTERS: [XBeeOnOff, XBeePWM],
OUTPUT_CLUSTERS: [],
},
0xDB: {
# DIO11/PWM1
DEVICE_TYPE: zha.DeviceType.LEVEL_CONTROL_SWITCH,
PROFILE_ID: XBEE_PROFILE_ID,
INPUT_CLUSTERS: [XBeeOnOff, XBeePWM],
OUTPUT_CLUSTERS: [],
},
0xDC: {
# DIO12/SPI_MISO
DEVICE_TYPE: zha.DeviceType.LEVEL_CONTROL_SWITCH,
PROFILE_ID: XBEE_PROFILE_ID,
INPUT_CLUSTERS: [XBeeOnOff],
OUTPUT_CLUSTERS: [],
},
0xDD: {
# DIO13/DOUT
DEVICE_TYPE: zha.DeviceType.LEVEL_CONTROL_SWITCH,
PROFILE_ID: XBEE_PROFILE_ID,
INPUT_CLUSTERS: [XBeeOnOff],
OUTPUT_CLUSTERS: [],
},
0xDE: {
# DIO14/DIN
DEVICE_TYPE: zha.DeviceType.LEVEL_CONTROL_SWITCH,
PROFILE_ID: XBEE_PROFILE_ID,
INPUT_CLUSTERS: [XBeeOnOff],
OUTPUT_CLUSTERS: [],
},
}
)
signature = {
ENDPOINTS: {
232: {
PROFILE_ID: XBEE_PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.LEVEL_CONTROL_SWITCH,
INPUT_CLUSTERS: [],
OUTPUT_CLUSTERS: [],
},
230: {
PROFILE_ID: XBEE_PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.LEVEL_CONTROL_SWITCH,
INPUT_CLUSTERS: [],
OUTPUT_CLUSTERS: [],
},
}
} | zha-quirks | /zha_quirks-0.0.103-py3-none-any.whl/zhaquirks/xbee/xbee3_io.py | xbee3_io.py |
import asyncio
import enum
import logging
from typing import Any, List, Optional
from zigpy.quirks import CustomDevice
import zigpy.types as t
from zigpy.zcl import foundation
from zigpy.zcl.clusters.general import (
AnalogInput,
AnalogOutput,
Basic,
BinaryInput,
LevelControl,
OnOff,
)
from zhaquirks import EventableCluster, LocalDataCluster
from zhaquirks.const import ENDPOINTS, INPUT_CLUSTERS, OUTPUT_CLUSTERS
from .types import ATCommand, BinaryString, Bytes, IOSample
_LOGGER = logging.getLogger(__name__)
DATA_IN_CMD = 0x0000
DIO_APPLY_CHANGES = 0x02
DIO_PIN_HIGH = 0x05
DIO_PIN_LOW = 0x04
ON_OFF_CMD = 0x0000
SAMPLE_DATA_CMD = 0x0000
SERIAL_DATA_CMD = 0x0000
AT_RESPONSE_CMD = 0x0000
XBEE_DATA_CLUSTER = 0x11
XBEE_AT_REQUEST_CLUSTER = 0x21
XBEE_AT_RESPONSE_CLUSTER = 0xA1
XBEE_AT_ENDPOINT = 0xE6
XBEE_DATA_ENDPOINT = 0xE8
XBEE_IO_CLUSTER = 0x92
XBEE_PROFILE_ID = 0xC105
ATTR_ON_OFF = 0x0000
ATTR_PRESENT_VALUE = 0x0055
PIN_ANALOG_OUTPUT = 2
REMOTE_AT_COMMAND_TIMEOUT = 30
# https://github.com/zigpy/zigpy-xbee/blob/dev/zigpy_xbee/api.py
AT_COMMANDS = {
# Addressing commands
"DH": t.uint32_t_be,
"DL": t.uint32_t_be,
"MY": t.uint16_t_be,
"MP": t.uint16_t_be,
"NC": t.uint32_t_be, # 0 - MAX_CHILDREN.
"SH": t.uint32_t_be,
"SL": t.uint32_t_be,
"NI": Bytes, # 20 byte printable ascii string
# "SE": t.uint8_t,
# "DE": t.uint8_t,
# "CI": t.uint16_t_be,
"TO": t.uint8_t,
"NP": t.uint16_t_be,
"DD": t.uint32_t_be,
"CR": t.uint8_t, # 0 - 0x3F
# Networking commands
"CH": t.uint8_t, # 0x0B - 0x1A
"DA": None, # no param
# "ID": t.uint64_t_be,
"OP": t.uint64_t_be,
"NH": t.uint8_t,
"BH": t.uint8_t, # 0 - 0x1E
"OI": t.uint16_t_be,
"NT": t.uint8_t, # 0x20 - 0xFF
"NO": t.uint8_t, # bitfield, 0 - 3
"SC": t.uint16_t_be, # 1 - 0xFFFF
"SD": t.uint8_t, # 0 - 7
# "ZS": t.uint8_t, # 0 - 2
"NJ": t.uint8_t,
"JV": t.Bool,
"NW": t.uint16_t_be, # 0 - 0x64FF
"JN": t.Bool,
"AR": t.uint8_t,
"DJ": t.Bool, # WTF, docs
"II": t.uint16_t_be,
# Security commands
# "EE": t.Bool,
# "EO": t.uint8_t,
# "NK": Bytes, # 128-bit value
# "KY": Bytes, # 128-bit value
# RF interfacing commands
"PL": t.uint8_t, # 0 - 4 (basically an Enum)
"PM": t.Bool,
"DB": t.uint8_t,
"PP": t.uint8_t, # RO
"AP": t.uint8_t, # 1-2 (an Enum)
"AO": t.uint8_t, # 0 - 3 (an Enum)
"BD": t.uint8_t, # 0 - 7 (an Enum)
"NB": t.uint8_t, # 0 - 3 (an Enum)
"SB": t.uint8_t, # 0 - 1 (an Enum)
"RO": t.uint8_t,
"D6": t.uint8_t, # 0 - 5 (an Enum)
"D7": t.uint8_t, # 0 - 7 (an Enum)
"P3": t.uint8_t, # 0 - 5 (an Enum)
"P4": t.uint8_t, # 0 - 5 (an Enum)
# I/O commands
"IR": t.uint16_t_be,
"IC": t.uint16_t_be,
"D0": t.uint8_t, # 0 - 5 (an Enum)
"D1": t.uint8_t, # 0 - 5 (an Enum)
"D2": t.uint8_t, # 0 - 5 (an Enum)
"D3": t.uint8_t, # 0 - 5 (an Enum)
"D4": t.uint8_t, # 0 - 5 (an Enum)
"D5": t.uint8_t, # 0 - 5 (an Enum)
"D8": t.uint8_t, # 0 - 5 (an Enum)
"D9": t.uint8_t, # 0 - 5 (an Enum)
"P0": t.uint8_t, # 0 - 5 (an Enum)
"P1": t.uint8_t, # 0 - 5 (an Enum)
"P2": t.uint8_t, # 0 - 5 (an Enum)
"P5": t.uint8_t, # 0 - 5 (an Enum)
"P6": t.uint8_t, # 0 - 5 (an Enum)
"P7": t.uint8_t, # 0 - 5 (an Enum)
"P8": t.uint8_t, # 0 - 5 (an Enum)
"P9": t.uint8_t, # 0 - 5 (an Enum)
"LT": t.uint8_t,
"PR": t.uint16_t_be,
"RP": t.uint8_t,
"%V": t.uint16_t_be, # read only
"V+": t.uint16_t_be,
"TP": t.int16s_be,
"M0": t.uint16_t_be, # 0 - 0x3FF
"M1": t.uint16_t_be, # 0 - 0x3FF
# Diagnostics commands
"VR": t.uint16_t_be,
"HV": t.uint16_t_be,
"AI": t.uint8_t,
# AT command options
"CT": t.uint16_t_be, # 2 - 0x028F
"CN": None,
"GT": t.uint16_t_be,
"CC": t.uint8_t,
# Sleep commands
"SM": t.uint8_t,
"SN": t.uint16_t_be,
"SP": t.uint16_t_be,
"ST": t.uint16_t_be,
"SO": t.uint8_t,
"WH": t.uint16_t_be,
"SI": None,
"PO": t.uint16_t_be, # 0 - 0x3E8
# Execution commands
"AC": None,
"WR": None,
"RE": None,
"FR": None,
"NR": t.Bool,
"CB": t.uint8_t,
"DN": Bytes, # "up to 20-Byte printable ASCII string"
"IS": IOSample,
"AS": None,
# Stuff I've guessed
# "CE": t.uint8_t,
}
# 4 AO lines
# 10 digital
# Discovered endpoint information: <SimpleDescriptor endpoint=232 profile=49413
# device_type=1 device_version=0 input_clusters=[] output_clusters=[]>
ENDPOINT_TO_AT = {
0xD0: "D0",
0xD1: "D1",
0xD2: "D2",
0xD3: "D3",
0xD4: "D4",
0xD5: "D5",
0xD6: "D6",
0xD7: "D7",
0xD8: "D8",
0xD9: "D9",
0xDA: "P0",
0xDB: "P1",
0xDC: "P2",
0xDD: "P3",
0xDE: "P4",
}
class ATCommandResult(enum.IntEnum):
"""AT command results."""
OK = 0
ERROR = 1
INVALID_COMMAND = 2
INVALID_PARAMETER = 3
TX_FAILURE = 4
class XBeeBasic(LocalDataCluster, Basic):
"""XBee Basic Cluster."""
_CONSTANT_ATTRIBUTES = {
0x0000: 0x02, # ZCLVersion
0x0007: Basic.PowerSource.Unknown, # PowerSource
}
class XBeeOnOff(LocalDataCluster, OnOff):
"""XBee on/off cluster."""
async def command(
self, command_id, *args, manufacturer=None, expect_reply=True, tsn=None
):
"""Xbee change pin state command, requires zigpy_xbee."""
pin_name = ENDPOINT_TO_AT.get(self._endpoint.endpoint_id)
if command_id not in [0, 1] or pin_name is None:
return super().command(command_id, *args)
if command_id == 0:
pin_cmd = DIO_PIN_LOW
else:
pin_cmd = DIO_PIN_HIGH
await self._endpoint.device.remote_at(pin_name, pin_cmd)
self._update_attribute(ATTR_ON_OFF, command_id)
return foundation.GENERAL_COMMANDS[
foundation.GeneralCommand.Default_Response
].schema(command_id=command_id, status=foundation.Status.SUCCESS)
class XBeeAnalogInput(LocalDataCluster, AnalogInput):
"""XBee Analog Input Cluster."""
class XBeePWM(LocalDataCluster, AnalogOutput):
"""XBee PWM Cluster."""
_CONSTANT_ATTRIBUTES = {
0x0041: float(0x03FF), # max_present_value
0x0045: 0.0, # min_present_value
0x0051: 0, # out_of_service
0x006A: 1.0, # resolution
0x006F: 0x00, # status_flags
}
_ep_id_2_pwm = {0xDA: "M0", 0xDB: "M1"}
async def write_attributes(self, attributes, manufacturer=None):
"""Intercept present_value attribute write."""
attr_id = None
if ATTR_PRESENT_VALUE in attributes:
attr_id = ATTR_PRESENT_VALUE
elif "present_value" in attributes:
attr_id = "present_value"
if attr_id:
duty_cycle = int(round(float(attributes[attr_id])))
at_command = self._ep_id_2_pwm.get(self._endpoint.endpoint_id)
await self._endpoint.device.remote_at(at_command, duty_cycle)
at_command = ENDPOINT_TO_AT.get(self._endpoint.endpoint_id)
await self._endpoint.device.remote_at(at_command, PIN_ANALOG_OUTPUT)
return await super().write_attributes(attributes, manufacturer)
async def read_attributes_raw(self, attributes, manufacturer=None):
"""Intercept present_value attribute read."""
if ATTR_PRESENT_VALUE in attributes or "present_value" in attributes:
at_command = self._ep_id_2_pwm.get(self._endpoint.endpoint_id)
result = await self._endpoint.device.remote_at(at_command)
self._update_attribute(ATTR_PRESENT_VALUE, float(result))
return await super().read_attributes_raw(attributes, manufacturer)
class XBeeRemoteATRequest(LocalDataCluster):
"""Remote AT Command Request Cluster."""
cluster_id = XBEE_AT_REQUEST_CLUSTER
client_commands = {}
server_commands = {
k: foundation.ZCLCommandDef(
name=v[0].replace("%V", "PercentV").replace("V+", "VPlus"),
schema={"param?": v[1]} if v[1] else {},
is_manufacturer_specific=True,
)
for k, v in zip(range(1, len(AT_COMMANDS) + 1), AT_COMMANDS.items())
}
_seq: int = 1
def _save_at_request(self, frame_id, future):
self._endpoint.in_clusters[XBEE_AT_RESPONSE_CLUSTER].save_at_request(
frame_id, future
)
def remote_at_command(self, cmd_name, *args, apply_changes=True, **kwargs):
"""Execute a Remote AT Command and Return Response."""
if hasattr(self._endpoint.device.application, "remote_at_command"):
return self._endpoint.device.application.remote_at_command(
self._endpoint.device.nwk,
cmd_name,
*args,
apply_changes=apply_changes,
encryption=False,
**kwargs,
)
_LOGGER.debug("Remote AT%s command: %s", cmd_name, args)
options = t.uint8_t(0)
if apply_changes:
options |= 0x02
return self._remote_at_command(options, cmd_name, *args)
async def _remote_at_command(self, options, name, *args):
_LOGGER.debug("Remote AT command: %s %s", name, args)
data = t.serialize(args, (AT_COMMANDS[name],))
try:
return await asyncio.wait_for(
await self._command(options, name.encode("ascii"), data, *args),
timeout=REMOTE_AT_COMMAND_TIMEOUT,
)
except asyncio.TimeoutError:
_LOGGER.warning("No response to %s command", name)
raise
async def _command(self, options, command, data, *args):
_LOGGER.debug("Command %s %s", command, data)
frame_id = self._seq
self._seq = (self._seq % 255) + 1
schema = (
t.uint8_t,
t.uint8_t,
t.uint8_t,
t.uint8_t,
t.EUI64,
t.uint16_t_be,
Bytes,
Bytes,
)
data = t.serialize(
(
0x32,
0x00,
options,
frame_id,
self._endpoint.device.application.state.node_info.ieee[::-1],
self._endpoint.device.application.state.node_info.nwk,
command,
data,
),
schema,
)
future = asyncio.Future()
self._save_at_request(frame_id, future)
try:
await self._endpoint.device.application.request(
self._endpoint.device,
XBEE_PROFILE_ID,
XBEE_AT_REQUEST_CLUSTER,
XBEE_AT_ENDPOINT,
XBEE_AT_ENDPOINT,
self._endpoint.device.application.get_sequence(),
data,
expect_reply=False,
)
except Exception as e:
future.set_exception(e)
return future
async def command(
self,
command_id,
param=None,
*args,
manufacturer=None,
expect_reply=False,
tsn=None,
):
"""Handle AT request."""
command = (
self.server_commands[command_id]
.name.replace("PercentV", "%V")
.replace("VPlus", "V+")
)
if param is not None:
value = await self.remote_at_command(command, param)
else:
value = await self.remote_at_command(command)
tsn = self._endpoint.device.application.get_sequence()
hdr = foundation.ZCLHeader.cluster(tsn, command_id)
self._endpoint.device.endpoints[XBEE_DATA_ENDPOINT].out_clusters[
LevelControl.cluster_id
].handle_cluster_request(hdr, {"response": value})
if command == "IS" and value:
tsn = self._endpoint.device.application.get_sequence()
hdr = foundation.ZCLHeader.cluster(tsn, SAMPLE_DATA_CMD)
self._endpoint.device.endpoints[XBEE_DATA_ENDPOINT].in_clusters[
XBEE_IO_CLUSTER
].handle_cluster_request(
hdr,
self._endpoint.device.endpoints[XBEE_DATA_ENDPOINT]
.in_clusters[XBEE_IO_CLUSTER]
.server_commands[SAMPLE_DATA_CMD]
.schema(io_sample=value),
)
return foundation.GENERAL_COMMANDS[
foundation.GeneralCommand.Default_Response
].schema(command_id=command_id, status=foundation.Status.SUCCESS)
class XBeeRemoteATResponse(LocalDataCluster):
"""Remote AT Command Response Cluster."""
cluster_id = XBEE_AT_RESPONSE_CLUSTER
_awaiting = {}
def save_at_request(self, frame_id, future):
"""Save pending request."""
self._awaiting[frame_id] = (future,)
def handle_cluster_request(
self,
hdr: foundation.ZCLHeader,
args: List[Any],
*,
dst_addressing: Optional[t.AddrMode] = None,
):
"""Handle AT response."""
if hdr.command_id == DATA_IN_CMD:
_LOGGER.debug(
"Remote AT command response: %s",
(args.frame_id, args.cmd, args.status, args.value),
)
(fut,) = self._awaiting.pop(args.frame_id)
try:
status = ATCommandResult(args.status)
except ValueError:
status = ATCommandResult.ERROR
if status:
fut.set_exception(RuntimeError(f"AT Command response: {status.name}"))
return
response_type = AT_COMMANDS[args.cmd.decode("ascii")]
if response_type is None or len(args.value) == 0:
fut.set_result(None)
return
response, remains = response_type.deserialize(args.value)
fut.set_result(response)
else:
super().handle_cluster_request(hdr, args)
client_commands = {}
server_commands = {
AT_RESPONSE_CMD: foundation.ZCLCommandDef(
name="remote_at_response",
schema={
"frame_id": t.uint8_t,
"cmd": ATCommand,
"status": t.uint8_t,
"value": Bytes,
},
is_manufacturer_specific=True,
)
}
class XBeeDigitalIOCluster(LocalDataCluster, BinaryInput):
"""Digital IO Cluster for the XBee."""
cluster_id = XBEE_IO_CLUSTER
def handle_cluster_request(
self,
hdr: foundation.ZCLHeader,
args: List[Any],
*,
dst_addressing: Optional[t.AddrMode] = None,
):
"""Handle the cluster request.
Update the digital pin states
"""
if hdr.command_id == SAMPLE_DATA_CMD:
values = args.io_sample
if "digital_samples" in values:
# Update digital inputs
active_pins = [
i for i, x in enumerate(values["digital_samples"]) if x is not None
]
for pin in active_pins:
# pylint: disable=W0212
self._endpoint.device[0xD0 + pin].on_off._update_attribute(
ATTR_ON_OFF, values["digital_samples"][pin]
)
if "analog_samples" in values:
# Update analog inputs
active_pins = [
i for i, x in enumerate(values["analog_samples"]) if x is not None
]
for pin in active_pins:
# pylint: disable=W0212
self._endpoint.device[0xD0 + pin].analog_input._update_attribute(
ATTR_PRESENT_VALUE,
values["analog_samples"][pin]
/ (10.23 if pin != 7 else 1000), # supply voltage is in mV
)
else:
super().handle_cluster_request(hdr, args)
client_commands = {}
server_commands = {
SAMPLE_DATA_CMD: foundation.ZCLCommandDef(
name="io_sample",
schema={"io_sample": IOSample},
is_manufacturer_specific=True,
)
}
# pylint: disable=too-many-ancestors
class XBeeEventRelayCluster(EventableCluster, LocalDataCluster, LevelControl):
"""A cluster with cluster_id which is allowed to send events."""
attributes = {}
client_commands = {}
server_commands = {
k: foundation.ZCLCommandDef(
name=v[0].replace("%V", "PercentV").replace("V+", "VPlus").lower()
+ "_command_response",
schema={"response?": v[1]} if v[1] else {},
is_manufacturer_specific=True,
)
for k, v in zip(range(1, len(AT_COMMANDS) + 1), AT_COMMANDS.items())
}
server_commands[SERIAL_DATA_CMD] = foundation.ZCLCommandDef(
name="receive_data", schema={"data": str}, is_manufacturer_specific=True
)
class XBeeSerialDataCluster(LocalDataCluster):
"""Serial Data Cluster for the XBee."""
cluster_id = XBEE_DATA_CLUSTER
ep_attribute = "xbee_serial_data"
async def command(
self,
command_id,
data,
*args,
manufacturer=None,
expect_reply=False,
tsn=None,
):
"""Handle outgoing data."""
data = BinaryString(data).serialize()
return foundation.GENERAL_COMMANDS[
foundation.GeneralCommand.Default_Response
].schema(
command_id=0x00,
status=(
await self._endpoint.device.application.request(
self._endpoint.device,
XBEE_PROFILE_ID,
XBEE_DATA_CLUSTER,
XBEE_DATA_ENDPOINT,
XBEE_DATA_ENDPOINT,
self._endpoint.device.application.get_sequence(),
data,
expect_reply=False,
)
)[0],
)
def handle_cluster_request(
self,
hdr: foundation.ZCLHeader,
args: List[Any],
*,
dst_addressing: Optional[t.AddrMode] = None,
):
"""Handle incoming data."""
if hdr.command_id == DATA_IN_CMD:
self._endpoint.out_clusters[LevelControl.cluster_id].handle_cluster_request(
hdr, {"data": args.data}
)
else:
super().handle_cluster_request(hdr, args)
attributes = {}
client_commands = {
SERIAL_DATA_CMD: foundation.ZCLCommandDef(
name="send_data",
schema={"data": BinaryString},
is_manufacturer_specific=True,
)
}
server_commands = {
SERIAL_DATA_CMD: foundation.ZCLCommandDef(
name="receive_data",
schema={"data": BinaryString},
is_manufacturer_specific=True,
)
}
class XBeeCommon(CustomDevice):
"""XBee common class."""
def remote_at(self, command, *args, **kwargs):
"""Remote at command."""
return (
self.endpoints[XBEE_AT_ENDPOINT]
.out_clusters[XBEE_AT_REQUEST_CLUSTER]
.remote_at_command(command, *args, apply_changes=True, **kwargs)
)
def deserialize(self, endpoint_id, cluster_id, data):
"""Deserialize."""
tsn = self._application.get_sequence()
command_id = 0x0000
hdr = foundation.ZCLHeader.cluster(tsn, command_id)
data = hdr.serialize() + data
return super().deserialize(endpoint_id, cluster_id, data)
replacement = {
ENDPOINTS: {
XBEE_AT_ENDPOINT: {
INPUT_CLUSTERS: [XBeeRemoteATResponse],
OUTPUT_CLUSTERS: [XBeeRemoteATRequest],
},
XBEE_DATA_ENDPOINT: {
INPUT_CLUSTERS: [
XBeeDigitalIOCluster,
XBeeSerialDataCluster,
XBeeBasic,
],
OUTPUT_CLUSTERS: [XBeeSerialDataCluster, XBeeEventRelayCluster],
},
},
"manufacturer": "Digi",
} | zha-quirks | /zha_quirks-0.0.103-py3-none-any.whl/zhaquirks/xbee/__init__.py | __init__.py |
import logging
from zigpy.profiles import zha
from zigpy.quirks import CustomDevice
from zigpy.zcl.clusters.general import (
Basic,
Identify,
Ota,
PollControl,
PowerConfiguration,
Time,
)
from zigpy.zcl.clusters.homeautomation import Diagnostic
from zigpy.zcl.clusters.hvac import Thermostat, UserInterface
from zhaquirks import PowerConfigurationCluster
from zhaquirks.bitron import BITRON
from zhaquirks.const import (
DEVICE_TYPE,
ENDPOINTS,
INPUT_CLUSTERS,
MODELS_INFO,
OUTPUT_CLUSTERS,
PROFILE_ID,
)
_LOGGER = logging.getLogger(__name__)
class Av201032PowerConfigurationCluster(PowerConfigurationCluster):
"""Power configuration cluster for Bitron/SMaBiT AV2010/32 thermostats.
This cluster takes the reported battery voltage and converts it into a
battery percentage, since the thermostat does not report this value.
"""
MIN_VOLTS = 2.5
MAX_VOLTS = 3.0
class Av201032(CustomDevice):
"""Class for the AV2010/32 thermostat."""
signature = {
# SizePrefixedSimpleDescriptor(
# endpoint=1,
# profile=260,
# device_type=769,
# device_version=0,
# input_clusters=[0, 1, 3, 10, 32, 513, 516, 2821],
# output_clusters=[3, 25]
# )
MODELS_INFO: [(BITRON, "902010/32")],
ENDPOINTS: {
1: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.THERMOSTAT,
INPUT_CLUSTERS: [
Basic.cluster_id,
PowerConfiguration.cluster_id,
Identify.cluster_id,
Time.cluster_id,
PollControl.cluster_id,
Thermostat.cluster_id,
UserInterface.cluster_id,
Diagnostic.cluster_id,
],
OUTPUT_CLUSTERS: [Identify.cluster_id, Ota.cluster_id],
}
},
}
replacement = {
ENDPOINTS: {
1: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.THERMOSTAT,
INPUT_CLUSTERS: [
Basic.cluster_id,
Av201032PowerConfigurationCluster,
Identify.cluster_id,
Time.cluster_id,
PollControl.cluster_id,
Thermostat.cluster_id,
UserInterface.cluster_id,
Diagnostic.cluster_id,
],
OUTPUT_CLUSTERS: [Identify.cluster_id, Ota.cluster_id],
}
},
} | zha-quirks | /zha_quirks-0.0.103-py3-none-any.whl/zhaquirks/bitron/thermostat.py | thermostat.py |
from zigpy.profiles import zha
from zigpy.quirks import CustomDevice
from zigpy.zcl.clusters.general import Basic, Identify, Ota, PollControl
from zigpy.zcl.clusters.homeautomation import Diagnostic
from zigpy.zcl.clusters.measurement import TemperatureMeasurement
from zigpy.zcl.clusters.security import IasZone
from zhaquirks import PowerConfigurationCluster
from zhaquirks.const import (
DEVICE_TYPE,
ENDPOINTS,
INPUT_CLUSTERS,
MODELS_INFO,
OUTPUT_CLUSTERS,
PROFILE_ID,
)
class CustomPowerConfigurationCluster(PowerConfigurationCluster):
"""Custom PowerConfigurationCluster."""
cluster_id = PowerConfigurationCluster.cluster_id
MIN_VOLTS = 2.1
MAX_VOLTS = 3.0
class ContactSensor(CustomDevice):
"""XHS2-UE Door/Window Sensor."""
signature = {
# <SimpleDescriptor endpoint=1 profile=260 device_type=1026
# device_version=0
# input_clusters=[0, 1, 3, 1026, 1280, 32, 2821]
# output_clusters=[25]>
MODELS_INFO: [("Universal Electronics Inc", "URC4460BC0-X-R")],
ENDPOINTS: {
1: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.IAS_ZONE,
INPUT_CLUSTERS: [
Basic.cluster_id,
CustomPowerConfigurationCluster.cluster_id,
Identify.cluster_id,
TemperatureMeasurement.cluster_id,
IasZone.cluster_id,
PollControl.cluster_id,
Diagnostic.cluster_id,
],
OUTPUT_CLUSTERS: [Ota.cluster_id],
}
},
}
replacement = {
ENDPOINTS: {
1: {
PROFILE_ID: zha.PROFILE_ID,
INPUT_CLUSTERS: [
Basic.cluster_id,
CustomPowerConfigurationCluster,
Identify.cluster_id,
TemperatureMeasurement.cluster_id,
IasZone.cluster_id,
PollControl.cluster_id,
Diagnostic.cluster_id,
],
OUTPUT_CLUSTERS: [Ota.cluster_id],
}
}
} | zha-quirks | /zha_quirks-0.0.103-py3-none-any.whl/zhaquirks/universalelectronics/contact_sensor.py | contact_sensor.py |
from zigpy.profiles import zll
from zigpy.quirks import CustomDevice
from zigpy.zcl.clusters.general import (
Basic,
Groups,
Identify,
LevelControl,
OnOff,
Scenes,
)
from zigpy.zcl.clusters.lighting import Color
from zigpy.zcl.clusters.lightlink import LightLink
from zhaquirks.const import (
DEVICE_TYPE,
ENDPOINTS,
INPUT_CLUSTERS,
MODELS_INFO,
OUTPUT_CLUSTERS,
PROFILE_ID,
)
from zhaquirks.gledopto import GLEDOPTO
class GLC009(CustomDevice):
"""GLEDOPTO GL-C-009 device."""
signature = {
# SizePrefixedSimpleDescriptor(endpoint=11, profile=49246,
# device_type=256, device_version=2,
# input_clusters=[0, 3, 4, 5, 6, 8, 768], output_clusters=[])
MODELS_INFO: [(GLEDOPTO, "GL-C-009")],
ENDPOINTS: {
11: {
PROFILE_ID: zll.PROFILE_ID,
DEVICE_TYPE: zll.DeviceType.DIMMABLE_LIGHT,
INPUT_CLUSTERS: [
Basic.cluster_id,
Identify.cluster_id,
Groups.cluster_id,
Scenes.cluster_id,
OnOff.cluster_id,
LevelControl.cluster_id,
Color.cluster_id,
],
OUTPUT_CLUSTERS: [],
},
# SizePrefixedSimpleDescriptor(endpoint=13, profile=49246,
# device_type=256, device_version=2, input_clusters=[4096],
# output_clusters=[4096])
13: {
PROFILE_ID: zll.PROFILE_ID,
DEVICE_TYPE: zll.DeviceType.DIMMABLE_LIGHT,
INPUT_CLUSTERS: [LightLink.cluster_id],
OUTPUT_CLUSTERS: [LightLink.cluster_id],
},
},
}
replacement = {
ENDPOINTS: {
11: {
PROFILE_ID: zll.PROFILE_ID,
DEVICE_TYPE: zll.DeviceType.DIMMABLE_LIGHT,
INPUT_CLUSTERS: [
Basic.cluster_id,
Identify.cluster_id,
Groups.cluster_id,
Scenes.cluster_id,
OnOff.cluster_id,
LevelControl.cluster_id,
],
OUTPUT_CLUSTERS: [],
},
}
} | zha-quirks | /zha_quirks-0.0.103-py3-none-any.whl/zhaquirks/gledopto/glc009.py | glc009.py |
from zigpy.profiles import zha
from zigpy.quirks import CustomCluster, CustomDevice
from zigpy.zcl.clusters.general import (
Basic,
Groups,
Identify,
LevelControl,
OnOff,
Ota,
Scenes,
)
from zigpy.zcl.clusters.lightlink import LightLink
from zhaquirks import NoReplyMixin
from zhaquirks.const import (
DEVICE_TYPE,
ENDPOINTS,
INPUT_CLUSTERS,
MODELS_INFO,
OUTPUT_CLUSTERS,
PROFILE_ID,
)
class LevelControlNoReply(NoReplyMixin, CustomCluster, LevelControl):
"""LevelControl cluster that does not require default responses."""
void_input_commands = {cmd.id for cmd in LevelControl.commands_by_name.values()}
class GledoptoGlSd001(CustomDevice):
"""Gledopto GL-SD-001 dimmer custom device implementation."""
signature = {
MODELS_INFO: [("GLEDOPTO", "GL-SD-001")],
ENDPOINTS: {
1: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.DIMMABLE_LIGHT,
INPUT_CLUSTERS: [
Basic.cluster_id,
Identify.cluster_id,
Groups.cluster_id,
Scenes.cluster_id,
OnOff.cluster_id,
LevelControl.cluster_id,
LightLink.cluster_id,
],
OUTPUT_CLUSTERS: [
Ota.cluster_id,
],
},
},
}
replacement = {
ENDPOINTS: {
1: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.DIMMABLE_LIGHT,
INPUT_CLUSTERS: [
Basic.cluster_id,
Identify.cluster_id,
Groups.cluster_id,
Scenes.cluster_id,
OnOff.cluster_id,
LevelControlNoReply,
LightLink.cluster_id,
],
OUTPUT_CLUSTERS: [
Ota.cluster_id,
],
},
},
} | zha-quirks | /zha_quirks-0.0.103-py3-none-any.whl/zhaquirks/gledopto/glsd001.py | glsd001.py |
from zigpy.profiles import zgp, zha
from zigpy.quirks import CustomDevice
from zigpy.zcl.clusters.general import (
Basic,
GreenPowerProxy,
Groups,
Identify,
LevelControl,
OnOff,
Ota,
Scenes,
)
from zigpy.zcl.clusters.lighting import Color
from zigpy.zcl.clusters.lightlink import LightLink
from zhaquirks.const import (
DEVICE_TYPE,
ENDPOINTS,
INPUT_CLUSTERS,
MODELS_INFO,
OUTPUT_CLUSTERS,
PROFILE_ID,
)
class GLC009P(CustomDevice):
"""Gledopto GL-C-009P (mini) custom device implementation for removing Color cluster."""
signature = {
MODELS_INFO: [("GLEDOPTO", "GL-C-009P")],
ENDPOINTS: {
11: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.DIMMABLE_LIGHT,
INPUT_CLUSTERS: [
Basic.cluster_id,
Identify.cluster_id,
Groups.cluster_id,
Scenes.cluster_id,
OnOff.cluster_id,
LevelControl.cluster_id,
Color.cluster_id,
LightLink.cluster_id,
],
OUTPUT_CLUSTERS: [
Ota.cluster_id,
],
},
242: {
PROFILE_ID: zgp.PROFILE_ID,
DEVICE_TYPE: zgp.DeviceType.PROXY_BASIC,
INPUT_CLUSTERS: [],
OUTPUT_CLUSTERS: [
GreenPowerProxy.cluster_id,
],
},
},
}
replacement = {
ENDPOINTS: {
11: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.DIMMABLE_LIGHT,
INPUT_CLUSTERS: [
Basic.cluster_id,
Identify.cluster_id,
Groups.cluster_id,
Scenes.cluster_id,
OnOff.cluster_id,
LevelControl.cluster_id,
LightLink.cluster_id,
],
OUTPUT_CLUSTERS: [
Ota.cluster_id,
],
},
242: {
PROFILE_ID: zgp.PROFILE_ID,
DEVICE_TYPE: zgp.DeviceType.PROXY_BASIC,
INPUT_CLUSTERS: [],
OUTPUT_CLUSTERS: [
GreenPowerProxy.cluster_id,
],
},
}
} | zha-quirks | /zha_quirks-0.0.103-py3-none-any.whl/zhaquirks/gledopto/glc009p.py | glc009p.py |
from zigpy.profiles import zha, zll
from zigpy.quirks import CustomDevice
from zigpy.zcl.clusters.general import (
Basic,
Groups,
Identify,
LevelControl,
OnOff,
Scenes,
)
from zigpy.zcl.clusters.lighting import Color
from zigpy.zcl.clusters.lightlink import LightLink
from zhaquirks.const import (
DEVICE_TYPE,
ENDPOINTS,
INPUT_CLUSTERS,
MODELS_INFO,
OUTPUT_CLUSTERS,
PROFILE_ID,
)
from zhaquirks.gledopto import GLEDOPTO
class GLS007Z(CustomDevice):
"""GLEDOPTO GL-S-007Z device."""
signature = {
# <SimpleDescriptor endpoint=12 profile=260 device_type=258
# device_version=2 input_clusters=[0, 3, 4, 5, 6, 8, 768]
# output_clusters=[]>
MODELS_INFO: [(GLEDOPTO, "GL-S-007Z")],
ENDPOINTS: {
12: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.COLOR_DIMMABLE_LIGHT,
INPUT_CLUSTERS: [
Basic.cluster_id,
Identify.cluster_id,
Groups.cluster_id,
Scenes.cluster_id,
OnOff.cluster_id,
LevelControl.cluster_id,
Color.cluster_id,
],
OUTPUT_CLUSTERS: [],
},
# <SimpleDescriptor endpoint=11 profile=49246 device_type=528
# device_version=2
# input_clusters=[0, 3, 4, 5, 6, 8, 768]
# output_clusters=[]>
11: {
PROFILE_ID: zll.PROFILE_ID,
DEVICE_TYPE: zll.DeviceType.EXTENDED_COLOR_LIGHT,
INPUT_CLUSTERS: [
Basic.cluster_id,
Identify.cluster_id,
Groups.cluster_id,
Scenes.cluster_id,
OnOff.cluster_id,
LevelControl.cluster_id,
Color.cluster_id,
],
OUTPUT_CLUSTERS: [],
},
# <SimpleDescriptor endpoint=13 profile=49246 device_type=57694
# device_version=2
# input_clusters=[4096]
# output_clusters=[4096]>
13: {
PROFILE_ID: zll.PROFILE_ID,
DEVICE_TYPE: 57694,
INPUT_CLUSTERS: [LightLink.cluster_id],
OUTPUT_CLUSTERS: [LightLink.cluster_id],
},
},
}
replacement = {
ENDPOINTS: {
12: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.COLOR_DIMMABLE_LIGHT,
INPUT_CLUSTERS: [
Basic.cluster_id,
Identify.cluster_id,
Groups.cluster_id,
Scenes.cluster_id,
OnOff.cluster_id,
LevelControl.cluster_id,
Color.cluster_id,
],
OUTPUT_CLUSTERS: [],
}
}
} | zha-quirks | /zha_quirks-0.0.103-py3-none-any.whl/zhaquirks/gledopto/gls007z.py | gls007z.py |
from __future__ import annotations
from typing import Any, Coroutine
from zigpy.profiles import zha
from zigpy.quirks import CustomCluster, CustomDevice
import zigpy.types as t
from zigpy.zcl import foundation
from zigpy.zcl.clusters.closures import WindowCovering
from zigpy.zcl.clusters.general import (
Basic,
Groups,
Identify,
Ota,
PowerConfiguration,
Scenes,
)
from zhaquirks import DoublingPowerConfigurationCluster
from zhaquirks.const import (
DEVICE_TYPE,
ENDPOINTS,
INPUT_CLUSTERS,
MODELS_INFO,
OUTPUT_CLUSTERS,
PROFILE_ID,
)
class InvertedWindowCoveringCluster(CustomCluster, WindowCovering):
"""WindowCovering cluster implementation that inverts the commands for up and down."""
CMD_UP_OPEN = WindowCovering.commands_by_name["up_open"].id
CMD_DOWN_CLOSE = WindowCovering.commands_by_name["down_close"].id
async def command(
self,
command_id: foundation.GeneralCommand | int | t.uint8_t,
*args,
manufacturer: int | t.uint16_t | None = None,
expect_reply: bool = True,
tsn: int | t.uint8_t | None = None,
**kwargs: Any,
) -> Coroutine:
"""Override default commands for up and down. They need to be backwards."""
# swap up and down commands
if command_id == self.CMD_UP_OPEN:
command_id = self.CMD_DOWN_CLOSE
elif command_id == self.CMD_DOWN_CLOSE:
command_id = self.CMD_UP_OPEN
return await super().command(
command_id,
*args,
manufacturer=manufacturer,
expect_reply=expect_reply,
tsn=tsn,
**kwargs,
)
class WM25LBlinds(CustomDevice):
"""Custom device representing Smartwings WM25LZ blinds."""
signature = {
# <SimpleDescriptor endpoint=1 profile=260 device_type=514
# device_version=1
# input_clusters=[0, 1, 3, 4, 5, 258]
# output_clusters=[3, 25]>
MODELS_INFO: [
("Smartwings", "WM25/L-Z"),
],
ENDPOINTS: {
1: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.WINDOW_COVERING_DEVICE,
INPUT_CLUSTERS: [
Basic.cluster_id,
PowerConfiguration.cluster_id,
Identify.cluster_id,
Groups.cluster_id,
Scenes.cluster_id,
WindowCovering.cluster_id,
],
OUTPUT_CLUSTERS: [Identify.cluster_id, Ota.cluster_id],
}
},
}
replacement = {
ENDPOINTS: {
1: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.WINDOW_COVERING_DEVICE,
INPUT_CLUSTERS: [
Basic.cluster_id,
DoublingPowerConfigurationCluster,
Identify.cluster_id,
Groups.cluster_id,
Scenes.cluster_id,
InvertedWindowCoveringCluster,
],
OUTPUT_CLUSTERS: [Identify.cluster_id, Ota.cluster_id],
}
}
} | zha-quirks | /zha_quirks-0.0.103-py3-none-any.whl/zhaquirks/smartwings/wm25lz.py | wm25lz.py |
from zigpy.profiles import zgp, zha
from zigpy.quirks import CustomDevice
from zigpy.zcl.clusters.general import (
Basic,
BinaryInput,
GreenPowerProxy,
Groups,
Identify,
LevelControl,
OnOff,
Ota,
PollControl,
Scenes,
)
from zigpy.zcl.clusters.lighting import Ballast
from zhaquirks import PowerConfigurationCluster
from zhaquirks.const import (
DEVICE_TYPE,
ENDPOINTS,
INPUT_CLUSTERS,
MODELS_INFO,
OUTPUT_CLUSTERS,
PROFILE_ID,
)
from zhaquirks.legrand import (
LEGRAND,
MANUFACTURER_SPECIFIC_CLUSTER_ID,
LegrandCluster,
LegrandPowerConfigurationCluster,
)
class DimmerWithoutNeutral(CustomDevice):
"""Dimmer switch w/o neutral."""
signature = {
# <SimpleDescriptor endpoint=1 profile=260 device_type=256
# device_version=1
# input_clusters=[0, 3, 4, 8, 6, 5, 15, 64513]
# output_clusters=[0, 64513, 25]>
MODELS_INFO: [(f" {LEGRAND}", " Dimmer switch w/o neutral")],
ENDPOINTS: {
1: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.ON_OFF_LIGHT,
INPUT_CLUSTERS: [
Basic.cluster_id,
Identify.cluster_id,
Groups.cluster_id,
OnOff.cluster_id,
LevelControl.cluster_id,
Scenes.cluster_id,
BinaryInput.cluster_id,
MANUFACTURER_SPECIFIC_CLUSTER_ID,
],
OUTPUT_CLUSTERS: [
Basic.cluster_id,
MANUFACTURER_SPECIFIC_CLUSTER_ID,
Ota.cluster_id,
],
}
},
}
replacement = {
ENDPOINTS: {
1: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.ON_OFF_LIGHT,
INPUT_CLUSTERS: [
Basic.cluster_id,
Identify.cluster_id,
Groups.cluster_id,
OnOff.cluster_id,
LevelControl.cluster_id,
Scenes.cluster_id,
BinaryInput.cluster_id,
LegrandCluster,
],
OUTPUT_CLUSTERS: [Basic.cluster_id, LegrandCluster, Ota.cluster_id],
}
}
}
class DimmerWithoutNeutral2(DimmerWithoutNeutral):
"""Dimmer switch w/o neutral 2."""
signature = {
# <SimpleDescriptor endpoint=1 profile=260 device_type=256
# device_version=1
# input_clusters=[0, 3, 4, 8, 6, 5, 15, 64513]
# output_clusters=[0, 64513, 25]>
MODELS_INFO: [(f" {LEGRAND}", " Dimmer switch w/o neutral")],
ENDPOINTS: {
1: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.ON_OFF_LIGHT,
INPUT_CLUSTERS: [
Basic.cluster_id,
Identify.cluster_id,
Groups.cluster_id,
OnOff.cluster_id,
LevelControl.cluster_id,
Scenes.cluster_id,
BinaryInput.cluster_id,
MANUFACTURER_SPECIFIC_CLUSTER_ID,
],
OUTPUT_CLUSTERS: [
Basic.cluster_id,
MANUFACTURER_SPECIFIC_CLUSTER_ID,
Ota.cluster_id,
],
},
242: {
PROFILE_ID: zgp.PROFILE_ID,
DEVICE_TYPE: zgp.DeviceType.PROXY_BASIC,
INPUT_CLUSTERS: [],
OUTPUT_CLUSTERS: [GreenPowerProxy.cluster_id],
},
},
}
class DimmerWithoutNeutral3(CustomDevice):
"""Dimmer switch w/o neutral (at least for firmware 0x2e and above)."""
signature = {
# <SimpleDescriptor endpoint=1 profile=260 device_type=256
# device_version=1
# input_clusters=[0, 3, 4, 5, 6, 8, 15, 64513]
# output_clusters=[0, 5, 6, 25, 64513]>
MODELS_INFO: [(f" {LEGRAND}", " Dimmer switch w/o neutral")],
ENDPOINTS: {
1: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.ON_OFF_LIGHT,
INPUT_CLUSTERS: [
Basic.cluster_id,
Identify.cluster_id,
Groups.cluster_id,
OnOff.cluster_id,
LevelControl.cluster_id,
Scenes.cluster_id,
BinaryInput.cluster_id,
MANUFACTURER_SPECIFIC_CLUSTER_ID,
],
OUTPUT_CLUSTERS: [
Basic.cluster_id,
MANUFACTURER_SPECIFIC_CLUSTER_ID,
Ota.cluster_id,
OnOff.cluster_id,
Scenes.cluster_id,
],
},
242: {
PROFILE_ID: zgp.PROFILE_ID,
DEVICE_TYPE: zgp.DeviceType.COMBO_BASIC,
INPUT_CLUSTERS: [GreenPowerProxy.cluster_id],
OUTPUT_CLUSTERS: [GreenPowerProxy.cluster_id],
},
},
}
replacement = {
ENDPOINTS: {
1: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.ON_OFF_LIGHT,
INPUT_CLUSTERS: [
Basic.cluster_id,
Identify.cluster_id,
Groups.cluster_id,
OnOff.cluster_id,
LevelControl.cluster_id,
Scenes.cluster_id,
BinaryInput.cluster_id,
# Some devices with firmware 0x39 have Ballast cluster,
# but some of them don't. But in any case Ballast works,
# if we add it here.
Ballast.cluster_id,
LegrandCluster,
],
OUTPUT_CLUSTERS: [
Basic.cluster_id,
LegrandCluster,
Ota.cluster_id,
OnOff.cluster_id,
Scenes.cluster_id,
],
},
# Green Power End Point
242: {
PROFILE_ID: zgp.PROFILE_ID,
DEVICE_TYPE: zgp.DeviceType.COMBO_BASIC,
INPUT_CLUSTERS: [GreenPowerProxy.cluster_id],
OUTPUT_CLUSTERS: [GreenPowerProxy.cluster_id],
},
},
}
class DimmerWithoutNeutralAndBallast(CustomDevice):
"""Dimmer switch w/o neutral (at least for firmware 0x39)."""
signature = {
# <SimpleDescriptor endpoint=1 profile=260 device_type=256
# device_version=1
# input_clusters=[0, 3, 4, 5, 6, 8, 15, 769, 64513]
# output_clusters=[0, 5, 6, 25, 64513]>
MODELS_INFO: [(f" {LEGRAND}", " Dimmer switch w/o neutral")],
ENDPOINTS: {
1: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.ON_OFF_LIGHT,
INPUT_CLUSTERS: [
Basic.cluster_id,
Identify.cluster_id,
Groups.cluster_id,
OnOff.cluster_id,
LevelControl.cluster_id,
Scenes.cluster_id,
BinaryInput.cluster_id,
Ballast.cluster_id,
MANUFACTURER_SPECIFIC_CLUSTER_ID,
],
OUTPUT_CLUSTERS: [
Basic.cluster_id,
MANUFACTURER_SPECIFIC_CLUSTER_ID,
Ota.cluster_id,
OnOff.cluster_id,
Scenes.cluster_id,
],
},
242: {
PROFILE_ID: zgp.PROFILE_ID,
DEVICE_TYPE: zgp.DeviceType.COMBO_BASIC,
INPUT_CLUSTERS: [GreenPowerProxy.cluster_id],
OUTPUT_CLUSTERS: [GreenPowerProxy.cluster_id],
},
},
}
replacement = {
ENDPOINTS: {
1: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.ON_OFF_LIGHT,
INPUT_CLUSTERS: [
Basic.cluster_id,
Identify.cluster_id,
Groups.cluster_id,
OnOff.cluster_id,
LevelControl.cluster_id,
Scenes.cluster_id,
BinaryInput.cluster_id,
Ballast.cluster_id,
LegrandCluster,
],
OUTPUT_CLUSTERS: [
Basic.cluster_id,
LegrandCluster,
Ota.cluster_id,
OnOff.cluster_id,
Scenes.cluster_id,
],
},
# Green Power End Point
242: {
PROFILE_ID: zgp.PROFILE_ID,
DEVICE_TYPE: zgp.DeviceType.COMBO_BASIC,
INPUT_CLUSTERS: [GreenPowerProxy.cluster_id],
OUTPUT_CLUSTERS: [GreenPowerProxy.cluster_id],
},
},
}
class DimmerWithNeutral(DimmerWithoutNeutral):
"""Dimmer switch with neutral."""
signature = {
# <SimpleDescriptor endpoint=1 profile=260 device_type=256
# device_version=1
# input_clusters=[0, 3, 4, 8, 6, 5, 15, 64513]
# output_clusters=[0, 25, 64513]>
MODELS_INFO: [(f" {LEGRAND}", " Dimmer switch with neutral")],
ENDPOINTS: {
1: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.ON_OFF_LIGHT,
INPUT_CLUSTERS: [
Basic.cluster_id,
Identify.cluster_id,
Groups.cluster_id,
OnOff.cluster_id,
LevelControl.cluster_id,
Scenes.cluster_id,
BinaryInput.cluster_id,
MANUFACTURER_SPECIFIC_CLUSTER_ID,
],
OUTPUT_CLUSTERS: [
Basic.cluster_id,
MANUFACTURER_SPECIFIC_CLUSTER_ID,
Ota.cluster_id,
],
},
242: {
PROFILE_ID: zgp.PROFILE_ID,
DEVICE_TYPE: zgp.DeviceType.COMBO_BASIC,
INPUT_CLUSTERS: [GreenPowerProxy.cluster_id],
OUTPUT_CLUSTERS: [GreenPowerProxy.cluster_id],
},
},
}
class DimmerWithNeutral2(CustomDevice):
"""Dimmer switch with neutral."""
signature = {
# <SimpleDescriptor endpoint=1 profile=260 device_type=256
# device_version=1
# input_clusters=[0, 3, 4, 8, 6, 5, 15, 64513]
# output_clusters=[0, 64513, 5, 25]>
MODELS_INFO: [(f" {LEGRAND}", " Dimmer switch with neutral")],
ENDPOINTS: {
1: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.ON_OFF_LIGHT,
INPUT_CLUSTERS: [
Basic.cluster_id,
Identify.cluster_id,
Groups.cluster_id,
OnOff.cluster_id,
LevelControl.cluster_id,
Scenes.cluster_id,
BinaryInput.cluster_id,
MANUFACTURER_SPECIFIC_CLUSTER_ID,
],
OUTPUT_CLUSTERS: [
Basic.cluster_id,
MANUFACTURER_SPECIFIC_CLUSTER_ID,
Scenes.cluster_id,
Ota.cluster_id,
],
},
242: {
PROFILE_ID: zgp.PROFILE_ID,
DEVICE_TYPE: zgp.DeviceType.COMBO_BASIC,
INPUT_CLUSTERS: [GreenPowerProxy.cluster_id],
OUTPUT_CLUSTERS: [GreenPowerProxy.cluster_id],
},
},
}
replacement = {
ENDPOINTS: {
1: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.ON_OFF_LIGHT,
INPUT_CLUSTERS: [
Basic.cluster_id,
Identify.cluster_id,
Groups.cluster_id,
OnOff.cluster_id,
LevelControl.cluster_id,
Scenes.cluster_id,
BinaryInput.cluster_id,
LegrandCluster,
],
OUTPUT_CLUSTERS: [
Basic.cluster_id,
LegrandCluster,
Scenes.cluster_id,
Ota.cluster_id,
],
}
}
}
class RemoteDimmer(CustomDevice):
"""Remote dimmer ."""
signature = {
MODELS_INFO: [(f" {LEGRAND}", " Remote dimmer switch")],
ENDPOINTS: {
1: {
# "profile_id": 260,
# "device_type": "0x0104",
# "in_clusters": ["0x0000","0x0001","0x0003","0x000f","0x0020","0xfc01"],
# "out_clusters": ["0x0000","0x0003","0x0006","0x0008","0x0019","0xfc01"]
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.DIMMER_SWITCH,
INPUT_CLUSTERS: [
Basic.cluster_id,
PowerConfigurationCluster.cluster_id,
Identify.cluster_id,
BinaryInput.cluster_id,
PollControl.cluster_id,
LegrandCluster.cluster_id,
],
OUTPUT_CLUSTERS: [
Basic.cluster_id,
Identify.cluster_id,
OnOff.cluster_id,
LevelControl.cluster_id,
Ota.cluster_id,
LegrandCluster.cluster_id,
],
}
},
}
replacement = {
ENDPOINTS: {
1: {
INPUT_CLUSTERS: [
Basic.cluster_id,
LegrandPowerConfigurationCluster,
Identify.cluster_id,
BinaryInput.cluster_id,
PollControl.cluster_id,
LegrandCluster,
],
OUTPUT_CLUSTERS: [
Basic.cluster_id,
Identify.cluster_id,
OnOff.cluster_id,
LevelControl.cluster_id,
Ota.cluster_id,
LegrandCluster,
],
}
}
} | zha-quirks | /zha_quirks-0.0.103-py3-none-any.whl/zhaquirks/legrand/dimmer.py | dimmer.py |
from zigpy.profiles import zha
from zigpy.quirks import CustomDevice
from zigpy.zcl.clusters.general import (
Basic,
BinaryInput,
Groups,
Identify,
OnOff,
Ota,
Scenes,
)
from zhaquirks.const import (
DEVICE_TYPE,
ENDPOINTS,
INPUT_CLUSTERS,
MODELS_INFO,
OUTPUT_CLUSTERS,
PROFILE_ID,
)
from zhaquirks.legrand import LEGRAND, MANUFACTURER_SPECIFIC_CLUSTER_ID, LegrandCluster
class LightSwitchWithNeutral(CustomDevice):
"""Light switch with neutral wire."""
signature = {
# <SimpleDescriptor endpoint=1 profile=260 device_type=256
# input_clusters=[0, 3, 4, 5, 6, 15, 64513]
# output_clusters=[0, 25, 64513]>
MODELS_INFO: [(f" {LEGRAND}", " Light switch with neutral")],
ENDPOINTS: {
1: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.ON_OFF_LIGHT,
INPUT_CLUSTERS: [
Basic.cluster_id,
Identify.cluster_id,
Groups.cluster_id,
Scenes.cluster_id,
OnOff.cluster_id,
BinaryInput.cluster_id,
MANUFACTURER_SPECIFIC_CLUSTER_ID,
],
OUTPUT_CLUSTERS: [
Basic.cluster_id,
Ota.cluster_id,
MANUFACTURER_SPECIFIC_CLUSTER_ID,
],
}
},
}
replacement = {
ENDPOINTS: {
1: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.ON_OFF_LIGHT,
INPUT_CLUSTERS: [
Basic.cluster_id,
Identify.cluster_id,
Groups.cluster_id,
Scenes.cluster_id,
OnOff.cluster_id,
BinaryInput.cluster_id,
LegrandCluster,
],
OUTPUT_CLUSTERS: [
Basic.cluster_id,
Ota.cluster_id,
LegrandCluster,
],
}
}
} | zha-quirks | /zha_quirks-0.0.103-py3-none-any.whl/zhaquirks/legrand/switch.py | switch.py |
import logging
from zigpy.profiles import zha
from zigpy.quirks import CustomDevice
from zigpy.zcl.clusters.general import (
Basic,
Identify,
Ota,
PollControl,
PowerConfiguration,
)
from zigpy.zcl.clusters.measurement import (
IlluminanceMeasurement,
TemperatureMeasurement,
)
from zigpy.zcl.clusters.security import IasZone
from zhaquirks.const import (
DEVICE_TYPE,
ENDPOINTS,
INPUT_CLUSTERS,
MODELS_INFO,
OUTPUT_CLUSTERS,
PROFILE_ID,
)
from zhaquirks.hivehome import HIVEHOME, MotionCluster
_LOGGER = logging.getLogger(__name__)
class MOT003(CustomDevice):
"""hivehome.com MOT003."""
signature = {
# <SimpleDescriptor endpoint=6 profile=260 device_type=1026
# device_version=6
# input_clusters=[0, 1, 3, 32, 1024, 1026, 1280]
# output_clusters=[25]>
MODELS_INFO: [(HIVEHOME, "MOT003")],
ENDPOINTS: {
6: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.IAS_ZONE,
INPUT_CLUSTERS: [
Basic.cluster_id,
PowerConfiguration.cluster_id,
Identify.cluster_id,
PollControl.cluster_id,
TemperatureMeasurement.cluster_id,
IlluminanceMeasurement.cluster_id,
IasZone.cluster_id,
],
OUTPUT_CLUSTERS: [Ota.cluster_id],
}
},
}
replacement = {
ENDPOINTS: {
6: {
INPUT_CLUSTERS: [
Basic.cluster_id,
PowerConfiguration.cluster_id,
Identify.cluster_id,
PollControl.cluster_id,
TemperatureMeasurement.cluster_id,
IlluminanceMeasurement.cluster_id,
MotionCluster,
],
OUTPUT_CLUSTERS: [Ota.cluster_id],
}
}
} | zha-quirks | /zha_quirks-0.0.103-py3-none-any.whl/zhaquirks/hivehome/mot003V6.py | mot003V6.py |
from zigpy.profiles import zgp, zha
from zigpy.quirks import CustomDevice
from zigpy.zcl.clusters.general import (
Basic,
GreenPowerProxy,
Groups,
Identify,
LevelControl,
OnOff,
OnOffConfiguration,
Ota,
Scenes,
)
from zigpy.zcl.clusters.lightlink import LightLink
from zhaquirks.const import (
DEVICE_TYPE,
ENDPOINTS,
INPUT_CLUSTERS,
MODELS_INFO,
OUTPUT_CLUSTERS,
PROFILE_ID,
)
WWAH_CLUSTER_ID = 0xFC57
class NodOnSIN4220(CustomDevice):
"""NodOn on/off switch two channels."""
signature = {
MODELS_INFO: [("NodOn", "SIN-4-2-20")],
ENDPOINTS: {
# <SimpleDescriptor endpoint=1 profile=260 device_type=256
# input_clusters=[0, 3, 4, 5, 6, 7, 8, 4096, 64599]
# output_clusters=[3, 6, 25]>
1: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.ON_OFF_LIGHT,
INPUT_CLUSTERS: [
Basic.cluster_id,
Identify.cluster_id,
Groups.cluster_id,
Scenes.cluster_id,
OnOff.cluster_id,
OnOffConfiguration.cluster_id,
LevelControl.cluster_id,
LightLink.cluster_id,
WWAH_CLUSTER_ID,
],
OUTPUT_CLUSTERS: [
Identify.cluster_id,
OnOff.cluster_id,
Ota.cluster_id,
],
},
# <SimpleDescriptor endpoint=1 profile=260 device_type=256
# input_clusters=[0, 3, 4, 5, 6, 7, 8]
# output_clusters=[3, 6]>
2: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.ON_OFF_LIGHT,
INPUT_CLUSTERS: [
Basic.cluster_id,
Identify.cluster_id,
Groups.cluster_id,
Scenes.cluster_id,
OnOff.cluster_id,
OnOffConfiguration.cluster_id,
LevelControl.cluster_id,
],
OUTPUT_CLUSTERS: [
Identify.cluster_id,
OnOff.cluster_id,
],
},
# <SimpleDescriptor endpoint=242 profile=41440 device_type=102
# input_clusters=[33]
# output_clusters=[33]
242: {
PROFILE_ID: zgp.PROFILE_ID,
DEVICE_TYPE: zgp.DeviceType.COMBO_BASIC,
INPUT_CLUSTERS: [GreenPowerProxy.cluster_id],
OUTPUT_CLUSTERS: [GreenPowerProxy.cluster_id],
},
},
}
replacement = {
ENDPOINTS: {
1: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.ON_OFF_LIGHT,
INPUT_CLUSTERS: [
Basic.cluster_id,
Identify.cluster_id,
Groups.cluster_id,
Scenes.cluster_id,
OnOff.cluster_id,
OnOffConfiguration.cluster_id,
LightLink.cluster_id,
WWAH_CLUSTER_ID,
],
OUTPUT_CLUSTERS: [
Identify.cluster_id,
OnOff.cluster_id,
Ota.cluster_id,
],
},
2: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.ON_OFF_LIGHT,
INPUT_CLUSTERS: [
Basic.cluster_id,
Identify.cluster_id,
Groups.cluster_id,
Scenes.cluster_id,
OnOff.cluster_id,
OnOffConfiguration.cluster_id,
],
OUTPUT_CLUSTERS: [
Identify.cluster_id,
OnOff.cluster_id,
],
},
242: {
PROFILE_ID: zgp.PROFILE_ID,
DEVICE_TYPE: zgp.DeviceType.COMBO_BASIC,
INPUT_CLUSTERS: [GreenPowerProxy.cluster_id],
OUTPUT_CLUSTERS: [GreenPowerProxy.cluster_id],
},
},
} | zha-quirks | /zha_quirks-0.0.103-py3-none-any.whl/zhaquirks/nodon/switch.py | switch.py |
import logging
from zigpy.profiles import zha
from zigpy.quirks import CustomDevice
from zigpy.zcl.clusters.general import (
Basic,
Identify,
Ota,
PollControl,
PowerConfiguration,
)
from zigpy.zcl.clusters.homeautomation import Diagnostic
from zigpy.zcl.clusters.measurement import TemperatureMeasurement
from zigpy.zcl.clusters.security import IasZone
from zhaquirks.const import (
BUTTON,
COMMAND,
COMMAND_BUTTON_DOUBLE,
COMMAND_BUTTON_HOLD,
COMMAND_BUTTON_SINGLE,
DEVICE_TYPE,
DOUBLE_PRESS,
ENDPOINTS,
INPUT_CLUSTERS,
LONG_PRESS,
MODELS_INFO,
OUTPUT_CLUSTERS,
PROFILE_ID,
SHORT_PRESS,
)
from zhaquirks.samjin import SAMJIN, SamjinIASCluster
_LOGGER = logging.getLogger(__name__)
class SamjinButton(CustomDevice):
"""Samjin button device."""
signature = {
# <SimpleDescriptor endpoint=1 profile=260 device_type=1026
# device_version=0
# input_clusters=[0, 1, 3, 32, 1026, 1280, 2821]
# output_clusters=[3, 25]>
MODELS_INFO: [(SAMJIN, BUTTON)],
ENDPOINTS: {
1: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.IAS_ZONE,
INPUT_CLUSTERS: [
Basic.cluster_id,
PowerConfiguration.cluster_id,
Identify.cluster_id,
PollControl.cluster_id,
TemperatureMeasurement.cluster_id,
IasZone.cluster_id,
Diagnostic.cluster_id,
],
OUTPUT_CLUSTERS: [Identify.cluster_id, Ota.cluster_id],
}
},
}
replacement = {
ENDPOINTS: {
1: {
PROFILE_ID: zha.PROFILE_ID,
INPUT_CLUSTERS: [
Basic.cluster_id,
PowerConfiguration.cluster_id,
Identify.cluster_id,
PollControl.cluster_id,
TemperatureMeasurement.cluster_id,
SamjinIASCluster,
Diagnostic.cluster_id,
],
OUTPUT_CLUSTERS: [Identify.cluster_id, Ota.cluster_id],
}
}
}
device_automation_triggers = {
(DOUBLE_PRESS, DOUBLE_PRESS): {COMMAND: COMMAND_BUTTON_DOUBLE},
(SHORT_PRESS, SHORT_PRESS): {COMMAND: COMMAND_BUTTON_SINGLE},
(LONG_PRESS, LONG_PRESS): {COMMAND: COMMAND_BUTTON_HOLD},
} | zha-quirks | /zha_quirks-0.0.103-py3-none-any.whl/zhaquirks/samjin/button.py | button.py |
import logging
from zigpy.profiles import zha
from zigpy.quirks import CustomDevice
from zigpy.zcl.clusters.general import (
Basic,
Identify,
Ota,
PollControl,
PowerConfiguration,
)
from zigpy.zcl.clusters.measurement import TemperatureMeasurement
from zigpy.zcl.clusters.security import IasZone
from zhaquirks.const import (
BUTTON,
COMMAND,
COMMAND_BUTTON_DOUBLE,
COMMAND_BUTTON_HOLD,
COMMAND_BUTTON_SINGLE,
DEVICE_TYPE,
DOUBLE_PRESS,
ENDPOINTS,
INPUT_CLUSTERS,
LONG_PRESS,
MODELS_INFO,
OUTPUT_CLUSTERS,
PROFILE_ID,
SHORT_PRESS,
)
from zhaquirks.samjin import SAMJIN, SamjinIASCluster
_LOGGER = logging.getLogger(__name__)
class SamjinButton(CustomDevice):
"""Samjin button device."""
signature = {
# <SimpleDescriptor endpoint=1 profile=260 device_type=1026
# device_version=0
# input_clusters=[0, 1, 3, 32, 1026, 1280, 2821]
# output_clusters=[3, 25]>
MODELS_INFO: [(SAMJIN, BUTTON)],
ENDPOINTS: {
1: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.IAS_ZONE,
INPUT_CLUSTERS: [
Basic.cluster_id,
PowerConfiguration.cluster_id,
Identify.cluster_id,
PollControl.cluster_id,
TemperatureMeasurement.cluster_id,
IasZone.cluster_id,
],
OUTPUT_CLUSTERS: [Identify.cluster_id, Ota.cluster_id],
}
},
}
replacement = {
ENDPOINTS: {
1: {
PROFILE_ID: zha.PROFILE_ID,
INPUT_CLUSTERS: [
Basic.cluster_id,
PowerConfiguration.cluster_id,
Identify.cluster_id,
PollControl.cluster_id,
TemperatureMeasurement.cluster_id,
SamjinIASCluster,
],
OUTPUT_CLUSTERS: [Identify.cluster_id, Ota.cluster_id],
}
}
}
device_automation_triggers = {
(DOUBLE_PRESS, DOUBLE_PRESS): {COMMAND: COMMAND_BUTTON_DOUBLE},
(SHORT_PRESS, SHORT_PRESS): {COMMAND: COMMAND_BUTTON_SINGLE},
(LONG_PRESS, LONG_PRESS): {COMMAND: COMMAND_BUTTON_HOLD},
} | zha-quirks | /zha_quirks-0.0.103-py3-none-any.whl/zhaquirks/samjin/button2.py | button2.py |
from zigpy.quirks import CustomDevice
from zigpy.zcl.clusters.general import (
Basic,
Identify,
Ota,
PollControl,
PowerConfiguration,
)
from zigpy.zcl.clusters.homeautomation import Diagnostic
from zigpy.zcl.clusters.measurement import TemperatureMeasurement
from zigpy.zcl.clusters.security import IasZone
from zhaquirks.const import (
DEVICE_TYPE,
ENDPOINTS,
INPUT_CLUSTERS,
MODELS_INFO,
OUTPUT_CLUSTERS,
PROFILE_ID,
)
from zhaquirks.samjin import SAMJIN
from zhaquirks.smartthings import SmartThingsAccelCluster
class SmartthingsMultiPurposeSensor2019(CustomDevice):
"""Samjin multi device."""
signature = {
MODELS_INFO: [(SAMJIN, "multi")],
ENDPOINTS: {
# <SimpleDescriptor endpoint=1 profile=260 device_type=1026
# device_version=0 input_clusters=[0, 1, 3, 32, 1026, 1280,
# 2821, 64514]
# output_clusters=[3, 25]>
1: {
PROFILE_ID: 0x0104,
DEVICE_TYPE: 0x0402,
INPUT_CLUSTERS: [
Basic.cluster_id,
PowerConfiguration.cluster_id,
Identify.cluster_id,
PollControl.cluster_id,
TemperatureMeasurement.cluster_id,
IasZone.cluster_id,
Diagnostic.cluster_id,
SmartThingsAccelCluster.cluster_id,
],
OUTPUT_CLUSTERS: [Identify.cluster_id, Ota.cluster_id],
}
},
}
replacement = {
ENDPOINTS: {
1: {
INPUT_CLUSTERS: [
Basic.cluster_id,
PowerConfiguration.cluster_id,
Identify.cluster_id,
PollControl.cluster_id,
TemperatureMeasurement.cluster_id,
IasZone.cluster_id,
Diagnostic.cluster_id,
SmartThingsAccelCluster,
],
OUTPUT_CLUSTERS: [Identify.cluster_id, Ota.cluster_id],
}
}
} | zha-quirks | /zha_quirks-0.0.103-py3-none-any.whl/zhaquirks/samjin/multi2.py | multi2.py |
from zigpy.profiles import zha
from zigpy.quirks import CustomDevice
from zigpy.zcl.clusters.general import (
Basic,
Groups,
Identify,
LevelControl,
OnOff,
Ota,
PowerConfiguration,
)
from zigpy.zcl.clusters.lighting import Color
from zigpy.zcl.clusters.lightlink import LightLink
from zhaquirks.const import (
ARGS,
CLUSTER_ID,
COMMAND,
COMMAND_MOVE,
COMMAND_MOVE_ON_OFF,
COMMAND_RELEASE,
COMMAND_STEP,
COMMAND_STEP_ON_OFF,
COMMAND_TOGGLE,
DEVICE_TYPE,
DIM_DOWN,
DIM_UP,
ENDPOINT_ID,
ENDPOINTS,
INPUT_CLUSTERS,
LONG_PRESS,
MODELS_INFO,
OUTPUT_CLUSTERS,
PARAMS,
PROFILE_ID,
SHORT_PRESS,
TURN_ON,
)
from zhaquirks.lds import MANUFACTURER
class CCTSwitch(CustomDevice):
"""Custom device representing CCTSwitch-D0001 remote control."""
signature = {
# <SimpleDescriptor endpoint = 1 profile = 260 device_type = 2048
# device_version = 1 input_clusters = [0, 1, 3, 4096, 64769]
# output_clusters = [3, 4, 6, 8, 25, 768, 4096] >
MODELS_INFO: [(MANUFACTURER, "ZBT-CCTSwitch-D0001")],
ENDPOINTS: {
1: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.COLOR_CONTROLLER,
INPUT_CLUSTERS: [
Basic.cluster_id,
PowerConfiguration.cluster_id,
Identify.cluster_id,
LightLink.cluster_id,
0xFD01,
],
OUTPUT_CLUSTERS: [
Identify.cluster_id,
Groups.cluster_id,
OnOff.cluster_id,
LevelControl.cluster_id,
Ota.cluster_id,
Color.cluster_id,
LightLink.cluster_id,
],
}
},
}
replacement = {
ENDPOINTS: {
1: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.COLOR_CONTROLLER,
INPUT_CLUSTERS: [
Basic.cluster_id,
PowerConfiguration.cluster_id,
Identify.cluster_id,
LightLink.cluster_id,
0xFD01,
],
OUTPUT_CLUSTERS: [
Identify.cluster_id,
Groups.cluster_id,
OnOff.cluster_id,
LevelControl.cluster_id,
Ota.cluster_id,
Color.cluster_id,
LightLink.cluster_id,
],
}
}
}
device_automation_triggers = {
(SHORT_PRESS, TURN_ON): {
COMMAND: COMMAND_TOGGLE,
CLUSTER_ID: 6,
ENDPOINT_ID: 1,
},
(LONG_PRESS, TURN_ON): {
COMMAND: COMMAND_RELEASE,
CLUSTER_ID: 5,
ENDPOINT_ID: 1,
ARGS: [],
},
(SHORT_PRESS, DIM_UP): {
COMMAND: COMMAND_STEP_ON_OFF,
CLUSTER_ID: 8,
ENDPOINT_ID: 1,
PARAMS: {"step_mode": 0},
},
(LONG_PRESS, DIM_UP): {
COMMAND: COMMAND_MOVE_ON_OFF,
CLUSTER_ID: 8,
ENDPOINT_ID: 1,
PARAMS: {"move_mode": 0},
},
(SHORT_PRESS, DIM_DOWN): {
COMMAND: COMMAND_STEP,
CLUSTER_ID: 8,
ENDPOINT_ID: 1,
PARAMS: {"step_mode": 1},
},
(LONG_PRESS, DIM_DOWN): {
COMMAND: COMMAND_MOVE,
CLUSTER_ID: 8,
ENDPOINT_ID: 1,
PARAMS: {"move_mode": 1},
},
} | zha-quirks | /zha_quirks-0.0.103-py3-none-any.whl/zhaquirks/lds/cctswitch.py | cctswitch.py |
from zigpy.profiles import zll
from zigpy.quirks import CustomDevice
from zigpy.zcl.clusters.general import (
Basic,
Groups,
Identify,
LevelControl,
OnOff,
Scenes,
)
from zigpy.zcl.clusters.lightlink import LightLink
from zhaquirks import GroupBoundCluster
from zhaquirks.const import (
CLUSTER_ID,
COMMAND,
COMMAND_MOVE_TO_LEVEL_ON_OFF,
COMMAND_STEP,
COMMAND_STEP_ON_OFF,
DEVICE_TYPE,
DIM_DOWN,
DIM_UP,
ENDPOINT_ID,
ENDPOINTS,
INPUT_CLUSTERS,
MODELS_INFO,
OUTPUT_CLUSTERS,
PARAMS,
PROFILE_ID,
SHORT_PRESS,
TURN_OFF,
TURN_ON,
)
MANUFACTURER_SPECIFIC_CLUSTER_ID_1 = 0xFF00 # decimal = 65280
MANUFACTURER_SPECIFIC_CLUSTER_ID_2 = 0xFC44 # decimal = 64580
class OnOffGroupCluster(GroupBoundCluster, OnOff):
"""On/Off Cluster which only binds to a group."""
class LevelControlGroupCluster(GroupBoundCluster, LevelControl):
"""Level Control Cluster which only binds to a group."""
class LutronLZL4BWHL01Remote(CustomDevice):
"""Custom device representing Lutron LZL4BWHL01 Remote."""
signature = {
# <SimpleDescriptor endpoint=1 profile=49246 device_type=2080
# device_version=2
# input_clusters=[0, 4096, 65280, 64580]
# output_clusters=[4096, 3, 6, 8, 4, 5, 0, 65280]>
MODELS_INFO: [
("Lutron", "LZL4BWHL01 Remote"),
(" Lutron", "LZL4BWHL01 Remote"),
],
ENDPOINTS: {
1: {
PROFILE_ID: zll.PROFILE_ID,
DEVICE_TYPE: zll.DeviceType.CONTROLLER,
INPUT_CLUSTERS: [
Basic.cluster_id,
LightLink.cluster_id,
MANUFACTURER_SPECIFIC_CLUSTER_ID_1,
MANUFACTURER_SPECIFIC_CLUSTER_ID_2,
],
OUTPUT_CLUSTERS: [
LightLink.cluster_id,
Identify.cluster_id,
OnOff.cluster_id,
LevelControl.cluster_id,
Groups.cluster_id,
Scenes.cluster_id,
Basic.cluster_id,
MANUFACTURER_SPECIFIC_CLUSTER_ID_1,
],
}
},
}
replacement = {
ENDPOINTS: {
1: {
PROFILE_ID: zll.PROFILE_ID,
DEVICE_TYPE: zll.DeviceType.CONTROLLER,
INPUT_CLUSTERS: [
Basic.cluster_id,
LightLink.cluster_id,
MANUFACTURER_SPECIFIC_CLUSTER_ID_1,
MANUFACTURER_SPECIFIC_CLUSTER_ID_2,
],
OUTPUT_CLUSTERS: [
LightLink.cluster_id,
Identify.cluster_id,
OnOffGroupCluster,
LevelControlGroupCluster,
Groups.cluster_id,
Scenes.cluster_id,
Basic.cluster_id,
MANUFACTURER_SPECIFIC_CLUSTER_ID_1,
],
}
}
}
device_automation_triggers = {
(SHORT_PRESS, TURN_ON): {
COMMAND: COMMAND_MOVE_TO_LEVEL_ON_OFF,
CLUSTER_ID: 8,
ENDPOINT_ID: 1,
PARAMS: {"level": 254, "transition_time": 4},
},
(SHORT_PRESS, TURN_OFF): {
COMMAND: COMMAND_MOVE_TO_LEVEL_ON_OFF,
CLUSTER_ID: 8,
ENDPOINT_ID: 1,
PARAMS: {"level": 0, "transition_time": 4},
},
(SHORT_PRESS, DIM_UP): {
COMMAND: COMMAND_STEP_ON_OFF,
CLUSTER_ID: 8,
ENDPOINT_ID: 1,
PARAMS: {"step_mode": 0},
},
(SHORT_PRESS, DIM_DOWN): {
COMMAND: COMMAND_STEP,
CLUSTER_ID: 8,
ENDPOINT_ID: 1,
PARAMS: {"step_mode": 1},
},
} | zha-quirks | /zha_quirks-0.0.103-py3-none-any.whl/zhaquirks/lutron/lzl4bwhl01remote.py | lzl4bwhl01remote.py |
from zigpy.profiles import zha
from zigpy.quirks import CustomDevice
from zigpy.zcl.clusters.general import Basic, Identify, Ota, PollControl
from zigpy.zcl.clusters.homeautomation import Diagnostic
from zigpy.zcl.clusters.measurement import TemperatureMeasurement
from zigpy.zcl.clusters.security import IasZone
from zhaquirks import PowerConfigurationCluster
from zhaquirks.const import (
DEVICE_TYPE,
ENDPOINTS,
INPUT_CLUSTERS,
MODELS_INFO,
OUTPUT_CLUSTERS,
PROFILE_ID,
)
class CustomPowerConfigurationCluster(PowerConfigurationCluster):
"""Custom PowerConfigurationCluster."""
cluster_id = PowerConfigurationCluster.cluster_id
MIN_VOLTS = 2.1
MAX_VOLTS = 3.0
class Ecolink4655BC0R(CustomDevice):
"""Ecolink 4655BC0-R device."""
signature = {
# <SimpleDescriptor endpoint=1 profile=260 device_type=1026
# device_version=0
# input_clusters=[0, 1, 3, 32, 1026, 1280, 2821]
# output_clusters=[25]>
MODELS_INFO: [("Ecolink", "4655BC0-R")],
ENDPOINTS: {
1: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.IAS_ZONE,
INPUT_CLUSTERS: [
Basic.cluster_id,
CustomPowerConfigurationCluster.cluster_id,
Identify.cluster_id,
PollControl.cluster_id,
TemperatureMeasurement.cluster_id,
IasZone.cluster_id,
Diagnostic.cluster_id,
],
OUTPUT_CLUSTERS: [Ota.cluster_id],
}
},
}
replacement = {
ENDPOINTS: {
1: {
PROFILE_ID: zha.PROFILE_ID,
INPUT_CLUSTERS: [
Basic.cluster_id,
CustomPowerConfigurationCluster,
Identify.cluster_id,
PollControl.cluster_id,
TemperatureMeasurement.cluster_id,
IasZone.cluster_id,
Diagnostic.cluster_id,
],
OUTPUT_CLUSTERS: [Ota.cluster_id],
}
}
} | zha-quirks | /zha_quirks-0.0.103-py3-none-any.whl/zhaquirks/ecolink/contact.py | contact.py |
from typing import Any, List, Optional, Union
from zigpy.profiles import zha
from zigpy.quirks import CustomDevice
import zigpy.types as t
from zigpy.zcl import foundation
from zigpy.zcl.clusters.general import (
Basic,
Groups,
Identify,
LevelControl,
OnOff,
Ota,
PowerConfiguration,
Scenes,
)
from zigpy.zcl.clusters.homeautomation import Diagnostic
from zigpy.zcl.clusters.lighting import Color
from zigpy.zcl.clusters.lightlink import LightLink
from zhaquirks import Bus, EventableCluster
from zhaquirks.const import (
ARGS,
BUTTON_1,
BUTTON_2,
BUTTON_3,
BUTTON_4,
CLUSTER_ID,
COMMAND,
COMMAND_OFF,
COMMAND_ON,
COMMAND_STEP,
COMMAND_STEP_COLOR_TEMP,
COMMAND_STEP_HUE,
COMMAND_STEP_SATURATION,
DEVICE_TYPE,
DIM_DOWN,
DIM_UP,
ENDPOINT_ID,
ENDPOINTS,
INPUT_CLUSTERS,
MODELS_INFO,
OUTPUT_CLUSTERS,
PARAMS,
PROFILE_ID,
SHORT_PRESS,
TURN_OFF,
TURN_ON,
ZHA_SEND_EVENT,
)
COLOR_UP = "color_up"
COLOR_DOWN = "color_down"
SATURATION_UP = "saturation_up"
SATURATION_DOWN = "saturation_down"
HUE_LEFT = "hue_left"
HUE_RIGHT = "hue_right"
MANUFACTURER_SPECIFIC_CLUSTER_ID = 0xFE00 # decimal = 65024
SCENE_NO_GROUP = 0x0000
class AdeoManufacturerCluster(EventableCluster):
"""Custom manufacturer cluster (used for preset buttons 1-4)."""
cluster_id = MANUFACTURER_SPECIFIC_CLUSTER_ID
name = "AdeoManufacturerCluster"
ep_attribute = "adeo_manufacturer_cluster"
client_commands = {
0x00: foundation.ZCLCommandDef(
"preset",
{"param1": t.uint8_t, "param2": t.uint8_t},
direction=foundation.Direction.Server_to_Client,
is_manufacturer_specific=True,
)
}
def handle_cluster_request(
self,
hdr: foundation.ZCLHeader,
args: List[Any],
*,
dst_addressing: Optional[
Union[t.Addressing.Group, t.Addressing.IEEE, t.Addressing.NWK]
] = None,
):
"""Handle the cluster command."""
if hdr.command_id == 0x0000:
self.endpoint.device.scenes_bus.listener_event(
"listener_event", ZHA_SEND_EVENT, "view", [SCENE_NO_GROUP, args[0]]
)
else:
super().handle_cluster_request(hdr, args, dst_addressing=dst_addressing)
class AdeoScenesCluster(Scenes, EventableCluster):
"""Scenes cluster to map preset buttons to the "view" command."""
cluster_id = Scenes.cluster_id
def __init__(self, *args, **kwargs):
"""Init."""
super().__init__(*args, **kwargs)
self.endpoint.device.scenes_bus.add_listener(self)
class AdeoColorController(CustomDevice):
"""Custom device representing ADEO color controller."""
def __init__(self, *args, **kwargs):
"""Init."""
self.scenes_bus = Bus()
super().__init__(*args, **kwargs)
signature = {
# <SimpleDescriptor endpoint=1 profile=260 device_type=2048
# device_version=1
# input_clusters=[0, 1, 3, 2821, 4096, 64769]
# output_clusters=[3, 4, 6, 8, 25, 768, 4096]>
MODELS_INFO: [("ADEO", "LXEK-5"), ("ADEO", "ZBEK-26")],
ENDPOINTS: {
1: {
PROFILE_ID: zha.PROFILE_ID, # 260
DEVICE_TYPE: zha.DeviceType.COLOR_CONTROLLER, # 2048
INPUT_CLUSTERS: [
Basic.cluster_id, # 0
PowerConfiguration.cluster_id, # 1
Identify.cluster_id, # 3
Diagnostic.cluster_id, # 2821
LightLink.cluster_id, # 4096
0xFD01, # 64769
],
OUTPUT_CLUSTERS: [
Identify.cluster_id, # 3
Groups.cluster_id, # 4
OnOff.cluster_id, # 6
LevelControl.cluster_id, # 8
Ota.cluster_id, # 25
Color.cluster_id, # 768
LightLink.cluster_id, # 4096
],
}
},
}
replacement = {
ENDPOINTS: {
1: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.COLOR_CONTROLLER,
INPUT_CLUSTERS: [
Basic.cluster_id, # 0
PowerConfiguration.cluster_id, # 1
Identify.cluster_id, # 3
Diagnostic.cluster_id, # 2821
LightLink.cluster_id, # 4096
0xFD01, # 64769
],
OUTPUT_CLUSTERS: [
Identify.cluster_id, # 3
Groups.cluster_id, # 4
AdeoScenesCluster, # 5
OnOff.cluster_id, # 6
LevelControl.cluster_id, # 8
Ota.cluster_id, # 25
Color.cluster_id, # 768
LightLink.cluster_id, # 4096
AdeoManufacturerCluster, # 65024
],
}
},
}
device_automation_triggers = {
(SHORT_PRESS, TURN_ON): {
COMMAND: COMMAND_ON,
CLUSTER_ID: 6, # OnOff.cluster_id
ENDPOINT_ID: 1,
ARGS: [],
},
(SHORT_PRESS, TURN_OFF): {
COMMAND: COMMAND_OFF,
CLUSTER_ID: 6, # OnOff.cluster_id
ENDPOINT_ID: 1,
ARGS: [],
},
(SHORT_PRESS, DIM_UP): {
COMMAND: COMMAND_STEP,
CLUSTER_ID: 8, # LevelControl.cluster_id
ENDPOINT_ID: 1,
PARAMS: {"step_mode": 0},
},
(SHORT_PRESS, DIM_DOWN): {
COMMAND: COMMAND_STEP,
CLUSTER_ID: 8, # LevelControl.cluster_id
ENDPOINT_ID: 1,
PARAMS: {"step_mode": 1},
},
(SHORT_PRESS, COLOR_UP): {
COMMAND: COMMAND_STEP_COLOR_TEMP,
CLUSTER_ID: 768, # Color.cluster_id
ENDPOINT_ID: 1,
PARAMS: {
"step_mode": 3,
"step_size": 22,
"transition_time": 5,
"color_temp_min_mireds": 153,
"color_temp_max_mireds": 370,
},
},
(SHORT_PRESS, COLOR_DOWN): {
COMMAND: COMMAND_STEP_COLOR_TEMP,
CLUSTER_ID: 768, # Color.cluster_id
ENDPOINT_ID: 1,
PARAMS: {
"step_mode": 1,
"step_size": 22,
"transition_time": 5,
"color_temp_min_mireds": 153,
"color_temp_max_mireds": 370,
},
},
(SHORT_PRESS, SATURATION_UP): {
COMMAND: COMMAND_STEP_SATURATION,
CLUSTER_ID: 768, # Color.cluster_id
ENDPOINT_ID: 1,
PARAMS: {"step_mode": 1},
},
(SHORT_PRESS, SATURATION_DOWN): {
COMMAND: COMMAND_STEP_SATURATION,
CLUSTER_ID: 768, # Color.cluster_id
ENDPOINT_ID: 1,
PARAMS: {"step_mode": 3},
},
(SHORT_PRESS, HUE_LEFT): {
COMMAND: COMMAND_STEP_HUE,
CLUSTER_ID: 768, # Color.cluster_id
ENDPOINT_ID: 1,
PARAMS: {"step_mode": 3},
},
(SHORT_PRESS, HUE_RIGHT): {
COMMAND: COMMAND_STEP_HUE,
CLUSTER_ID: 768, # Color.cluster_id
ENDPOINT_ID: 1,
PARAMS: {"step_mode": 1},
},
(SHORT_PRESS, BUTTON_1): {
COMMAND: "view",
CLUSTER_ID: 5, # Scenes.cluster_id
ENDPOINT_ID: 1,
ARGS: [0, 0xA],
},
(SHORT_PRESS, BUTTON_2): {
COMMAND: "view",
CLUSTER_ID: 5, # Scenes.cluster_id
ENDPOINT_ID: 1,
ARGS: [0, 0xB],
},
(SHORT_PRESS, BUTTON_3): {
COMMAND: "view",
CLUSTER_ID: 5, # Scenes.cluster_id
ENDPOINT_ID: 1,
ARGS: [0, 0xC],
},
(SHORT_PRESS, BUTTON_4): {
COMMAND: "view",
CLUSTER_ID: 5, # Scenes.cluster_id
ENDPOINT_ID: 1,
ARGS: [0, 0xD],
},
} | zha-quirks | /zha_quirks-0.0.103-py3-none-any.whl/zhaquirks/adeo/color_controller.py | color_controller.py |
from __future__ import annotations
from zigpy.profiles import zha
from zigpy.quirks import CustomCluster, CustomDevice
from zigpy.zcl.clusters.general import (
Basic,
Groups,
Identify,
LevelControl,
OnOff,
Ota,
Scenes,
)
from zigpy.zcl.clusters.hvac import Fan
from zhaquirks import NoReplyMixin
from zhaquirks.const import (
DEVICE_TYPE,
ENDPOINTS,
INPUT_CLUSTERS,
MANUFACTURER,
OUTPUT_CLUSTERS,
PROFILE_ID,
)
class KofBasic(NoReplyMixin, CustomCluster, Basic):
"""KOF Basic Cluster."""
void_input_commands = {
Basic.commands_by_name["reset_fact_default"].id,
}
class KofIdentify(NoReplyMixin, CustomCluster, Identify):
"""KOF Identify Cluster."""
void_input_commands = {
Identify.commands_by_name["identify"].id,
Identify.commands_by_name["trigger_effect"].id,
}
class KofGroups(NoReplyMixin, CustomCluster, Groups):
"""KOF Group Cluster."""
# Remove All Groups, Add Group If Identifying
void_input_commands = {
Groups.commands_by_name["remove_all"].id,
Groups.commands_by_name["add_if_identifying"].id,
}
class KofScenes(NoReplyMixin, CustomCluster, Scenes):
"""KOF Scene Cluster."""
void_input_commands = {Scenes.commands_by_name["recall"].id}
class KofOnOff(NoReplyMixin, CustomCluster, OnOff):
"""KOF On Off Cluster."""
void_input_commands = {cmd.id for cmd in OnOff.commands_by_name.values()}
class KofLevelControl(NoReplyMixin, CustomCluster, LevelControl):
"""KOF Level Control Cluster."""
void_input_commands = {cmd.id for cmd in LevelControl.commands_by_name.values()}
class CeilingFan(CustomDevice):
"""Ceiling Fan Device."""
signature = {
ENDPOINTS: {
1: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: 14,
INPUT_CLUSTERS: [
Basic.cluster_id,
Identify.cluster_id,
Groups.cluster_id,
Scenes.cluster_id,
OnOff.cluster_id,
LevelControl.cluster_id,
Fan.cluster_id,
],
OUTPUT_CLUSTERS: [Identify.cluster_id, Ota.cluster_id],
}
},
MANUFACTURER: "King Of Fans, Inc.",
}
replacement = {
ENDPOINTS: {
1: {
DEVICE_TYPE: zha.DeviceType.DIMMABLE_LIGHT,
INPUT_CLUSTERS: [
KofBasic,
KofIdentify,
KofGroups,
KofScenes,
KofOnOff,
KofLevelControl,
Fan,
],
OUTPUT_CLUSTERS: [Identify, Ota],
}
}
} | zha-quirks | /zha_quirks-0.0.103-py3-none-any.whl/zhaquirks/kof/kof_mr101z.py | kof_mr101z.py |
from zigpy.profiles import zha
from zigpy.quirks import CustomDevice
from zigpy.zcl.clusters.general import Basic, LevelControl, MultistateInput, OnOff, Ota
from zhaquirks import CustomCluster, PowerConfigurationCluster
from zhaquirks.const import (
COMMAND,
COMMAND_DOUBLE,
COMMAND_HOLD,
COMMAND_RELEASE,
COMMAND_SINGLE,
DEVICE_TYPE,
DOUBLE_PRESS,
ENDPOINTS,
INPUT_CLUSTERS,
LONG_PRESS,
LONG_RELEASE,
MODELS_INFO,
OUTPUT_CLUSTERS,
PROFILE_ID,
SHORT_PRESS,
SKIP_CONFIGURATION,
VALUE,
ZHA_SEND_EVENT,
)
from zhaquirks.thirdreality import THIRD_REALITY
class CustomPowerConfigurationCluster(PowerConfigurationCluster):
"""Custom PowerConfigurationCluster."""
cluster_id = PowerConfigurationCluster.cluster_id
MIN_VOLTS = 2.1
MAX_VOLTS = 3.0
MOVEMENT_TYPE = {
0: COMMAND_HOLD,
1: COMMAND_SINGLE,
2: COMMAND_DOUBLE,
255: COMMAND_RELEASE,
}
class MultistateInputCluster(CustomCluster, MultistateInput):
"""Multistate input cluster."""
cluster_id = MultistateInput.cluster_id
def __init__(self, *args, **kwargs):
"""Init."""
self._current_state = {}
super().__init__(*args, **kwargs)
def _update_attribute(self, attrid, value):
super()._update_attribute(attrid, value)
if attrid == 0x0055:
self._current_state[0x0055] = action = MOVEMENT_TYPE.get(value)
event_args = {VALUE: value}
if action is not None:
self.listener_event(ZHA_SEND_EVENT, action, event_args)
# show something in the sensor in HA
super()._update_attribute(0, action)
class Button(CustomDevice):
"""thirdreality button device - alternate version."""
signature = {
MODELS_INFO: [(THIRD_REALITY, "3RSB22BZ")],
ENDPOINTS: {
1: {
PROFILE_ID: 0x0104,
DEVICE_TYPE: 0x0006,
INPUT_CLUSTERS: [
Basic.cluster_id,
MultistateInput.cluster_id,
CustomPowerConfigurationCluster.cluster_id,
],
OUTPUT_CLUSTERS: [
OnOff.cluster_id,
LevelControl.cluster_id,
Ota.cluster_id,
],
}
},
}
replacement = {
SKIP_CONFIGURATION: True,
ENDPOINTS: {
1: {
DEVICE_TYPE: zha.DeviceType.REMOTE_CONTROL,
INPUT_CLUSTERS: [
Basic.cluster_id,
CustomPowerConfigurationCluster,
MultistateInputCluster,
],
OUTPUT_CLUSTERS: [
OnOff.cluster_id,
LevelControl.cluster_id,
Ota.cluster_id,
],
}
},
}
device_automation_triggers = {
(DOUBLE_PRESS, DOUBLE_PRESS): {COMMAND: COMMAND_DOUBLE},
(SHORT_PRESS, SHORT_PRESS): {COMMAND: COMMAND_SINGLE},
(LONG_PRESS, LONG_PRESS): {COMMAND: COMMAND_HOLD},
(LONG_RELEASE, LONG_RELEASE): {COMMAND: COMMAND_HOLD},
} | zha-quirks | /zha_quirks-0.0.103-py3-none-any.whl/zhaquirks/thirdreality/button.py | button.py |
from zigpy.profiles import zha
from zigpy.quirks import CustomCluster, CustomDevice
from zigpy.zcl.clusters.general import (
Basic,
Groups,
Identify,
LevelControl,
MultistateInput,
OnOff,
Ota,
Scenes,
)
from zigpy.zcl.clusters.lighting import Color
from zigpy.zcl.clusters.lightlink import LightLink
from zigpy.zcl.clusters.measurement import IlluminanceMeasurement
from zigpy.zcl.clusters.security import IasZone
from zhaquirks import LocalDataCluster
from zhaquirks.const import (
DEVICE_TYPE,
ENDPOINTS,
INPUT_CLUSTERS,
MODELS_INFO,
OUTPUT_CLUSTERS,
PROFILE_ID,
)
from zhaquirks.thirdreality import THIRD_REALITY
THIRD_REALITY_CLUSTER_ID = 0xFC00
THIRD_REALITY_MOTION_EVENT_ATTR_ID = 0x0002
class ThirdRealitySpecificCluster(CustomCluster):
"""Manufacturer specific cluster to relay motion event to IAS Zone cluster."""
cluster_id = THIRD_REALITY_CLUSTER_ID
def _update_attribute(self, attrid, value):
super()._update_attribute(attrid, value)
if attrid == THIRD_REALITY_MOTION_EVENT_ATTR_ID:
self.endpoint.ias_zone.update_attribute(
IasZone.AttributeDefs.zone_status.id, value
)
class LocalIasZone(LocalDataCluster, IasZone):
"""Local IAS Zone cluster."""
_CONSTANT_ATTRIBUTES = {
IasZone.AttributeDefs.zone_type.id: IasZone.ZoneType.Motion_Sensor
}
class Nightlight(CustomDevice):
"""Custom device for 3RSNL02043Z."""
signature = {
MODELS_INFO: [(THIRD_REALITY, "3RSNL02043Z")],
ENDPOINTS: {
1: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.COLOR_DIMMABLE_LIGHT,
INPUT_CLUSTERS: [
Basic.cluster_id,
Identify.cluster_id,
Groups.cluster_id,
Scenes.cluster_id,
OnOff.cluster_id,
LevelControl.cluster_id,
MultistateInput.cluster_id,
Color.cluster_id,
IlluminanceMeasurement.cluster_id,
LightLink.cluster_id,
ThirdRealitySpecificCluster.cluster_id,
],
OUTPUT_CLUSTERS: [
Ota.cluster_id,
],
}
},
}
replacement = {
ENDPOINTS: {
1: {
DEVICE_TYPE: zha.DeviceType.COLOR_DIMMABLE_LIGHT,
INPUT_CLUSTERS: [
Basic.cluster_id,
Identify.cluster_id,
Groups.cluster_id,
Scenes.cluster_id,
OnOff.cluster_id,
LevelControl.cluster_id,
MultistateInput.cluster_id,
Color.cluster_id,
IlluminanceMeasurement.cluster_id,
LightLink.cluster_id,
LocalIasZone,
ThirdRealitySpecificCluster,
],
OUTPUT_CLUSTERS: [
Ota.cluster_id,
],
}
}
} | zha-quirks | /zha_quirks-0.0.103-py3-none-any.whl/zhaquirks/thirdreality/night_light.py | night_light.py |
from zigpy.profiles import zha
from zigpy.quirks import CustomDevice
from zigpy.zcl.clusters.general import Basic, Groups, Identify, OnOff, Ota, Scenes
from zigpy.zcl.clusters.homeautomation import Diagnostic
from zhaquirks import PowerConfigurationCluster
from zhaquirks.const import (
DEVICE_TYPE,
ENDPOINTS,
INPUT_CLUSTERS,
MODELS_INFO,
OUTPUT_CLUSTERS,
PROFILE_ID,
)
from zhaquirks.thirdreality import THIRD_REALITY
class CustomPowerConfigurationCluster(PowerConfigurationCluster):
"""Custom PowerConfigurationCluster."""
cluster_id = PowerConfigurationCluster.cluster_id
MIN_VOLTS = 2.1
MAX_VOLTS = 3.0
class Switch(CustomDevice):
"""3RSS008Z device."""
signature = {
# <SimpleDescriptor endpoint=1 profile=260
# device_type=2 device_version=1
# input_clusters=[0, 4, 3, 6, 5, 25, 1]
# output_clusters=[1]>
MODELS_INFO: [(THIRD_REALITY, "3RSS007Z"), (THIRD_REALITY, "3RSS008Z")],
ENDPOINTS: {
1: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.ON_OFF_OUTPUT,
INPUT_CLUSTERS: [
Basic.cluster_id,
Identify.cluster_id,
Groups.cluster_id,
Scenes.cluster_id,
OnOff.cluster_id,
Ota.cluster_id,
CustomPowerConfigurationCluster.cluster_id,
],
OUTPUT_CLUSTERS: [CustomPowerConfigurationCluster.cluster_id],
}
},
}
replacement = {
ENDPOINTS: {
1: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.ON_OFF_OUTPUT,
INPUT_CLUSTERS: [
Basic.cluster_id,
Identify.cluster_id,
Groups.cluster_id,
Scenes.cluster_id,
OnOff.cluster_id,
Ota.cluster_id,
CustomPowerConfigurationCluster,
],
OUTPUT_CLUSTERS: [CustomPowerConfigurationCluster.cluster_id],
}
}
}
class SwitchPlus(Switch):
"""RealitySwitch Plus (3RSS008Z) device."""
signature = {
# <SimpleDescriptor endpoint=1 profile=260
# device_type=2 device_version=1
# input_clusters=[0, 4, 3, 6, 5, 1, 2821]
# output_clusters=[25]>
MODELS_INFO: [(THIRD_REALITY, "3RSS008Z")],
ENDPOINTS: {
1: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.ON_OFF_OUTPUT,
INPUT_CLUSTERS: [
Basic.cluster_id,
Identify.cluster_id,
Groups.cluster_id,
Scenes.cluster_id,
OnOff.cluster_id,
Diagnostic.cluster_id,
CustomPowerConfigurationCluster.cluster_id,
],
OUTPUT_CLUSTERS: [Ota.cluster_id],
}
},
}
replacement = {
ENDPOINTS: {
1: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.ON_OFF_OUTPUT,
INPUT_CLUSTERS: [
Basic.cluster_id,
Identify.cluster_id,
Groups.cluster_id,
Scenes.cluster_id,
OnOff.cluster_id,
Diagnostic.cluster_id,
CustomPowerConfigurationCluster,
],
OUTPUT_CLUSTERS: [Ota.cluster_id],
}
}
} | zha-quirks | /zha_quirks-0.0.103-py3-none-any.whl/zhaquirks/thirdreality/switch.py | switch.py |
from zigpy.profiles import zha
from zigpy.profiles.zha import DeviceType
from zigpy.quirks import CustomDevice
from zigpy.zcl.clusters.general import Basic, Groups, Identify, LevelControl, OnOff
from zigpy.zcl.clusters.lightlink import LightLink
from zhaquirks.const import (
CLUSTER_ID,
COMMAND,
COMMAND_OFF,
COMMAND_ON,
COMMAND_STEP,
DEVICE_TYPE,
DIM_DOWN,
DIM_UP,
ENDPOINT_ID,
ENDPOINTS,
INPUT_CLUSTERS,
MODELS_INFO,
OUTPUT_CLUSTERS,
PARAMS,
PROFILE_ID,
SHORT_PRESS,
TURN_OFF,
TURN_ON,
)
ADUROLIGHT_CLUSTER_ID = 64716
class AdurolightNCC(CustomDevice):
"""ADUROLIGHT Adurolight_NCC device."""
signature = {
# <SimpleDescriptor endpoint=1 profile=260 device_type=2080
# device_version=2
# input_clusters=[0, 3, 8, 4096, 64716]
# output_clusters=[3, 4, 6, 8, 4096, 64716]>
MODELS_INFO: [("ADUROLIGHT", "Adurolight_NCC")],
ENDPOINTS: {
1: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: DeviceType.NON_COLOR_CONTROLLER,
INPUT_CLUSTERS: [
Basic.cluster_id,
Identify.cluster_id,
LevelControl.cluster_id,
LightLink.cluster_id,
ADUROLIGHT_CLUSTER_ID,
],
OUTPUT_CLUSTERS: [
Identify.cluster_id,
Groups.cluster_id,
OnOff.cluster_id,
LevelControl.cluster_id,
LightLink.cluster_id,
ADUROLIGHT_CLUSTER_ID,
],
}
},
}
replacement = {
ENDPOINTS: {
1: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: DeviceType.NON_COLOR_CONTROLLER,
INPUT_CLUSTERS: [
Basic.cluster_id,
Identify.cluster_id,
LightLink.cluster_id,
ADUROLIGHT_CLUSTER_ID,
],
OUTPUT_CLUSTERS: [
Identify.cluster_id,
Groups.cluster_id,
OnOff.cluster_id,
LevelControl.cluster_id,
LightLink.cluster_id,
ADUROLIGHT_CLUSTER_ID,
],
}
}
}
device_automation_triggers = {
(SHORT_PRESS, TURN_ON): {COMMAND: COMMAND_ON, CLUSTER_ID: 6, ENDPOINT_ID: 1},
(SHORT_PRESS, TURN_OFF): {COMMAND: COMMAND_OFF, CLUSTER_ID: 6, ENDPOINT_ID: 1},
(SHORT_PRESS, DIM_UP): {
COMMAND: COMMAND_STEP,
CLUSTER_ID: 8,
ENDPOINT_ID: 1,
PARAMS: {"step_mode": 0},
},
(SHORT_PRESS, DIM_DOWN): {
COMMAND: COMMAND_STEP,
CLUSTER_ID: 8,
ENDPOINT_ID: 1,
PARAMS: {"step_mode": 1},
},
} | zha-quirks | /zha_quirks-0.0.103-py3-none-any.whl/zhaquirks/aduro/adurolightncc.py | adurolightncc.py |
import logging
from zigpy.profiles import zha
from zigpy.quirks import CustomDevice
from zigpy.zcl.clusters.general import Basic, BinaryInput, Identify, Ota, PollControl
from zhaquirks import Bus, LocalDataCluster, PowerConfigurationCluster
from zhaquirks.const import (
DEVICE_TYPE,
ENDPOINTS,
INPUT_CLUSTERS,
OUTPUT_CLUSTERS,
PROFILE_ID,
)
_LOGGER = logging.getLogger(__name__)
ARRIVAL_SENSOR_DEVICE_TYPE = 0x8000
class FastPollingPowerConfigurationCluster(PowerConfigurationCluster):
"""FastPollingPowerConfigurationCluster."""
cluster_id = PowerConfigurationCluster.cluster_id
FREQUENCY = 45
MINIMUM_CHANGE = 1
async def configure_reporting(
self,
attribute,
min_interval,
max_interval,
reportable_change,
manufacturer=None,
):
"""Configure reporting."""
result = await super().configure_reporting(
PowerConfigurationCluster.BATTERY_VOLTAGE_ATTR,
self.FREQUENCY,
self.FREQUENCY,
self.MINIMUM_CHANGE,
)
return result
def _update_attribute(self, attrid, value):
self.endpoint.device.tracking_bus.listener_event(
"update_tracking", attrid, value
)
super()._update_attribute(attrid, value)
# stealing this for tracking alerts
class TrackingCluster(LocalDataCluster, BinaryInput):
"""Tracking cluster."""
cluster_id = BinaryInput.cluster_id
def __init__(self, *args, **kwargs):
"""Init."""
super().__init__(*args, **kwargs)
self.endpoint.device.tracking_bus.add_listener(self)
def update_tracking(self, attrid, value):
"""Update tracking info."""
# prevent unbounded null entries from going into zigbee.db
self._update_attribute(0, 1)
class SmartThingsTagV4(CustomDevice):
"""Custom device representing smartthings tagV4 sensors."""
def __init__(self, *args, **kwargs):
"""Init."""
self.tracking_bus = Bus()
super().__init__(*args, **kwargs)
signature = {
# <SimpleDescriptor endpoint=1 profile=260 device_type=12
# device_version=0
# input_clusters=[0, 1, 3, 15, 32]
# output_clusters=[3, 25]>
ENDPOINTS: {
1: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.SIMPLE_SENSOR,
INPUT_CLUSTERS: [
Basic.cluster_id,
FastPollingPowerConfigurationCluster.cluster_id,
Identify.cluster_id,
PollControl.cluster_id,
TrackingCluster.cluster_id,
],
OUTPUT_CLUSTERS: [Identify.cluster_id, Ota.cluster_id],
}
}
}
replacement = {
ENDPOINTS: {
1: {
DEVICE_TYPE: ARRIVAL_SENSOR_DEVICE_TYPE,
INPUT_CLUSTERS: [
Basic.cluster_id,
FastPollingPowerConfigurationCluster,
Identify.cluster_id,
PollControl.cluster_id,
TrackingCluster,
],
OUTPUT_CLUSTERS: [Identify.cluster_id, Ota.cluster_id],
}
}
} | zha-quirks | /zha_quirks-0.0.103-py3-none-any.whl/zhaquirks/smartthings/tag_v4.py | tag_v4.py |
from zigpy.profiles import zha
from zigpy.quirks import CustomCluster, CustomDevice
from zigpy.zcl.clusters.general import Basic, BinaryInput, Identify, Ota, PollControl
from zigpy.zcl.clusters.measurement import TemperatureMeasurement
from zigpy.zcl.clusters.security import IasZone
from zhaquirks import PowerConfigurationCluster
from zhaquirks.const import (
DEVICE_TYPE,
ENDPOINTS,
INPUT_CLUSTERS,
MODELS_INFO,
OUTPUT_CLUSTERS,
PROFILE_ID,
ZONE_TYPE,
)
from zhaquirks.smartthings import SMART_THINGS
class CustomIasZone(CustomCluster, IasZone):
"""Custom IasZone cluster."""
_CONSTANT_ATTRIBUTES = {ZONE_TYPE: IasZone.ZoneType.Water_Sensor}
class SmartThingsMoistureV4(CustomDevice):
"""SmartThingsMoistureV4."""
signature = {
# <SimpleDescriptor endpoint=1 profile=260 device_type=1026
# device_version=0
# input_clusters=[0, 1, 3, 15, 1026, 1280, 32]
# output_clusters=[25]>
MODELS_INFO: [(SMART_THINGS, "moisturev4")],
ENDPOINTS: {
1: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.IAS_ZONE,
INPUT_CLUSTERS: [
Basic.cluster_id,
PowerConfigurationCluster.cluster_id,
Identify.cluster_id,
BinaryInput.cluster_id,
PollControl.cluster_id,
TemperatureMeasurement.cluster_id,
IasZone.cluster_id,
],
OUTPUT_CLUSTERS: [Ota.cluster_id],
}
},
}
replacement = {
ENDPOINTS: {
1: {
INPUT_CLUSTERS: [
Basic.cluster_id,
PowerConfigurationCluster,
Identify.cluster_id,
BinaryInput.cluster_id,
PollControl.cluster_id,
TemperatureMeasurement.cluster_id,
CustomIasZone,
],
OUTPUT_CLUSTERS: [Ota.cluster_id],
}
}
} | zha-quirks | /zha_quirks-0.0.103-py3-none-any.whl/zhaquirks/smartthings/moisturev4.py | moisturev4.py |
from zigpy.profiles import zha
from zigpy.quirks import CustomDevice
from zigpy.zcl.clusters.general import Basic, BinaryInput, Identify, Ota, PollControl
from zigpy.zcl.clusters.measurement import TemperatureMeasurement
from zigpy.zcl.clusters.security import IasZone
from zhaquirks import PowerConfigurationCluster
from zhaquirks.centralite import CentraLiteAccelCluster
from zhaquirks.const import (
DEVICE_TYPE,
ENDPOINTS,
INPUT_CLUSTERS,
MODELS_INFO,
OUTPUT_CLUSTERS,
PROFILE_ID,
)
from zhaquirks.smartthings import SMART_THINGS
class SmartThingsMultiV4(CustomDevice):
"""SmartThingsMultiV4."""
signature = {
# <SimpleDescriptor endpoint=1 profile=260 device_type=1026
# device_version=0
# input_clusters=[0, 1, 3, 15, 32, 1026, 1280, 64514]
# output_clusters=[25]>
MODELS_INFO: [(SMART_THINGS, "multiv4")],
ENDPOINTS: {
1: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.IAS_ZONE,
INPUT_CLUSTERS: [
Basic.cluster_id,
PowerConfigurationCluster.cluster_id,
Identify.cluster_id,
BinaryInput.cluster_id,
PollControl.cluster_id,
TemperatureMeasurement.cluster_id,
IasZone.cluster_id,
CentraLiteAccelCluster.cluster_id,
],
OUTPUT_CLUSTERS: [Ota.cluster_id],
}
},
}
replacement = {
ENDPOINTS: {
1: {
INPUT_CLUSTERS: [
Basic.cluster_id,
PowerConfigurationCluster,
Identify.cluster_id,
BinaryInput.cluster_id,
PollControl.cluster_id,
TemperatureMeasurement.cluster_id,
IasZone.cluster_id,
CentraLiteAccelCluster,
],
OUTPUT_CLUSTERS: [Ota.cluster_id],
}
}
} | zha-quirks | /zha_quirks-0.0.103-py3-none-any.whl/zhaquirks/smartthings/multiv4.py | multiv4.py |
import logging
from typing import Any, List, Optional, Union
from zigpy.profiles import zgp, zha
from zigpy.quirks import CustomCluster, CustomDevice
import zigpy.types as t
from zigpy.zcl import foundation
from zigpy.zcl.clusters.closures import WindowCovering
from zigpy.zcl.clusters.general import (
Basic,
GreenPowerProxy,
Groups,
Identify,
LevelControl,
OnOff,
Scenes,
)
from zigpy.zcl.clusters.lighting import Color
from zhaquirks.const import (
BUTTON,
BUTTON_1,
BUTTON_2,
BUTTON_3,
BUTTON_4,
COMMAND,
DEVICE_TYPE,
DOUBLE_PRESS,
ENDPOINTS,
INPUT_CLUSTERS,
LONG_PRESS,
LONG_RELEASE,
MODELS_INFO,
OUTPUT_CLUSTERS,
PRESS_TYPE,
PROFILE_ID,
SHORT_PRESS,
ZHA_SEND_EVENT,
)
_LOGGER = logging.getLogger(__name__)
# Siglis zigfred specific clusters
SIGLIS_MANUFACTURER_CODE = 0x129C
ZIGFRED_CLUSTER_ID = 0xFC42
ZIGFRED_CLUSTER_BUTTONS_ATTRIBUTE_ID = 0x0008
ZIGFRED_CLUSTER_COMMAND_BUTTON_EVENT = 0x02
# Siglis zigfred cluster implementation
class ZigfredCluster(CustomCluster):
"""Siglis manufacturer specific cluster for zigfred."""
name = "Siglis Manufacturer Specific"
cluster_id = ZIGFRED_CLUSTER_ID
buttons_attribute_id = ZIGFRED_CLUSTER_BUTTONS_ATTRIBUTE_ID
server_commands = {
ZIGFRED_CLUSTER_COMMAND_BUTTON_EVENT: foundation.ZCLCommandDef(
"button_event",
{"param1": t.uint32_t},
direction=foundation.Direction.Server_to_Client,
is_manufacturer_specific=True,
),
}
def _process_button_event(self, value: t.uint32_t):
button_lookup = {
0: BUTTON_1,
1: BUTTON_2,
2: BUTTON_3,
3: BUTTON_4,
}
press_type_lookup = {
0: LONG_RELEASE,
1: SHORT_PRESS,
2: DOUBLE_PRESS,
3: LONG_PRESS,
}
button = value & 0xFF
press_type = (value >> 8) & 0xFF
button = button_lookup[button]
press_type = press_type_lookup[press_type]
action = f"{button}_{press_type}"
event_args = {
BUTTON: button,
PRESS_TYPE: press_type,
}
_LOGGER.info(f"Got button press on zigfred cluster: {action}")
if button and press_type:
self.listener_event(ZHA_SEND_EVENT, action, event_args)
def handle_cluster_request(
self,
hdr: foundation.ZCLHeader,
args: List[Any],
*,
dst_addressing: Optional[
Union[t.Addressing.Group, t.Addressing.IEEE, t.Addressing.NWK]
] = None,
) -> None:
"""Handle cluster specific commands."""
if hdr.command_id == ZIGFRED_CLUSTER_COMMAND_BUTTON_EVENT:
self._process_button_event(args[0])
class ZigfredUno(CustomDevice):
"""zigfred uno device handler."""
def __init__(self, *args, **kwargs):
"""Init."""
_LOGGER.info("Initializing zigfred uno")
super().__init__(*args, **kwargs)
signature = {
MODELS_INFO: [("Siglis", "zigfred uno")],
ENDPOINTS: {
5: {
# Front Module LED
# SizePrefixedSimpleDescriptor(endpoint=5,
# profile=260, device_type=258,
# device_version=1,
# input_clusters=[0, 3, 4, 5, 6, 8, 768, 837],
# output_clusters=[])
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.COLOR_DIMMABLE_LIGHT,
INPUT_CLUSTERS: [
Basic.cluster_id,
Identify.cluster_id,
Groups.cluster_id,
Scenes.cluster_id,
OnOff.cluster_id,
LevelControl.cluster_id,
Color.cluster_id,
ZigfredCluster.cluster_id,
],
OUTPUT_CLUSTERS: [],
},
6: {
# Relay
# SizePrefixedSimpleDescriptor(endpoint=6,
# profile=260, device_type=256,
# device_version=1,
# input_clusters=[0, 3, 4, 5, 6],
# output_clusters=[])
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.ON_OFF_LIGHT,
INPUT_CLUSTERS: [
Basic.cluster_id,
Identify.cluster_id,
Groups.cluster_id,
Scenes.cluster_id,
OnOff.cluster_id,
],
OUTPUT_CLUSTERS: [],
},
7: {
# Relay
# SizePrefixedSimpleDescriptor(endpoint=7,
# profile=260, device_type=257,
# device_version=1,
# input_clusters=[0, 3, 5, 4, 6, 8],
# output_clusters=[])
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.DIMMABLE_LIGHT,
INPUT_CLUSTERS: [
Basic.cluster_id,
Identify.cluster_id,
Groups.cluster_id,
Scenes.cluster_id,
OnOff.cluster_id,
LevelControl.cluster_id,
],
OUTPUT_CLUSTERS: [],
},
242: {
# SizePrefixedSimpleDescriptor(endpoint=242,
# profile=41440, device_type=97,
# device_version=0,
# input_clusters=[],
# output_clusters=[33])
PROFILE_ID: zgp.PROFILE_ID,
DEVICE_TYPE: zgp.DeviceType.PROXY_BASIC,
INPUT_CLUSTERS: [],
OUTPUT_CLUSTERS: [GreenPowerProxy.cluster_id],
},
},
}
replacement = {
ENDPOINTS: {
5: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.COLOR_DIMMABLE_LIGHT,
INPUT_CLUSTERS: [
Basic.cluster_id,
Identify.cluster_id,
Groups.cluster_id,
Scenes.cluster_id,
OnOff.cluster_id,
LevelControl.cluster_id,
Color.cluster_id,
ZigfredCluster,
],
OUTPUT_CLUSTERS: [],
},
6: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.ON_OFF_LIGHT,
INPUT_CLUSTERS: [
Basic.cluster_id,
Identify.cluster_id,
Groups.cluster_id,
Scenes.cluster_id,
OnOff.cluster_id,
],
},
7: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.DIMMABLE_LIGHT,
INPUT_CLUSTERS: [
Basic.cluster_id,
Identify.cluster_id,
Groups.cluster_id,
Scenes.cluster_id,
OnOff.cluster_id,
LevelControl.cluster_id,
],
},
242: {
PROFILE_ID: zgp.PROFILE_ID,
DEVICE_TYPE: zgp.DeviceType.PROXY_BASIC,
INPUT_CLUSTERS: [],
OUTPUT_CLUSTERS: [GreenPowerProxy.cluster_id],
},
},
}
device_automation_triggers = {
(SHORT_PRESS, BUTTON_1): {COMMAND: f"{BUTTON_1}_{SHORT_PRESS}"},
(SHORT_PRESS, BUTTON_2): {COMMAND: f"{BUTTON_2}_{SHORT_PRESS}"},
(SHORT_PRESS, BUTTON_3): {COMMAND: f"{BUTTON_3}_{SHORT_PRESS}"},
(SHORT_PRESS, BUTTON_4): {COMMAND: f"{BUTTON_4}_{SHORT_PRESS}"},
(DOUBLE_PRESS, BUTTON_1): {COMMAND: f"{BUTTON_1}_{DOUBLE_PRESS}"},
(DOUBLE_PRESS, BUTTON_2): {COMMAND: f"{BUTTON_2}_{DOUBLE_PRESS}"},
(DOUBLE_PRESS, BUTTON_3): {COMMAND: f"{BUTTON_3}_{DOUBLE_PRESS}"},
(DOUBLE_PRESS, BUTTON_4): {COMMAND: f"{BUTTON_4}_{DOUBLE_PRESS}"},
(LONG_PRESS, BUTTON_1): {COMMAND: f"{BUTTON_1}_{LONG_PRESS}"},
(LONG_PRESS, BUTTON_2): {COMMAND: f"{BUTTON_2}_{LONG_PRESS}"},
(LONG_PRESS, BUTTON_3): {COMMAND: f"{BUTTON_3}_{LONG_PRESS}"},
(LONG_PRESS, BUTTON_4): {COMMAND: f"{BUTTON_4}_{LONG_PRESS}"},
(LONG_RELEASE, BUTTON_1): {COMMAND: f"{BUTTON_1}_{LONG_RELEASE}"},
(LONG_RELEASE, BUTTON_2): {COMMAND: f"{BUTTON_2}_{LONG_RELEASE}"},
(LONG_RELEASE, BUTTON_3): {COMMAND: f"{BUTTON_3}_{LONG_RELEASE}"},
(LONG_RELEASE, BUTTON_4): {COMMAND: f"{BUTTON_4}_{LONG_RELEASE}"},
}
class ZigfredPlus(CustomDevice):
"""zigfred plus device handler."""
def __init__(self, *args, **kwargs):
"""Init."""
_LOGGER.info("Initializing zigfred plus")
super().__init__(*args, **kwargs)
signature = {
MODELS_INFO: [("Siglis", "zigfred plus")],
ENDPOINTS: {
5: {
# Front Module LED
# SizePrefixedSimpleDescriptor(endpoint=5,
# profile=260, device_type=258,
# device_version=1,
# input_clusters=[0, 3, 4, 5, 6, 8, 768, 837],
# output_clusters=[])
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.COLOR_DIMMABLE_LIGHT,
INPUT_CLUSTERS: [
Basic.cluster_id,
Identify.cluster_id,
Groups.cluster_id,
Scenes.cluster_id,
OnOff.cluster_id,
LevelControl.cluster_id,
Color.cluster_id,
ZigfredCluster.cluster_id,
],
OUTPUT_CLUSTERS: [],
},
7: {
# Dimmable Light 1
# SizePrefixedSimpleDescriptor(endpoint=7,
# profile=260, device_type=257,
# device_version=1,
# input_clusters=[0, 3, 5, 4, 6, 8],
# output_clusters=[])
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.DIMMABLE_LIGHT,
INPUT_CLUSTERS: [
Basic.cluster_id,
Identify.cluster_id,
Groups.cluster_id,
Scenes.cluster_id,
OnOff.cluster_id,
LevelControl.cluster_id,
],
OUTPUT_CLUSTERS: [],
},
8: {
# Dimmable Light 2
# SizePrefixedSimpleDescriptor(endpoint=8,
# profile=260, device_type=257,
# device_version=1,
# input_clusters=[0, 3, 5, 4, 6, 8],
# output_clusters=[])
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.DIMMABLE_LIGHT,
INPUT_CLUSTERS: [
Basic.cluster_id,
Identify.cluster_id,
Groups.cluster_id,
Scenes.cluster_id,
OnOff.cluster_id,
LevelControl.cluster_id,
],
OUTPUT_CLUSTERS: [],
},
9: {
# Dimmable Light 3
# SizePrefixedSimpleDescriptor(endpoint=9,
# profile=260, device_type=257,
# device_version=1,
# input_clusters=[0, 3, 5, 4, 6, 8],
# output_clusters=[])
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.DIMMABLE_LIGHT,
INPUT_CLUSTERS: [
Basic.cluster_id,
Identify.cluster_id,
Groups.cluster_id,
Scenes.cluster_id,
OnOff.cluster_id,
LevelControl.cluster_id,
],
OUTPUT_CLUSTERS: [],
},
10: {
# Dimmable Light 4
# SizePrefixedSimpleDescriptor(endpoint=10,
# profile=260, device_type=257,
# device_version=1,
# input_clusters=[0, 3, 5, 4, 6, 8],
# output_clusters=[])
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.DIMMABLE_LIGHT,
INPUT_CLUSTERS: [
Basic.cluster_id,
Identify.cluster_id,
Groups.cluster_id,
Scenes.cluster_id,
OnOff.cluster_id,
LevelControl.cluster_id,
],
OUTPUT_CLUSTERS: [],
},
11: {
# Window Cover 1
# SizePrefixedSimpleDescriptor(endpoint=11,
# profile=260, device_type=514,
# device_version=1,
# input_clusters=[0, 3, 5, 4, 258],
# output_clusters=[])
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.WINDOW_COVERING_DEVICE,
INPUT_CLUSTERS: [
Basic.cluster_id,
Identify.cluster_id,
Groups.cluster_id,
Scenes.cluster_id,
WindowCovering.cluster_id,
],
OUTPUT_CLUSTERS: [],
},
12: {
# Window Cover 1
# SizePrefixedSimpleDescriptor(endpoint=12,
# profile=260, device_type=514,
# device_version=1,
# input_clusters=[0, 3, 5, 4, 258],
# output_clusters=[])
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.WINDOW_COVERING_DEVICE,
INPUT_CLUSTERS: [
Basic.cluster_id,
Identify.cluster_id,
Groups.cluster_id,
Scenes.cluster_id,
WindowCovering.cluster_id,
],
OUTPUT_CLUSTERS: [],
},
242: {
# SizePrefixedSimpleDescriptor(endpoint=242,
# profile=41440, device_type=97,
# device_version=0,
# input_clusters=[],
# output_clusters=[33])
PROFILE_ID: zgp.PROFILE_ID,
DEVICE_TYPE: zgp.DeviceType.PROXY_BASIC,
INPUT_CLUSTERS: [],
OUTPUT_CLUSTERS: [GreenPowerProxy.cluster_id],
},
},
}
replacement = {
ENDPOINTS: {
5: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.COLOR_DIMMABLE_LIGHT,
INPUT_CLUSTERS: [
Basic.cluster_id,
Identify.cluster_id,
Groups.cluster_id,
Scenes.cluster_id,
OnOff.cluster_id,
LevelControl.cluster_id,
Color.cluster_id,
ZigfredCluster,
],
OUTPUT_CLUSTERS: [],
},
7: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.DIMMABLE_LIGHT,
INPUT_CLUSTERS: [
Basic.cluster_id,
Identify.cluster_id,
Groups.cluster_id,
Scenes.cluster_id,
OnOff.cluster_id,
LevelControl.cluster_id,
],
},
8: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.DIMMABLE_LIGHT,
INPUT_CLUSTERS: [
Basic.cluster_id,
Identify.cluster_id,
Groups.cluster_id,
Scenes.cluster_id,
OnOff.cluster_id,
LevelControl.cluster_id,
],
},
9: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.DIMMABLE_LIGHT,
INPUT_CLUSTERS: [
Basic.cluster_id,
Identify.cluster_id,
Groups.cluster_id,
Scenes.cluster_id,
OnOff.cluster_id,
LevelControl.cluster_id,
],
},
10: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.DIMMABLE_LIGHT,
INPUT_CLUSTERS: [
Basic.cluster_id,
Identify.cluster_id,
Groups.cluster_id,
Scenes.cluster_id,
OnOff.cluster_id,
LevelControl.cluster_id,
],
},
11: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.WINDOW_COVERING_DEVICE,
INPUT_CLUSTERS: [
Basic.cluster_id,
Identify.cluster_id,
Groups.cluster_id,
Scenes.cluster_id,
WindowCovering.cluster_id,
],
},
12: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.WINDOW_COVERING_DEVICE,
INPUT_CLUSTERS: [
Basic.cluster_id,
Identify.cluster_id,
Groups.cluster_id,
Scenes.cluster_id,
WindowCovering.cluster_id,
],
},
242: {
PROFILE_ID: zgp.PROFILE_ID,
DEVICE_TYPE: zgp.DeviceType.PROXY_BASIC,
INPUT_CLUSTERS: [],
OUTPUT_CLUSTERS: [GreenPowerProxy.cluster_id],
},
},
}
device_automation_triggers = {
(SHORT_PRESS, BUTTON_1): {COMMAND: f"{BUTTON_1}_{SHORT_PRESS}"},
(SHORT_PRESS, BUTTON_2): {COMMAND: f"{BUTTON_2}_{SHORT_PRESS}"},
(SHORT_PRESS, BUTTON_3): {COMMAND: f"{BUTTON_3}_{SHORT_PRESS}"},
(SHORT_PRESS, BUTTON_4): {COMMAND: f"{BUTTON_4}_{SHORT_PRESS}"},
(DOUBLE_PRESS, BUTTON_1): {COMMAND: f"{BUTTON_1}_{DOUBLE_PRESS}"},
(DOUBLE_PRESS, BUTTON_2): {COMMAND: f"{BUTTON_2}_{DOUBLE_PRESS}"},
(DOUBLE_PRESS, BUTTON_3): {COMMAND: f"{BUTTON_3}_{DOUBLE_PRESS}"},
(DOUBLE_PRESS, BUTTON_4): {COMMAND: f"{BUTTON_4}_{DOUBLE_PRESS}"},
(LONG_PRESS, BUTTON_1): {COMMAND: f"{BUTTON_1}_{LONG_PRESS}"},
(LONG_PRESS, BUTTON_2): {COMMAND: f"{BUTTON_2}_{LONG_PRESS}"},
(LONG_PRESS, BUTTON_3): {COMMAND: f"{BUTTON_3}_{LONG_PRESS}"},
(LONG_PRESS, BUTTON_4): {COMMAND: f"{BUTTON_4}_{LONG_PRESS}"},
(LONG_RELEASE, BUTTON_1): {COMMAND: f"{BUTTON_1}_{LONG_RELEASE}"},
(LONG_RELEASE, BUTTON_2): {COMMAND: f"{BUTTON_2}_{LONG_RELEASE}"},
(LONG_RELEASE, BUTTON_3): {COMMAND: f"{BUTTON_3}_{LONG_RELEASE}"},
(LONG_RELEASE, BUTTON_4): {COMMAND: f"{BUTTON_4}_{LONG_RELEASE}"},
} | zha-quirks | /zha_quirks-0.0.103-py3-none-any.whl/zhaquirks/siglis/zigfred.py | zigfred.py |
from zigpy.profiles import zha
from zigpy.profiles.zha import DeviceType
from zigpy.quirks import CustomCluster, CustomDevice
from zigpy.zcl.clusters.general import (
Basic,
Groups,
Identify,
Ota,
PollControl,
PowerConfiguration,
Scenes,
)
from zigpy.zcl.clusters.measurement import (
PressureMeasurement,
RelativeHumidity,
TemperatureMeasurement,
)
from zhaquirks.const import (
DEVICE_TYPE,
ENDPOINTS,
INPUT_CLUSTERS,
MODELS_INFO,
OUTPUT_CLUSTERS,
PROFILE_ID,
)
from zhaquirks.xiaomi import LUMI
class PressureMeasurementCluster(CustomCluster, PressureMeasurement):
"""Custom cluster representing Keen Home's pressure measurement."""
cluster_id = PressureMeasurement.cluster_id
KEEN_MEASURED_VALUE_ATTR = 0x0020
MEASURED_VALUE_ATTR = 0x0000
def _update_attribute(self, attrid, value):
super()._update_attribute(attrid, value)
if attrid == self.KEEN_MEASURED_VALUE_ATTR:
value = value / 1000.0
super()._update_attribute(self.MEASURED_VALUE_ATTR, value)
class TemperatureHumidtyPressureSensor(CustomDevice):
"""Keen Home temperature/humidity/pressure sensor."""
signature = {
# <SimpleDescriptor endpoint=1 profile=260 device_type=770
# device_version=1
# input_clusters=[0, 3, 1, 32]
# output_clusters=[0, 4, 3, 5, 25, 1026, 1029, 1027, 32]>
MODELS_INFO: [(LUMI, "RS-THP-MP-1.0")],
ENDPOINTS: {
1: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: DeviceType.TEMPERATURE_SENSOR,
INPUT_CLUSTERS: [
Basic.cluster_id,
Identify.cluster_id,
PowerConfiguration.cluster_id,
PollControl.cluster_id,
],
OUTPUT_CLUSTERS: [
Basic.cluster_id,
Groups.cluster_id,
Identify.cluster_id,
Scenes.cluster_id,
Ota.cluster_id,
TemperatureMeasurement.cluster_id,
RelativeHumidity.cluster_id,
PressureMeasurement.cluster_id,
PollControl.cluster_id,
],
}
},
}
replacement = {
ENDPOINTS: {
1: {
INPUT_CLUSTERS: [
Basic.cluster_id,
Identify.cluster_id,
PowerConfiguration.cluster_id,
RelativeHumidity.cluster_id,
TemperatureMeasurement.cluster_id,
PollControl.cluster_id,
PressureMeasurementCluster,
],
OUTPUT_CLUSTERS: [Basic.cluster_id, Groups.cluster_id],
}
}
} | zha-quirks | /zha_quirks-0.0.103-py3-none-any.whl/zhaquirks/keenhome/weather.py | weather.py |
from zigpy.profiles import zha
from zigpy.quirks import CustomDevice
from zigpy.zcl.clusters.general import (
Basic,
Groups,
Identify,
LevelControl,
OnOff,
Ota,
PollControl,
Scenes,
)
from zigpy.zcl.clusters.homeautomation import Diagnostic
from zigpy.zcl.clusters.measurement import PressureMeasurement, TemperatureMeasurement
from zhaquirks import DoublingPowerConfigurationCluster
from zhaquirks.const import (
DEVICE_TYPE,
ENDPOINTS,
INPUT_CLUSTERS,
MODELS_INFO,
OUTPUT_CLUSTERS,
PROFILE_ID,
)
KEEN1_CLUSTER_ID = 0xFC01 # decimal = 64513
KEEN2_CLUSTER_ID = 0xFC02 # decimal = 64514
class KeenHomeSmartVent(CustomDevice):
"""Custom device representing Keen Home Smart Vent."""
signature = {
# <SimpleDescriptor endpoint=1 profile=260 device_type=3
# device_version=0
# input_clusters=[
# 0, 1, 3, 4, 5, 6, 8, 32, 1026, 1027, 2821, 64513, 64514]
# output_clusters=[25]>
MODELS_INFO: [
("Keen Home Inc", "SV01-410-MP-1.0"),
("Keen Home Inc", "SV01-410-MP-1.1"),
("Keen Home Inc", "SV01-410-MP-1.4"),
("Keen Home Inc", "SV01-410-MP-1.5"),
("Keen Home Inc", "SV02-410-MP-1.3"),
("Keen Home Inc", "SV01-412-MP-1.0"),
("Keen Home Inc", "SV01-610-MP-1.0"),
("Keen Home Inc", "SV02-610-MP-1.3"),
("Keen Home Inc", "SV01-612-MP-1.0"),
("Keen Home Inc", "SV02-612-MP-1.3"),
],
ENDPOINTS: {
1: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.LEVEL_CONTROLLABLE_OUTPUT,
INPUT_CLUSTERS: [
Basic.cluster_id,
DoublingPowerConfigurationCluster.cluster_id,
Identify.cluster_id,
Groups.cluster_id,
Scenes.cluster_id,
OnOff.cluster_id,
LevelControl.cluster_id,
PollControl.cluster_id,
TemperatureMeasurement.cluster_id,
PressureMeasurement.cluster_id,
Diagnostic.cluster_id,
KEEN1_CLUSTER_ID,
KEEN2_CLUSTER_ID,
],
OUTPUT_CLUSTERS: [Ota.cluster_id],
}
},
}
replacement = {
ENDPOINTS: {
1: {
PROFILE_ID: zha.PROFILE_ID,
INPUT_CLUSTERS: [
Basic.cluster_id,
DoublingPowerConfigurationCluster,
Identify.cluster_id,
Groups.cluster_id,
Scenes.cluster_id,
OnOff.cluster_id,
LevelControl.cluster_id,
PollControl.cluster_id,
TemperatureMeasurement.cluster_id,
PressureMeasurement.cluster_id,
Diagnostic.cluster_id,
KEEN1_CLUSTER_ID,
KEEN2_CLUSTER_ID,
],
OUTPUT_CLUSTERS: [Ota.cluster_id],
}
}
} | zha-quirks | /zha_quirks-0.0.103-py3-none-any.whl/zhaquirks/keenhome/sv02612mp13.py | sv02612mp13.py |
from zigpy.profiles import zha
from zigpy.quirks import CustomDevice
from zigpy.zcl.clusters.general import (
Basic,
Groups,
Identify,
LevelControl,
OnOff,
Ota,
PollControl,
PowerConfiguration,
Scenes,
)
from zigpy.zcl.clusters.lightlink import LightLink
from zhaquirks.const import (
CLUSTER_ID,
COMMAND,
COMMAND_MOVE,
COMMAND_STEP,
COMMAND_STOP,
COMMAND_TOGGLE,
DEVICE_TYPE,
DOUBLE_PRESS,
ENDPOINT_ID,
ENDPOINTS,
INPUT_CLUSTERS,
LEFT,
MODELS_INFO,
OUTPUT_CLUSTERS,
PARAMS,
PROFILE_ID,
RIGHT,
ROTATED,
SHORT_PRESS,
STOP,
TRIPLE_PRESS,
TURN_ON,
)
from zhaquirks.ikea import IKEA, IKEA_CLUSTER_ID, DoublingPowerConfig1CRCluster
class IkeaSYMFONISK1(CustomDevice):
"""Custom device representing IKEA of Sweden TRADFRI remote control."""
signature = {
# <SimpleDescriptor endpoint=1 profile=260 device_type=6
# device_version=1
# input_clusters=[0, 1, 3, 32, 4096]
# output_clusters=[3, 4, 6, 8, 25, 4096]>
MODELS_INFO: [(IKEA, "SYMFONISK Sound Controller")],
ENDPOINTS: {
1: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.REMOTE_CONTROL,
INPUT_CLUSTERS: [
Basic.cluster_id,
PowerConfiguration.cluster_id,
Identify.cluster_id,
PollControl.cluster_id,
LightLink.cluster_id,
],
OUTPUT_CLUSTERS: [
Identify.cluster_id,
Groups.cluster_id,
OnOff.cluster_id,
LevelControl.cluster_id,
Ota.cluster_id,
LightLink.cluster_id,
],
}
},
}
replacement = {
ENDPOINTS: {
1: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.REMOTE_CONTROL,
INPUT_CLUSTERS: [
Basic.cluster_id,
DoublingPowerConfig1CRCluster,
Identify.cluster_id,
PollControl.cluster_id,
LightLink.cluster_id,
],
OUTPUT_CLUSTERS: [
Identify.cluster_id,
Groups.cluster_id,
OnOff.cluster_id,
LevelControl.cluster_id,
Ota.cluster_id,
LightLink.cluster_id,
],
}
}
}
device_automation_triggers = {
(SHORT_PRESS, TURN_ON): {
COMMAND: COMMAND_TOGGLE,
CLUSTER_ID: 6,
ENDPOINT_ID: 1,
},
(ROTATED, RIGHT): {
COMMAND: COMMAND_MOVE,
CLUSTER_ID: 8,
ENDPOINT_ID: 1,
PARAMS: {"move_mode": 0},
},
(ROTATED, LEFT): {
COMMAND: COMMAND_MOVE,
CLUSTER_ID: 8,
ENDPOINT_ID: 1,
PARAMS: {"move_mode": 1},
},
(ROTATED, STOP): {
COMMAND: COMMAND_STOP,
CLUSTER_ID: 8,
ENDPOINT_ID: 1,
},
(DOUBLE_PRESS, TURN_ON): {
COMMAND: COMMAND_STEP,
CLUSTER_ID: 8,
ENDPOINT_ID: 1,
PARAMS: {"step_mode": 0},
},
(TRIPLE_PRESS, TURN_ON): {
COMMAND: COMMAND_STEP,
CLUSTER_ID: 8,
ENDPOINT_ID: 1,
PARAMS: {"step_mode": 1},
},
}
class IkeaSYMFONISK2(CustomDevice):
"""Custom device representing IKEA of Sweden TRADFRI remote control."""
signature = {
# <SimpleDescriptor endpoint=1 profile=260 device_type=6
# device_version=1
# input_clusters=[0, 1, 3, 32, 4096 64636]
# output_clusters=[3, 4, 5, 6, 8, 25, 4096,]>
MODELS_INFO: [(IKEA, "SYMFONISK Sound Controller")],
ENDPOINTS: {
1: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.REMOTE_CONTROL,
INPUT_CLUSTERS: [
Basic.cluster_id,
PowerConfiguration.cluster_id,
Identify.cluster_id,
PollControl.cluster_id,
LightLink.cluster_id,
IKEA_CLUSTER_ID,
],
OUTPUT_CLUSTERS: [
Identify.cluster_id,
Groups.cluster_id,
Scenes.cluster_id,
OnOff.cluster_id,
LevelControl.cluster_id,
Ota.cluster_id,
LightLink.cluster_id,
],
}
},
}
replacement = {
ENDPOINTS: {
1: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.REMOTE_CONTROL,
INPUT_CLUSTERS: [
Basic.cluster_id,
DoublingPowerConfig1CRCluster,
Identify.cluster_id,
PollControl.cluster_id,
LightLink.cluster_id,
IKEA_CLUSTER_ID,
],
OUTPUT_CLUSTERS: [
Identify.cluster_id,
Groups.cluster_id,
Scenes.cluster_id,
OnOff.cluster_id,
LevelControl.cluster_id,
Ota.cluster_id,
LightLink.cluster_id,
],
}
}
}
device_automation_triggers = IkeaSYMFONISK1.device_automation_triggers.copy() | zha-quirks | /zha_quirks-0.0.103-py3-none-any.whl/zhaquirks/ikea/symfonisk.py | symfonisk.py |
from typing import Any, List, Optional, Union
from zigpy.profiles import zha
from zigpy.quirks import CustomCluster, CustomDevice
import zigpy.types as t
from zigpy.zcl import foundation
from zigpy.zcl.clusters.closures import WindowCovering
from zigpy.zcl.clusters.general import (
Alarms,
Basic,
Groups,
Identify,
LevelControl,
OnOff,
Ota,
PollControl,
PowerConfiguration,
)
from zigpy.zcl.clusters.lightlink import LightLink
from zhaquirks.const import (
ARGS,
CLOSE,
COMMAND,
COMMAND_STOP,
DEVICE_TYPE,
ENDPOINTS,
INPUT_CLUSTERS,
LONG_RELEASE,
MODELS_INFO,
OPEN,
OUTPUT_CLUSTERS,
PROFILE_ID,
SHORT_PRESS,
ZHA_SEND_EVENT,
)
from zhaquirks.ikea import IKEA, IKEA_CLUSTER_ID, DoublingPowerConfig1CRCluster
COMMAND_CLOSE = "down_close"
COMMAND_STOP_OPENING = "stop_opening"
COMMAND_STOP_CLOSING = "stop_closing"
COMMAND_OPEN = "up_open"
class IkeaWindowCovering(CustomCluster, WindowCovering):
"""Ikea Window covering cluster."""
def __init__(self, *args, **kwargs):
"""Initialize instance."""
super().__init__(*args, **kwargs)
self._is_closing = None
def handle_cluster_request(
self,
hdr: foundation.ZCLHeader,
args: List[Any],
*,
dst_addressing: Optional[
Union[t.Addressing.Group, t.Addressing.IEEE, t.Addressing.NWK]
] = None,
) -> None:
"""Handle cluster specific commands.
We just want to keep track of direction, to associate it with the stop command.
"""
cmd_name = self.server_commands[hdr.command_id].name
if cmd_name == COMMAND_OPEN:
self._is_closing = False
elif cmd_name == COMMAND_CLOSE:
self._is_closing = True
elif cmd_name == COMMAND_STOP:
action = COMMAND_STOP_CLOSING if self._is_closing else COMMAND_STOP_OPENING
self.listener_event(ZHA_SEND_EVENT, action, [])
class IkeaTradfriOpenCloseRemote(CustomDevice):
"""Custom device representing IKEA of Sweden TRADFRI remote control."""
signature = {
# <SimpleDescriptor endpoint=1 profile=260 device_type=515
# device_version=1
# input_clusters=[0, 1, 3, 9, 32, 4096, 64636]
# output_clusters=[3, 4, 6, 8, 25, 258, 4096]>
MODELS_INFO: [
("\x02KE", "TRADFRI open/close remote"),
(IKEA, "TRADFRI open/close remote"),
],
ENDPOINTS: {
1: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.WINDOW_COVERING_CONTROLLER,
INPUT_CLUSTERS: [
Basic.cluster_id,
PowerConfiguration.cluster_id,
Identify.cluster_id,
Alarms.cluster_id,
PollControl.cluster_id,
LightLink.cluster_id,
IKEA_CLUSTER_ID,
],
OUTPUT_CLUSTERS: [
Identify.cluster_id,
Groups.cluster_id,
OnOff.cluster_id,
LevelControl.cluster_id,
Ota.cluster_id,
WindowCovering.cluster_id,
LightLink.cluster_id,
],
}
},
}
replacement = {
ENDPOINTS: {
1: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.WINDOW_COVERING_CONTROLLER,
INPUT_CLUSTERS: [
Basic.cluster_id,
DoublingPowerConfig1CRCluster,
Identify.cluster_id,
Alarms.cluster_id,
PollControl.cluster_id,
LightLink.cluster_id,
IKEA_CLUSTER_ID,
],
OUTPUT_CLUSTERS: [
Identify.cluster_id,
Groups.cluster_id,
LevelControl.cluster_id,
Ota.cluster_id,
IkeaWindowCovering,
LightLink.cluster_id,
],
}
},
}
device_automation_triggers = {
(SHORT_PRESS, OPEN): {COMMAND: COMMAND_OPEN, ARGS: []},
(LONG_RELEASE, OPEN): {COMMAND: COMMAND_STOP_OPENING, ARGS: []},
(SHORT_PRESS, CLOSE): {COMMAND: COMMAND_CLOSE, ARGS: []},
(LONG_RELEASE, CLOSE): {COMMAND: COMMAND_STOP_CLOSING, ARGS: []},
} | zha-quirks | /zha_quirks-0.0.103-py3-none-any.whl/zhaquirks/ikea/opencloseremote.py | opencloseremote.py |
from zigpy.profiles import zha
from zigpy.quirks import CustomDevice
from zigpy.zcl.clusters.closures import WindowCovering
from zigpy.zcl.clusters.general import (
Basic,
Groups,
Identify,
Ota,
PollControl,
PowerConfiguration,
Scenes,
)
from zigpy.zcl.clusters.lightlink import LightLink
from zhaquirks import DoublingPowerConfigurationCluster
from zhaquirks.const import (
DEVICE_TYPE,
ENDPOINTS,
INPUT_CLUSTERS,
MODELS_INFO,
OUTPUT_CLUSTERS,
PROFILE_ID,
)
from zhaquirks.ikea import IKEA, IKEA_CLUSTER_ID
class IkeaTradfriRollerBlinds(CustomDevice):
"""Custom device representing IKEA of Sweden TRADFRI Fyrtur blinds."""
signature = {
# <SimpleDescriptor endpoint=1 profile=260 device_type=514
# device_version=1
# input_clusters=[0, 1, 3, 4, 5, 32, 258, 4096, 64636]
# output_clusters=[25, 4096]>
MODELS_INFO: [
(IKEA, "FYRTUR block-out roller blind"),
(IKEA, "KADRILJ roller blind"),
(IKEA, "TREDANSEN block-out cellul blind"),
(IKEA, "PRAKTLYSING cellular blind"),
],
ENDPOINTS: {
1: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.WINDOW_COVERING_DEVICE,
INPUT_CLUSTERS: [
Basic.cluster_id,
PowerConfiguration.cluster_id,
Identify.cluster_id,
Groups.cluster_id,
Scenes.cluster_id,
PollControl.cluster_id,
WindowCovering.cluster_id,
LightLink.cluster_id,
IKEA_CLUSTER_ID,
],
OUTPUT_CLUSTERS: [Ota.cluster_id, LightLink.cluster_id],
}
},
}
replacement = {
ENDPOINTS: {
1: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.WINDOW_COVERING_DEVICE,
INPUT_CLUSTERS: [
Basic.cluster_id,
DoublingPowerConfigurationCluster,
Identify.cluster_id,
Groups.cluster_id,
Scenes.cluster_id,
PollControl.cluster_id,
WindowCovering.cluster_id,
LightLink.cluster_id,
IKEA_CLUSTER_ID,
],
OUTPUT_CLUSTERS: [Ota.cluster_id, LightLink.cluster_id],
}
}
}
class IkeaTradfriRollerBlinds2(CustomDevice):
"""Custom device representing IKEA of Sweden TRADFRI Fyrtur blinds."""
signature = {
# <SimpleDescriptor endpoint=1 profile=260 device_type=514
# device_version=1
# input_clusters=[0, 1, 3, 4, 5, 32, 258, 4096]
# output_clusters=[25, 4096]>
MODELS_INFO: [
(IKEA, "FYRTUR block-out roller blind"),
(IKEA, "KADRILJ roller blind"),
],
ENDPOINTS: {
1: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.WINDOW_COVERING_DEVICE,
INPUT_CLUSTERS: [
Basic.cluster_id,
PowerConfiguration.cluster_id,
Identify.cluster_id,
Groups.cluster_id,
Scenes.cluster_id,
PollControl.cluster_id,
WindowCovering.cluster_id,
LightLink.cluster_id,
],
OUTPUT_CLUSTERS: [Ota.cluster_id, LightLink.cluster_id],
}
},
}
replacement = IkeaTradfriRollerBlinds.replacement | zha-quirks | /zha_quirks-0.0.103-py3-none-any.whl/zhaquirks/ikea/blinds.py | blinds.py |
from zigpy.profiles import zha
from zigpy.quirks import CustomDevice
from zigpy.zcl.clusters.general import (
Basic,
Groups,
Identify,
LevelControl,
OnOff,
Ota,
PollControl,
PowerConfiguration,
)
from zigpy.zcl.clusters.lightlink import LightLink
from zhaquirks.const import (
BUTTON_1,
BUTTON_2,
CLUSTER_ID,
COMMAND,
COMMAND_M_INITIAL_PRESS,
COMMAND_M_LONG_PRESS,
COMMAND_M_LONG_RELEASE,
COMMAND_M_MULTI_PRESS_COMPLETE,
COMMAND_M_SHORT_RELEASE,
COMMAND_MOVE,
COMMAND_MOVE_ON_OFF,
COMMAND_STEP,
COMMAND_TOGGLE,
DEVICE_TYPE,
DIM_DOWN,
DIM_UP,
DOUBLE_PRESS,
ENDPOINT_ID,
ENDPOINTS,
INPUT_CLUSTERS,
LEFT,
LONG_PRESS,
LONG_RELEASE,
MODELS_INFO,
OUTPUT_CLUSTERS,
PARAMS,
PRESSED,
PROFILE_ID,
RIGHT,
SHORT_PRESS,
TOGGLE,
)
from zhaquirks.ikea import (
COMMAND_SHORTCUT_V1,
IKEA,
IKEA_CLUSTER_ID,
WWAH_CLUSTER_ID,
DoublingPowerConfig2AAACluster,
PowerConfig2AAACluster,
ShortcutV1Cluster,
ShortcutV2Cluster,
)
class Symfonisk2CommonTriggers:
"""IKEA Symfonisk 2 common device triggers."""
device_automation_triggers = {
(SHORT_PRESS, TOGGLE): {
COMMAND: COMMAND_TOGGLE,
CLUSTER_ID: 6,
ENDPOINT_ID: 1,
},
(SHORT_PRESS, DIM_UP): {
COMMAND: COMMAND_MOVE_ON_OFF,
CLUSTER_ID: 8,
ENDPOINT_ID: 1,
PARAMS: {"move_mode": 0},
},
(LONG_PRESS, DIM_UP): {
COMMAND: COMMAND_MOVE,
CLUSTER_ID: 8,
ENDPOINT_ID: 1,
PARAMS: {"move_mode": 0},
},
(SHORT_PRESS, DIM_DOWN): {
COMMAND: COMMAND_MOVE_ON_OFF,
CLUSTER_ID: 8,
ENDPOINT_ID: 1,
PARAMS: {"move_mode": 1},
},
(LONG_PRESS, DIM_DOWN): {
COMMAND: COMMAND_MOVE,
CLUSTER_ID: 8,
ENDPOINT_ID: 1,
PARAMS: {"move_mode": 1},
},
(SHORT_PRESS, RIGHT): {
COMMAND: COMMAND_STEP,
CLUSTER_ID: 8,
ENDPOINT_ID: 1,
PARAMS: {"step_mode": 0},
},
(SHORT_PRESS, LEFT): {
COMMAND: COMMAND_STEP,
CLUSTER_ID: 8,
ENDPOINT_ID: 1,
PARAMS: {"step_mode": 1},
},
}
class IkeaSymfoniskGen2v1(CustomDevice):
"""Custom device representing IKEA SYMFONISK sound remote gen2 V1.0.012."""
signature = {
# <SimpleDescriptor endpoint=1 profile=260 device_type=6
# device_version=1
# input_clusters=[0, 1, 3, 32, 4096, 64636]
# output_clusters=[3, 4, 6, 8, 25, 4096, 64639]>
MODELS_INFO: [(IKEA, "SYMFONISK sound remote gen2")],
ENDPOINTS: {
1: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.REMOTE_CONTROL,
INPUT_CLUSTERS: [
Basic.cluster_id,
PowerConfiguration.cluster_id,
Identify.cluster_id,
PollControl.cluster_id,
LightLink.cluster_id,
WWAH_CLUSTER_ID,
],
OUTPUT_CLUSTERS: [
Identify.cluster_id,
Groups.cluster_id,
OnOff.cluster_id,
LevelControl.cluster_id,
Ota.cluster_id,
LightLink.cluster_id,
ShortcutV1Cluster.cluster_id,
],
},
},
}
replacement = {
ENDPOINTS: {
1: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.REMOTE_CONTROL,
INPUT_CLUSTERS: [
Basic.cluster_id,
DoublingPowerConfig2AAACluster,
Identify.cluster_id,
PollControl.cluster_id,
LightLink.cluster_id,
WWAH_CLUSTER_ID,
ShortcutV1Cluster,
],
OUTPUT_CLUSTERS: [
Identify.cluster_id,
Groups.cluster_id,
OnOff.cluster_id,
LevelControl.cluster_id,
Ota.cluster_id,
LightLink.cluster_id,
ShortcutV1Cluster,
],
},
},
}
device_automation_triggers = (
Symfonisk2CommonTriggers.device_automation_triggers.copy()
)
device_automation_triggers.update(
{
(SHORT_PRESS, BUTTON_1): {
COMMAND: COMMAND_SHORTCUT_V1,
PARAMS: {"shortcut_button": 1, "shortcut_event": 1},
},
(DOUBLE_PRESS, BUTTON_1): {
COMMAND: COMMAND_SHORTCUT_V1,
PARAMS: {"shortcut_button": 1, "shortcut_event": 2},
},
(LONG_PRESS, BUTTON_1): {
COMMAND: COMMAND_SHORTCUT_V1,
PARAMS: {"shortcut_button": 1, "shortcut_event": 3},
},
(SHORT_PRESS, BUTTON_2): {
COMMAND: COMMAND_SHORTCUT_V1,
PARAMS: {"shortcut_button": 2, "shortcut_event": 1},
},
(DOUBLE_PRESS, BUTTON_2): {
COMMAND: COMMAND_SHORTCUT_V1,
PARAMS: {"shortcut_button": 2, "shortcut_event": 2},
},
(LONG_PRESS, BUTTON_2): {
COMMAND: COMMAND_SHORTCUT_V1,
PARAMS: {"shortcut_button": 2, "shortcut_event": 3},
},
},
)
class IkeaSymfoniskGen2v2(CustomDevice):
"""Custom device representing IKEA SYMFONISK sound remote gen2 V1.0.32."""
signature = {
# <SimpleDescriptor endpoint=1 profile=260 device_type=6
# device_version=1
# input_clusters=[0, 1, 3, 32, 4096, 64636]
# output_clusters=[3, 4, 6, 8, 25, 4096]>
MODELS_INFO: [(IKEA, "SYMFONISK sound remote gen2")],
ENDPOINTS: {
1: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.REMOTE_CONTROL,
INPUT_CLUSTERS: [
Basic.cluster_id,
PowerConfiguration.cluster_id,
Identify.cluster_id,
PollControl.cluster_id,
LightLink.cluster_id,
IKEA_CLUSTER_ID,
],
OUTPUT_CLUSTERS: [
Identify.cluster_id,
Groups.cluster_id,
OnOff.cluster_id,
LevelControl.cluster_id,
Ota.cluster_id,
LightLink.cluster_id,
],
},
# <SimpleDescriptor endpoint=1 profile=260 device_type=6
# device_version=1
# input_clusters=[0, 3, 64640]
# output_clusters=[3, 4, 64640]>
2: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.REMOTE_CONTROL,
INPUT_CLUSTERS: [
Basic.cluster_id,
Identify.cluster_id,
ShortcutV2Cluster.cluster_id,
],
OUTPUT_CLUSTERS: [
Identify.cluster_id,
Groups.cluster_id,
ShortcutV2Cluster.cluster_id,
],
},
# <SimpleDescriptor endpoint=1 profile=260 device_type=6
# device_version=1
# input_clusters=[0, 3, 64640]
# output_clusters=[3, 4, 64640]>
3: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.REMOTE_CONTROL,
INPUT_CLUSTERS: [
Basic.cluster_id,
Identify.cluster_id,
ShortcutV2Cluster.cluster_id,
],
OUTPUT_CLUSTERS: [
Identify.cluster_id,
Groups.cluster_id,
ShortcutV2Cluster.cluster_id,
],
},
},
}
replacement = {
ENDPOINTS: {
1: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.REMOTE_CONTROL,
INPUT_CLUSTERS: [
Basic.cluster_id,
PowerConfig2AAACluster,
Identify.cluster_id,
PollControl.cluster_id,
LightLink.cluster_id,
IKEA_CLUSTER_ID,
],
OUTPUT_CLUSTERS: [
Identify.cluster_id,
Groups.cluster_id,
OnOff.cluster_id,
LevelControl.cluster_id,
Ota.cluster_id,
LightLink.cluster_id,
],
},
2: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.REMOTE_CONTROL,
INPUT_CLUSTERS: [
Basic.cluster_id,
Identify.cluster_id,
ShortcutV2Cluster,
],
OUTPUT_CLUSTERS: [
Identify.cluster_id,
Groups.cluster_id,
ShortcutV2Cluster,
],
},
3: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.REMOTE_CONTROL,
INPUT_CLUSTERS: [
Basic.cluster_id,
Identify.cluster_id,
ShortcutV2Cluster,
],
OUTPUT_CLUSTERS: [
Identify.cluster_id,
Groups.cluster_id,
ShortcutV2Cluster,
],
},
},
}
device_automation_triggers = (
Symfonisk2CommonTriggers.device_automation_triggers.copy()
)
device_automation_triggers.update(
{
(PRESSED, BUTTON_1): {ENDPOINT_ID: 2, COMMAND: COMMAND_M_INITIAL_PRESS},
(SHORT_PRESS, BUTTON_1): {ENDPOINT_ID: 2, COMMAND: COMMAND_M_SHORT_RELEASE},
(DOUBLE_PRESS, BUTTON_1): {
ENDPOINT_ID: 2,
COMMAND: COMMAND_M_MULTI_PRESS_COMPLETE,
},
(LONG_PRESS, BUTTON_1): {ENDPOINT_ID: 2, COMMAND: COMMAND_M_LONG_PRESS},
(LONG_RELEASE, BUTTON_1): {ENDPOINT_ID: 2, COMMAND: COMMAND_M_LONG_RELEASE},
(PRESSED, BUTTON_2): {ENDPOINT_ID: 3, COMMAND: COMMAND_M_INITIAL_PRESS},
(SHORT_PRESS, BUTTON_2): {ENDPOINT_ID: 3, COMMAND: COMMAND_M_SHORT_RELEASE},
(DOUBLE_PRESS, BUTTON_2): {
ENDPOINT_ID: 3,
COMMAND: COMMAND_M_MULTI_PRESS_COMPLETE,
},
(LONG_PRESS, BUTTON_2): {ENDPOINT_ID: 3, COMMAND: COMMAND_M_LONG_PRESS},
(LONG_RELEASE, BUTTON_2): {ENDPOINT_ID: 3, COMMAND: COMMAND_M_LONG_RELEASE},
},
) | zha-quirks | /zha_quirks-0.0.103-py3-none-any.whl/zhaquirks/ikea/symfonisk2.py | symfonisk2.py |
from zigpy.profiles import zha
from zigpy.quirks import CustomDevice
from zigpy.zcl.clusters.closures import WindowCovering
from zigpy.zcl.clusters.general import (
Alarms,
Basic,
Groups,
Identify,
LevelControl,
OnOff,
Ota,
PollControl,
PowerConfiguration,
)
from zigpy.zcl.clusters.lightlink import LightLink
from zhaquirks.const import (
CLUSTER_ID,
COMMAND,
COMMAND_MOVE_ON_OFF,
COMMAND_OFF,
COMMAND_ON,
COMMAND_STOP_ON_OFF,
DEVICE_TYPE,
DIM_UP,
DOUBLE_PRESS,
ENDPOINT_ID,
ENDPOINTS,
INPUT_CLUSTERS,
LONG_PRESS,
LONG_RELEASE,
MODELS_INFO,
OUTPUT_CLUSTERS,
PARAMS,
PROFILE_ID,
SHORT_PRESS,
TURN_ON,
)
from zhaquirks.ikea import IKEA, IKEA_CLUSTER_ID, DoublingPowerConfig1CRCluster
class IkeaTradfriShortcutBtn(CustomDevice):
"""Custom device representing IKEA of Sweden TRADFRI shortcut button."""
signature = {
# <SimpleDescriptor endpoint=1 profile=260 device_type=2080
# device_version=1
# input_clusters=[0, 1, 3, 9, 32, 4096]
# output_clusters=[3, 4, 6, 8, 25, 258, 4096]>
MODELS_INFO: [(IKEA, "TRADFRI SHORTCUT Button")],
ENDPOINTS: {
1: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.NON_COLOR_CONTROLLER,
INPUT_CLUSTERS: [
Basic.cluster_id,
PowerConfiguration.cluster_id,
Identify.cluster_id,
Alarms.cluster_id,
PollControl.cluster_id,
LightLink.cluster_id,
],
OUTPUT_CLUSTERS: [
Identify.cluster_id,
Groups.cluster_id,
OnOff.cluster_id,
LevelControl.cluster_id,
Ota.cluster_id,
WindowCovering.cluster_id,
LightLink.cluster_id,
],
}
},
}
replacement = {
ENDPOINTS: {
1: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.NON_COLOR_CONTROLLER,
INPUT_CLUSTERS: [
Basic.cluster_id,
DoublingPowerConfig1CRCluster,
Identify.cluster_id,
Alarms.cluster_id,
PollControl.cluster_id,
LightLink.cluster_id,
],
OUTPUT_CLUSTERS: [
Identify.cluster_id,
Groups.cluster_id,
OnOff.cluster_id,
LevelControl.cluster_id,
Ota.cluster_id,
WindowCovering.cluster_id,
LightLink.cluster_id,
],
}
}
}
device_automation_triggers = {
(SHORT_PRESS, TURN_ON): {COMMAND: COMMAND_ON, CLUSTER_ID: 6, ENDPOINT_ID: 1},
(DOUBLE_PRESS, TURN_ON): {COMMAND: COMMAND_OFF, CLUSTER_ID: 6, ENDPOINT_ID: 1},
(LONG_PRESS, DIM_UP): {
COMMAND: COMMAND_MOVE_ON_OFF,
CLUSTER_ID: 8,
ENDPOINT_ID: 1,
PARAMS: {"move_mode": 0},
},
(LONG_RELEASE, DIM_UP): {
COMMAND: COMMAND_STOP_ON_OFF,
CLUSTER_ID: 8,
ENDPOINT_ID: 1,
},
}
class IkeaTradfriShortcutBtn2(CustomDevice):
"""Custom device representing IKEA of Sweden TRADFRI shortcut button with IKEA cluster."""
signature = {
# <SimpleDescriptor endpoint=1 profile=260 device_type=2080
# device_version=1
# input_clusters=[0, 1, 3, 9, 32, 4096, 64636]
# output_clusters=[3, 4, 6, 8, 25, 4096]>
MODELS_INFO: [(IKEA, "TRADFRI SHORTCUT Button")],
ENDPOINTS: {
1: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.NON_COLOR_CONTROLLER,
INPUT_CLUSTERS: [
Basic.cluster_id,
PowerConfiguration.cluster_id,
Identify.cluster_id,
Alarms.cluster_id,
PollControl.cluster_id,
LightLink.cluster_id,
IKEA_CLUSTER_ID,
],
OUTPUT_CLUSTERS: [
Identify.cluster_id,
Groups.cluster_id,
OnOff.cluster_id,
LevelControl.cluster_id,
Ota.cluster_id,
LightLink.cluster_id,
],
}
},
}
replacement = {
ENDPOINTS: {
1: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.NON_COLOR_CONTROLLER,
INPUT_CLUSTERS: [
Basic.cluster_id,
DoublingPowerConfig1CRCluster,
Identify.cluster_id,
Alarms.cluster_id,
PollControl.cluster_id,
LightLink.cluster_id,
],
OUTPUT_CLUSTERS: [
Identify.cluster_id,
Groups.cluster_id,
OnOff.cluster_id,
LevelControl.cluster_id,
Ota.cluster_id,
LightLink.cluster_id,
],
}
}
}
device_automation_triggers = {
(SHORT_PRESS, TURN_ON): {COMMAND: COMMAND_ON, CLUSTER_ID: 6, ENDPOINT_ID: 1},
(DOUBLE_PRESS, TURN_ON): {COMMAND: COMMAND_OFF, CLUSTER_ID: 6, ENDPOINT_ID: 1},
(LONG_PRESS, DIM_UP): {
COMMAND: COMMAND_MOVE_ON_OFF,
CLUSTER_ID: 8,
ENDPOINT_ID: 1,
PARAMS: {"move_mode": 0},
},
(LONG_RELEASE, DIM_UP): {
COMMAND: COMMAND_STOP_ON_OFF,
CLUSTER_ID: 8,
ENDPOINT_ID: 1,
},
} | zha-quirks | /zha_quirks-0.0.103-py3-none-any.whl/zhaquirks/ikea/shortcutbtn.py | shortcutbtn.py |
from zigpy.profiles import zha, zll
from zigpy.quirks import CustomDevice
from zigpy.zcl.clusters.general import (
Basic,
Groups,
Identify,
LevelControl,
OnOff,
Ota,
PollControl,
Scenes,
)
from zigpy.zcl.clusters.homeautomation import Diagnostic
from zigpy.zcl.clusters.lighting import Color
from zigpy.zcl.clusters.lightlink import LightLink
from zhaquirks.const import (
DEVICE_TYPE,
ENDPOINTS,
INPUT_CLUSTERS,
MODELS_INFO,
OUTPUT_CLUSTERS,
PROFILE_ID,
)
from zhaquirks.ikea import IKEA
class CCTLightZHA(CustomDevice):
"""TRADFRI CCT lights with ZHA profile but ZLL device type."""
signature = {
# <SimpleDescriptor endpoint=1 profile=260 device_type=544
# device_version=2
# input_clusters=[0, 3, 4, 5, 6, 8, 768, 2821, 4096]
# output_clusters=[5, 25, 32, 4096]>
MODELS_INFO: [
(IKEA, "TRADFRI bulb GU10 WS 400lm"),
(IKEA, "FLOALT panel WS 30x90"),
(IKEA, "FLOALT panel WS 60x60"),
],
ENDPOINTS: {
1: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zll.DeviceType.COLOR_TEMPERATURE_LIGHT,
INPUT_CLUSTERS: [
Basic.cluster_id,
Identify.cluster_id,
Groups.cluster_id,
Scenes.cluster_id,
OnOff.cluster_id,
LevelControl.cluster_id,
Color.cluster_id,
Diagnostic.cluster_id,
LightLink.cluster_id,
],
OUTPUT_CLUSTERS: [
Scenes.cluster_id,
Ota.cluster_id,
PollControl.cluster_id,
LightLink.cluster_id,
],
},
},
}
replacement = {
ENDPOINTS: {
1: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.COLOR_TEMPERATURE_LIGHT,
INPUT_CLUSTERS: [
Basic.cluster_id,
Identify.cluster_id,
Groups.cluster_id,
Scenes.cluster_id,
OnOff.cluster_id,
LevelControl.cluster_id,
Color.cluster_id,
Diagnostic.cluster_id,
LightLink.cluster_id,
],
OUTPUT_CLUSTERS: [
Scenes.cluster_id,
Ota.cluster_id,
PollControl.cluster_id,
LightLink.cluster_id,
],
}
}
} | zha-quirks | /zha_quirks-0.0.103-py3-none-any.whl/zhaquirks/ikea/cctlightzha.py | cctlightzha.py |
from __future__ import annotations
import logging
from typing import Any
from zigpy.profiles import zgp, zha
from zigpy.quirks import CustomCluster, CustomDevice
import zigpy.types as t
from zigpy.zcl.clusters.general import (
Basic,
GreenPowerProxy,
Groups,
Identify,
Ota,
Scenes,
)
from zigpy.zcl.clusters.hvac import Fan
from zigpy.zcl.clusters.measurement import PM25, IlluminanceMeasurement
from zhaquirks import Bus
from zhaquirks.const import (
DEVICE_TYPE,
ENDPOINTS,
INPUT_CLUSTERS,
MODELS_INFO,
OUTPUT_CLUSTERS,
PROFILE_ID,
)
from zhaquirks.ikea import IKEA, IKEA_CLUSTER_ID, WWAH_CLUSTER_ID
_LOGGER = logging.getLogger(__name__)
class IkeaAirpurifier(CustomCluster):
"""Ikea Manufacturer Specific AirPurifier."""
name: str = "Ikea Airpurifier"
cluster_id: t.uint16_t = 0xFC7D # 64637 0xFC7D control air purifier with manufacturer-specific attributes
ep_attribute: str = "ikea_airpurifier"
attributes = {
0x0000: ("filter_run_time", t.uint32_t, True),
0x0001: ("replace_filter", t.uint8_t, True),
0x0002: ("filter_life_time", t.uint32_t, True),
0x0003: ("disable_led", t.Bool, True),
0x0004: ("air_quality_25pm", t.uint16_t, True),
0x0005: ("child_lock", t.Bool, True),
0x0006: (
"fan_mode",
t.uint8_t,
True,
), # fan mode (Off, Auto, fanspeed 10 - 50) read/write
0x0007: (
"fan_speed",
t.uint8_t,
True,
), # current fan speed (only fan speed 10-50)
0x0008: ("device_run_time", t.uint32_t, True),
}
def __init__(self, *args, **kwargs):
"""Init."""
self._current_state = {}
super().__init__(*args, **kwargs)
self.endpoint.device.change_fan_mode_bus.add_listener(self)
def _update_attribute(self, attrid, value):
if attrid == 0x0004:
if (
value is not None and value < 5500
): # > 5500 = out of scale; if value is 65535 (0xFFFF), device is off
self.endpoint.device.pm25_bus.listener_event("update_state", value)
elif attrid == 0x0006:
if value > 9 and value < 51:
value = value / 5
super()._update_attribute(attrid, value)
async def write_attributes(
self, attributes: dict[str | int, Any], manufacturer: int | None = None
) -> list:
"""Override wrong writes to thermostat attributes."""
if "fan_mode" in attributes:
fan_mode = attributes.get("fan_mode")
if fan_mode and fan_mode > 1 and fan_mode < 11:
fan_mode = fan_mode * 5
return await super().write_attributes(
{"fan_mode": fan_mode}, manufacturer
)
return await super().write_attributes(attributes, manufacturer)
class PM25Cluster(CustomCluster, PM25):
"""PM25 input cluster, only used to show PM2.5 values from IKEA cluster."""
cluster_id = PM25.cluster_id
def __init__(self, *args, **kwargs):
"""Init."""
super().__init__(*args, **kwargs)
self.endpoint.device.pm25_bus.add_listener(self)
def update_state(self, value):
"""25pm reported."""
self._update_attribute(0x0000, value)
def _update_attribute(self, attrid, value):
"""Check for a valid PM2.5 value."""
if attrid == 0x0000:
if value < 5500:
super()._update_attribute(attrid, value)
else:
super()._update_attribute(attrid, value)
async def read_attributes(
self, attributes, allow_cache=False, only_cache=False, manufacturer=None
):
"""Read attributes ZCL foundation command."""
if "measured_value" in attributes:
return (
await self.endpoint.device.endpoints[1]
.in_clusters[64637]
.read_attributes(
["air_quality_25pm"],
allow_cache=allow_cache,
only_cache=only_cache,
manufacturer=manufacturer,
)
)
else:
return await super().read_attributes(
attributes,
allow_cache=allow_cache,
only_cache=only_cache,
manufacturer=manufacturer,
)
class IkeaSTARKVIND(CustomDevice):
"""STARKVIND Air purifier by IKEA of Sweden."""
def __init__(self, *args, **kwargs):
"""Init."""
self.pm25_bus = Bus()
self.change_fan_mode_bus = Bus()
self.change_fan_mode_ha_bus = Bus()
super().__init__(*args, **kwargs)
signature = {
# <SimpleDescriptor endpoint=1 profile=260 device_type=7 (0x0007)
# device_version=0
# input_clusters=[0, 3, 4, 5, 514, 64599, 64637] output_clusters=[25, 1024, 1066]>
MODELS_INFO: [
(IKEA, "STARKVIND Air purifier"),
(IKEA, "STARKVIND Air purifier table"),
],
ENDPOINTS: {
1: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.COMBINED_INTERFACE,
INPUT_CLUSTERS: [
Basic.cluster_id, # 0
Identify.cluster_id, # 3
Groups.cluster_id, # 4
Scenes.cluster_id, # 5
Fan.cluster_id, # 514 0x0202
WWAH_CLUSTER_ID, # 64599 0xFC57
IkeaAirpurifier.cluster_id, # 64637 0xFC7D
],
OUTPUT_CLUSTERS: [
Ota.cluster_id, # 25 0x0019
IlluminanceMeasurement.cluster_id, # 1024 0x0400
PM25.cluster_id, # 1066 0x042A PM2.5 Measurement Cluster
],
},
# <SimpleDescriptor endpoint=242 profile=41440 device_type=97
# device_version=0
# input_clusters=[33] output_clusters=[33]>
242: {
PROFILE_ID: zgp.PROFILE_ID, # 41440 (dec)
DEVICE_TYPE: zgp.DeviceType.PROXY_BASIC,
INPUT_CLUSTERS: [],
OUTPUT_CLUSTERS: [
GreenPowerProxy.cluster_id, # 0x0021 = GreenPowerProxy.cluster_id
],
},
},
}
replacement = {
ENDPOINTS: {
1: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.COMBINED_INTERFACE,
INPUT_CLUSTERS: [
Basic.cluster_id, # 0
Identify.cluster_id, # 3
Groups.cluster_id, # 4
Scenes.cluster_id, # 5
WWAH_CLUSTER_ID, # 64599 0xFC57
IkeaAirpurifier, # 64637 0xFC7D control air purifier with manufacturer-specific attributes
PM25Cluster, # 1066 0x042A PM2.5 Measurement Cluster
],
OUTPUT_CLUSTERS: [
Ota.cluster_id, # 25 0x0019
IlluminanceMeasurement.cluster_id, # 1024 0x0400
],
},
# <SimpleDescriptor endpoint=242 profile=41440 device_type=97
# device_version=0
# input_clusters=[33] output_clusters=[33]>
242: {
PROFILE_ID: zgp.PROFILE_ID, # 41440 (dec)
DEVICE_TYPE: zgp.DeviceType.PROXY_BASIC,
INPUT_CLUSTERS: [],
OUTPUT_CLUSTERS: [
GreenPowerProxy.cluster_id, # 0x0021 = GreenPowerProxy.cluster_id
],
},
},
}
class IkeaSTARKVIND_v2(IkeaSTARKVIND):
"""STARKVIND Air purifier by IKEA of Sweden."""
signature = {
# <SimpleDescriptor endpoint=1 profile=260 device_type=7 (0x0007)
# device_version=0
# input_clusters=[0, 3, 4, 5, 514, 64599, 64637] output_clusters=[25, 1024, 1066]>
MODELS_INFO: IkeaSTARKVIND.signature[MODELS_INFO].copy(),
ENDPOINTS: {
1: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.COMBINED_INTERFACE,
INPUT_CLUSTERS: [
Basic.cluster_id, # 0
Identify.cluster_id, # 3
Groups.cluster_id, # 4
Scenes.cluster_id, # 5
Fan.cluster_id, # 514 0x0202
WWAH_CLUSTER_ID, # 64599 0xFC57
IKEA_CLUSTER_ID, # 64636 0xFC7C
IkeaAirpurifier.cluster_id, # 64637 0xFC7D
],
OUTPUT_CLUSTERS: [
Ota.cluster_id, # 25 0x0019
IlluminanceMeasurement.cluster_id, # 1024 0x0400
PM25.cluster_id, # 1066 0x042A PM2.5 Measurement Cluster
],
},
# <SimpleDescriptor endpoint=242 profile=41440 device_type=97
# device_version=0
# input_clusters=[33] output_clusters=[33]>
242: {
PROFILE_ID: zgp.PROFILE_ID, # 41440 (dec)
DEVICE_TYPE: zgp.DeviceType.PROXY_BASIC,
INPUT_CLUSTERS: [],
OUTPUT_CLUSTERS: [
GreenPowerProxy.cluster_id, # 0x0021 = GreenPowerProxy.cluster_id
],
},
},
}
replacement = {
ENDPOINTS: {
1: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.COMBINED_INTERFACE,
INPUT_CLUSTERS: [
Basic.cluster_id, # 0
Identify.cluster_id, # 3
Groups.cluster_id, # 4
Scenes.cluster_id, # 5
WWAH_CLUSTER_ID, # 64599 0xFC57
IKEA_CLUSTER_ID, # 64636 0xFC7C
IkeaAirpurifier, # 64637 0xFC7D control air purifier with manufacturer-specific attributes
PM25Cluster, # 1066 0x042A PM2.5 Measurement Cluster
],
OUTPUT_CLUSTERS: [
Ota.cluster_id, # 25 0x0019
IlluminanceMeasurement.cluster_id, # 1024 0x0400
],
},
# <SimpleDescriptor endpoint=242 profile=41440 device_type=97
# device_version=0
# input_clusters=[33] output_clusters=[33]>
242: {
PROFILE_ID: zgp.PROFILE_ID, # 41440 (dec)
DEVICE_TYPE: zgp.DeviceType.PROXY_BASIC,
INPUT_CLUSTERS: [],
OUTPUT_CLUSTERS: [
GreenPowerProxy.cluster_id, # 0x0021 = GreenPowerProxy.cluster_id
],
},
},
} | zha-quirks | /zha_quirks-0.0.103-py3-none-any.whl/zhaquirks/ikea/starkvind.py | starkvind.py |
from zigpy.profiles import zll
from zigpy.quirks import CustomDevice
from zigpy.zcl.clusters.general import (
Alarms,
Basic,
Groups,
Identify,
OnOff,
Ota,
PowerConfiguration,
)
from zigpy.zcl.clusters.homeautomation import Diagnostic
from zigpy.zcl.clusters.lightlink import LightLink
from zhaquirks.const import (
DEVICE_TYPE,
ENDPOINTS,
INPUT_CLUSTERS,
MODELS_INFO,
OUTPUT_CLUSTERS,
PROFILE_ID,
)
from zhaquirks.ikea import IKEA, DoublingPowerConfig2CRCluster
class IkeaTradfriMotion(CustomDevice):
"""Custom device representing IKEA of Sweden TRADFRI remote control."""
signature = {
# <SimpleDescriptor endpoint=1 profile=49246 device_type=2128
# device_version=2
# input_clusters=[0, 1, 3, 9, 2821, 4096]
# output_clusters=[3, 4, 6, 25, 4096]>
MODELS_INFO: [(IKEA, "TRADFRI motion sensor")],
ENDPOINTS: {
1: {
PROFILE_ID: zll.PROFILE_ID,
DEVICE_TYPE: zll.DeviceType.ON_OFF_SENSOR,
INPUT_CLUSTERS: [
Basic.cluster_id,
PowerConfiguration.cluster_id,
Identify.cluster_id,
Alarms.cluster_id,
Diagnostic.cluster_id,
LightLink.cluster_id,
],
OUTPUT_CLUSTERS: [
Identify.cluster_id,
Groups.cluster_id,
OnOff.cluster_id,
Ota.cluster_id,
LightLink.cluster_id,
],
}
},
}
replacement = {
ENDPOINTS: {
1: {
PROFILE_ID: zll.PROFILE_ID,
DEVICE_TYPE: zll.DeviceType.ON_OFF_SENSOR,
INPUT_CLUSTERS: [
Basic.cluster_id,
DoublingPowerConfig2CRCluster,
Identify.cluster_id,
Alarms.cluster_id,
Diagnostic.cluster_id,
LightLink.cluster_id,
],
OUTPUT_CLUSTERS: [
Identify.cluster_id,
Groups.cluster_id,
OnOff.cluster_id,
Ota.cluster_id,
LightLink.cluster_id,
],
}
}
} | zha-quirks | /zha_quirks-0.0.103-py3-none-any.whl/zhaquirks/ikea/motion.py | motion.py |
from zigpy.profiles import zha, zll
from zigpy.quirks import CustomDevice
from zigpy.zcl.clusters.general import (
Alarms,
Basic,
Groups,
Identify,
LevelControl,
OnOff,
Ota,
PollControl,
PowerConfiguration,
Scenes,
)
from zigpy.zcl.clusters.homeautomation import Diagnostic
from zigpy.zcl.clusters.lightlink import LightLink
from zhaquirks import DoublingPowerConfigurationCluster
from zhaquirks.const import (
CLUSTER_ID,
COMMAND,
COMMAND_HOLD,
COMMAND_MOVE,
COMMAND_MOVE_ON_OFF,
COMMAND_PRESS,
COMMAND_RELEASE,
COMMAND_STEP,
COMMAND_STEP_ON_OFF,
COMMAND_STOP,
COMMAND_STOP_ON_OFF,
COMMAND_TOGGLE,
DEVICE_TYPE,
DIM_DOWN,
DIM_UP,
ENDPOINT_ID,
ENDPOINTS,
INPUT_CLUSTERS,
LEFT,
LONG_PRESS,
LONG_RELEASE,
MODELS_INFO,
OUTPUT_CLUSTERS,
PARAMS,
PROFILE_ID,
RIGHT,
SHORT_PRESS,
TURN_ON,
)
from zhaquirks.ikea import (
IKEA,
IKEA_CLUSTER_ID,
WWAH_CLUSTER_ID,
DoublingPowerConfig1CRCluster,
PowerConfig1CRCluster,
ScenesCluster,
)
class IkeaTradfriRemote1(CustomDevice):
"""Custom device representing ZLL version of IKEA five button remote."""
signature = {
# <SimpleDescriptor endpoint=1 profile=49246 device_type=2096
# device_version=2
# input_clusters=[0, 1, 3, 9, 2821, 4096]
# output_clusters=[3, 4, 5, 6, 8, 25, 4096]>
MODELS_INFO: [(IKEA, "TRADFRI remote control")],
ENDPOINTS: {
1: {
PROFILE_ID: zll.PROFILE_ID,
DEVICE_TYPE: zll.DeviceType.SCENE_CONTROLLER,
INPUT_CLUSTERS: [
Basic.cluster_id,
PowerConfiguration.cluster_id,
Identify.cluster_id,
Alarms.cluster_id,
Diagnostic.cluster_id,
LightLink.cluster_id,
],
OUTPUT_CLUSTERS: [
Identify.cluster_id,
Groups.cluster_id,
Scenes.cluster_id,
OnOff.cluster_id,
LevelControl.cluster_id,
Ota.cluster_id,
LightLink.cluster_id,
],
}
},
}
replacement = {
ENDPOINTS: {
1: {
PROFILE_ID: zll.PROFILE_ID,
DEVICE_TYPE: zll.DeviceType.SCENE_CONTROLLER,
INPUT_CLUSTERS: [
Basic.cluster_id,
DoublingPowerConfigurationCluster,
Identify.cluster_id,
Alarms.cluster_id,
Diagnostic.cluster_id,
LightLink.cluster_id,
],
OUTPUT_CLUSTERS: [
Identify.cluster_id,
Groups.cluster_id,
ScenesCluster,
OnOff.cluster_id,
LevelControl.cluster_id,
Ota.cluster_id,
LightLink.cluster_id,
],
}
}
}
device_automation_triggers = {
(SHORT_PRESS, TURN_ON): {
COMMAND: COMMAND_TOGGLE,
CLUSTER_ID: 6,
ENDPOINT_ID: 1,
},
(LONG_PRESS, TURN_ON): {
COMMAND: COMMAND_RELEASE,
CLUSTER_ID: 5,
ENDPOINT_ID: 1,
PARAMS: {"param1": 0},
},
(SHORT_PRESS, DIM_UP): {
COMMAND: COMMAND_STEP_ON_OFF,
CLUSTER_ID: 8,
ENDPOINT_ID: 1,
PARAMS: {"step_mode": 0},
},
(LONG_PRESS, DIM_UP): {
COMMAND: COMMAND_MOVE_ON_OFF,
CLUSTER_ID: 8,
ENDPOINT_ID: 1,
PARAMS: {"move_mode": 0},
},
(LONG_RELEASE, DIM_UP): {
COMMAND: COMMAND_STOP_ON_OFF,
CLUSTER_ID: 8,
ENDPOINT_ID: 1,
},
(SHORT_PRESS, DIM_DOWN): {
COMMAND: COMMAND_STEP,
CLUSTER_ID: 8,
ENDPOINT_ID: 1,
PARAMS: {"step_mode": 1},
},
(LONG_PRESS, DIM_DOWN): {
COMMAND: COMMAND_MOVE,
CLUSTER_ID: 8,
ENDPOINT_ID: 1,
PARAMS: {"move_mode": 1},
},
(LONG_RELEASE, DIM_DOWN): {
COMMAND: COMMAND_STOP,
CLUSTER_ID: 8,
ENDPOINT_ID: 1,
},
(SHORT_PRESS, LEFT): {
COMMAND: COMMAND_PRESS,
CLUSTER_ID: 5,
ENDPOINT_ID: 1,
PARAMS: {
"param1": 257,
"param2": 13,
"param3": 0,
},
},
(LONG_PRESS, LEFT): {
COMMAND: COMMAND_HOLD,
CLUSTER_ID: 5,
ENDPOINT_ID: 1,
PARAMS: {
"param1": 3329,
"param2": 0,
},
},
(SHORT_PRESS, RIGHT): {
COMMAND: COMMAND_PRESS,
CLUSTER_ID: 5,
ENDPOINT_ID: 1,
PARAMS: {
"param1": 256,
"param2": 13,
"param3": 0,
},
},
(LONG_PRESS, RIGHT): {
COMMAND: COMMAND_HOLD,
CLUSTER_ID: 5,
ENDPOINT_ID: 1,
PARAMS: {
"param1": 3328,
"param2": 0,
},
},
}
class IkeaTradfriRemote2(IkeaTradfriRemote1):
"""Custom device representing variation of IKEA five button remote."""
signature = {
# <SimpleDescriptor endpoint=1 profile=260 device_type=2080
# device_version=1
# input_clusters=[0, 1, 3, 32, 4096, 64636]
# output_clusters=[3, 4, 6, 8, 25, 4096]>
MODELS_INFO: [(IKEA, "TRADFRI remote control")],
ENDPOINTS: {
1: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.NON_COLOR_CONTROLLER,
INPUT_CLUSTERS: [
Basic.cluster_id,
PowerConfiguration.cluster_id,
Identify.cluster_id,
PollControl.cluster_id,
LightLink.cluster_id,
IKEA_CLUSTER_ID,
],
OUTPUT_CLUSTERS: [
Identify.cluster_id,
Groups.cluster_id,
OnOff.cluster_id,
LevelControl.cluster_id,
Ota.cluster_id,
LightLink.cluster_id,
],
}
},
}
replacement = {
ENDPOINTS: {
1: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.NON_COLOR_CONTROLLER,
INPUT_CLUSTERS: [
Basic.cluster_id,
DoublingPowerConfig1CRCluster,
Identify.cluster_id,
PollControl.cluster_id,
LightLink.cluster_id,
IKEA_CLUSTER_ID,
],
OUTPUT_CLUSTERS: [
Identify.cluster_id,
Groups.cluster_id,
ScenesCluster,
OnOff.cluster_id,
LevelControl.cluster_id,
Ota.cluster_id,
LightLink.cluster_id,
],
}
}
}
class IkeaTradfriRemote3(IkeaTradfriRemote1):
"""Custom device representing variation of IKEA five button remote."""
signature = {
# <SimpleDescriptor endpoint=1 profile=260 device_type=2064
# device_version=2
# input_clusters=[0, 1, 3, 9, 2821, 4096]
# output_clusters=[3, 4, 5, 6, 8, 25, 4096]>
MODELS_INFO: [(IKEA, "TRADFRI remote control")],
ENDPOINTS: {
1: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.COLOR_SCENE_CONTROLLER,
INPUT_CLUSTERS: [
Basic.cluster_id,
PowerConfiguration.cluster_id,
Identify.cluster_id,
Alarms.cluster_id,
Diagnostic.cluster_id,
LightLink.cluster_id,
],
OUTPUT_CLUSTERS: [
Identify.cluster_id,
Groups.cluster_id,
ScenesCluster.cluster_id,
OnOff.cluster_id,
LevelControl.cluster_id,
Ota.cluster_id,
LightLink.cluster_id,
],
}
},
}
replacement = {
ENDPOINTS: {
1: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.COLOR_SCENE_CONTROLLER,
INPUT_CLUSTERS: [
Basic.cluster_id,
DoublingPowerConfig1CRCluster,
Identify.cluster_id,
Alarms.cluster_id,
LightLink.cluster_id,
],
OUTPUT_CLUSTERS: [
Identify.cluster_id,
Groups.cluster_id,
ScenesCluster,
OnOff.cluster_id,
LevelControl.cluster_id,
Ota.cluster_id,
LightLink.cluster_id,
],
}
}
}
class IkeaTradfriRemote4(IkeaTradfriRemote1):
"""Custom device representing variation of IKEA five button remote."""
signature = {
# <SimpleDescriptor endpoint=1 profile=260 device_type=2080
# device_version=1
# input_clusters=[0, 1, 3, 32, 4096, 64636]
# output_clusters=[3, 4, 5, 6, 8, 25, 4096]>
MODELS_INFO: [(IKEA, "TRADFRI remote control")],
ENDPOINTS: {
1: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.NON_COLOR_CONTROLLER,
INPUT_CLUSTERS: [
Basic.cluster_id,
PowerConfiguration.cluster_id,
Identify.cluster_id,
PollControl.cluster_id,
LightLink.cluster_id,
IKEA_CLUSTER_ID,
],
OUTPUT_CLUSTERS: [
Identify.cluster_id,
Groups.cluster_id,
ScenesCluster.cluster_id,
OnOff.cluster_id,
LevelControl.cluster_id,
Ota.cluster_id,
LightLink.cluster_id,
],
}
},
}
replacement = {
ENDPOINTS: {
1: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.NON_COLOR_CONTROLLER,
INPUT_CLUSTERS: [
Basic.cluster_id,
DoublingPowerConfig1CRCluster,
Identify.cluster_id,
PollControl.cluster_id,
LightLink.cluster_id,
IKEA_CLUSTER_ID,
],
OUTPUT_CLUSTERS: [
Identify.cluster_id,
Groups.cluster_id,
ScenesCluster,
OnOff.cluster_id,
LevelControl.cluster_id,
Ota.cluster_id,
LightLink.cluster_id,
],
}
}
}
class IkeaTradfriRemote5(IkeaTradfriRemote1):
"""Custom device representing variation of IKEA five button remote."""
signature = {
# <SimpleDescriptor endpoint=1 profile=260 device_type=2080
# device_version=1
# input_clusters=[0, 1, 3, 32, 4096, 64599, 64636]
# output_clusters=[3, 4, 5, 6, 8, 25, 4096]>
MODELS_INFO: [(IKEA, "TRADFRI remote control")],
ENDPOINTS: {
1: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.NON_COLOR_CONTROLLER,
INPUT_CLUSTERS: [
Basic.cluster_id,
PowerConfiguration.cluster_id,
Identify.cluster_id,
PollControl.cluster_id,
LightLink.cluster_id,
WWAH_CLUSTER_ID,
IKEA_CLUSTER_ID,
],
OUTPUT_CLUSTERS: [
Identify.cluster_id,
Groups.cluster_id,
ScenesCluster.cluster_id,
OnOff.cluster_id,
LevelControl.cluster_id,
Ota.cluster_id,
LightLink.cluster_id,
],
}
},
}
replacement = {
ENDPOINTS: {
1: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.NON_COLOR_CONTROLLER,
INPUT_CLUSTERS: [
Basic.cluster_id,
PowerConfig1CRCluster,
Identify.cluster_id,
PollControl.cluster_id,
LightLink.cluster_id,
WWAH_CLUSTER_ID,
IKEA_CLUSTER_ID,
],
OUTPUT_CLUSTERS: [
Identify.cluster_id,
Groups.cluster_id,
ScenesCluster,
OnOff.cluster_id,
LevelControl.cluster_id,
Ota.cluster_id,
LightLink.cluster_id,
],
}
}
} | zha-quirks | /zha_quirks-0.0.103-py3-none-any.whl/zhaquirks/ikea/fivebtnremote.py | fivebtnremote.py |
from zigpy.profiles import zha
from zigpy.quirks import CustomDevice
from zigpy.zcl.clusters.general import (
Basic,
Identify,
LevelControl,
OnOff,
Ota,
PollControl,
PowerConfiguration,
)
from zigpy.zcl.clusters.lightlink import LightLink
from zhaquirks.const import (
CLUSTER_ID,
COMMAND,
COMMAND_HOLD,
COMMAND_MOVE,
COMMAND_MOVE_ON_OFF,
COMMAND_OFF,
COMMAND_ON,
COMMAND_PRESS,
COMMAND_STOP,
COMMAND_STOP_ON_OFF,
DEVICE_TYPE,
DIM_DOWN,
DIM_UP,
ENDPOINT_ID,
ENDPOINTS,
INPUT_CLUSTERS,
LEFT,
LONG_PRESS,
LONG_RELEASE,
MODELS_INFO,
OUTPUT_CLUSTERS,
PARAMS,
PROFILE_ID,
RIGHT,
SHORT_PRESS,
TURN_OFF,
TURN_ON,
)
from zhaquirks.ikea import (
IKEA,
IKEA_CLUSTER_ID,
WWAH_CLUSTER_ID,
DoublingPowerConfig2AAACluster,
ScenesCluster,
)
class IkeaTradfriRemoteV1(CustomDevice):
"""Custom device representing IKEA of Sweden TRADFRI remote control V1.0.024."""
signature = {
# <SimpleDescriptor endpoint=1 profile=260 device_type=820
# device_version=1
# input_clusters=[0, 1, 3, 32, 4096, 64599]
# output_clusters=[3, 6, 8, 25, 4096]>
MODELS_INFO: [(IKEA, "Remote Control N2")],
ENDPOINTS: {
1: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.NON_COLOR_CONTROLLER,
INPUT_CLUSTERS: [
Basic.cluster_id,
PowerConfiguration.cluster_id,
Identify.cluster_id,
PollControl.cluster_id,
LightLink.cluster_id,
WWAH_CLUSTER_ID,
],
OUTPUT_CLUSTERS: [
Identify.cluster_id,
OnOff.cluster_id,
LevelControl.cluster_id,
Ota.cluster_id,
LightLink.cluster_id,
],
}
},
}
replacement = {
ENDPOINTS: {
1: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.NON_COLOR_CONTROLLER,
INPUT_CLUSTERS: [
Basic.cluster_id,
DoublingPowerConfig2AAACluster,
Identify.cluster_id,
PollControl.cluster_id,
LightLink.cluster_id,
WWAH_CLUSTER_ID,
],
OUTPUT_CLUSTERS: [
Identify.cluster_id,
ScenesCluster,
OnOff.cluster_id,
LevelControl.cluster_id,
Ota.cluster_id,
LightLink.cluster_id,
],
}
}
}
device_automation_triggers = {
(SHORT_PRESS, TURN_ON): {COMMAND: COMMAND_ON, CLUSTER_ID: 6, ENDPOINT_ID: 1},
(LONG_PRESS, DIM_UP): {
COMMAND: COMMAND_MOVE_ON_OFF,
CLUSTER_ID: 8,
ENDPOINT_ID: 1,
PARAMS: {"move_mode": 0},
},
(LONG_RELEASE, DIM_UP): {
COMMAND: COMMAND_STOP_ON_OFF,
CLUSTER_ID: 8,
ENDPOINT_ID: 1,
},
(SHORT_PRESS, TURN_OFF): {COMMAND: COMMAND_OFF, CLUSTER_ID: 6, ENDPOINT_ID: 1},
(LONG_PRESS, DIM_DOWN): {
COMMAND: COMMAND_MOVE,
CLUSTER_ID: 8,
ENDPOINT_ID: 1,
PARAMS: {"move_mode": 1},
},
(LONG_RELEASE, DIM_DOWN): {
COMMAND: COMMAND_STOP,
CLUSTER_ID: 8,
ENDPOINT_ID: 1,
},
(SHORT_PRESS, LEFT): {
COMMAND: COMMAND_PRESS,
CLUSTER_ID: 5,
ENDPOINT_ID: 1,
PARAMS: {
"param1": 257,
"param2": 13,
"param3": 0,
},
},
(LONG_PRESS, LEFT): {
COMMAND: COMMAND_HOLD,
CLUSTER_ID: 5,
ENDPOINT_ID: 1,
PARAMS: {
"param1": 3329,
"param2": 0,
},
},
(SHORT_PRESS, RIGHT): {
COMMAND: COMMAND_PRESS,
CLUSTER_ID: 5,
ENDPOINT_ID: 1,
PARAMS: {
"param1": 256,
"param2": 13,
"param3": 0,
},
},
(LONG_PRESS, RIGHT): {
COMMAND: COMMAND_HOLD,
CLUSTER_ID: 5,
ENDPOINT_ID: 1,
PARAMS: {
"param1": 3328,
"param2": 0,
},
},
}
class IkeaTradfriRemoteV2(CustomDevice):
"""Custom device representing IKEA of Sweden TRADFRI remote control Version 2.4.5."""
signature = {
# <SimpleDescriptor endpoint=1 profile=260 device_type=820
# device_version=1
# input_clusters=[0, 1, 3, 32, 4096, 64599, 64636]
# output_clusters=[3, 5, 6, 8, 25, 4096]>
MODELS_INFO: [(IKEA, "Remote Control N2")],
ENDPOINTS: {
1: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.NON_COLOR_CONTROLLER,
INPUT_CLUSTERS: [
Basic.cluster_id,
PowerConfiguration.cluster_id,
Identify.cluster_id,
PollControl.cluster_id,
LightLink.cluster_id,
WWAH_CLUSTER_ID,
IKEA_CLUSTER_ID,
],
OUTPUT_CLUSTERS: [
Identify.cluster_id,
ScenesCluster.cluster_id,
OnOff.cluster_id,
LevelControl.cluster_id,
Ota.cluster_id,
LightLink.cluster_id,
],
}
},
}
replacement = {
ENDPOINTS: {
1: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.NON_COLOR_CONTROLLER,
INPUT_CLUSTERS: [
Basic.cluster_id,
PowerConfiguration.cluster_id,
Identify.cluster_id,
PollControl.cluster_id,
LightLink.cluster_id,
WWAH_CLUSTER_ID,
IKEA_CLUSTER_ID,
],
OUTPUT_CLUSTERS: [
Identify.cluster_id,
ScenesCluster,
OnOff.cluster_id,
LevelControl.cluster_id,
Ota.cluster_id,
LightLink.cluster_id,
],
}
}
}
device_automation_triggers = IkeaTradfriRemoteV1.device_automation_triggers.copy() | zha-quirks | /zha_quirks-0.0.103-py3-none-any.whl/zhaquirks/ikea/fourbtnremote.py | fourbtnremote.py |
from zigpy.profiles import zha
from zigpy.quirks import CustomDevice
from zigpy.zcl.clusters.general import (
Alarms,
Basic,
Groups,
Identify,
LevelControl,
OnOff,
Ota,
PollControl,
PowerConfiguration,
)
from zigpy.zcl.clusters.homeautomation import Diagnostic
from zigpy.zcl.clusters.lightlink import LightLink
from zhaquirks.const import (
DEVICE_TYPE,
ENDPOINTS,
INPUT_CLUSTERS,
MODELS_INFO,
OUTPUT_CLUSTERS,
PROFILE_ID,
)
from zhaquirks.ikea import (
IKEA,
IKEA_CLUSTER_ID,
WWAH_CLUSTER_ID,
DoublingPowerConfig2CRCluster,
)
class IkeaTradfriMotionE1745_Var01(CustomDevice):
"""Custom device representing IKEA of Sweden TRADFRI motion sensor E1745 second gen variation 1."""
signature = {
# <SimpleDescriptor endpoint=1 profile=260 device_type=2128
# device_version=2
# input_clusters=[0, 1, 3, 9, 2821, 4096]
# output_clusters=[3, 4, 6, 25, 4096]>
MODELS_INFO: [(IKEA, "TRADFRI motion sensor")],
ENDPOINTS: {
1: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.ON_OFF_SENSOR,
INPUT_CLUSTERS: [
Basic.cluster_id,
PowerConfiguration.cluster_id,
Identify.cluster_id,
Alarms.cluster_id,
Diagnostic.cluster_id,
LightLink.cluster_id,
],
OUTPUT_CLUSTERS: [
Identify.cluster_id,
Groups.cluster_id,
OnOff.cluster_id,
Ota.cluster_id,
LightLink.cluster_id,
],
}
},
}
replacement = {
ENDPOINTS: {
1: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.ON_OFF_SENSOR,
INPUT_CLUSTERS: [
Basic.cluster_id,
DoublingPowerConfig2CRCluster,
Identify.cluster_id,
Alarms.cluster_id,
Diagnostic.cluster_id,
LightLink.cluster_id,
],
OUTPUT_CLUSTERS: [
Identify.cluster_id,
Groups.cluster_id,
OnOff.cluster_id,
Ota.cluster_id,
LightLink.cluster_id,
],
}
}
}
class IkeaTradfriMotionE1745_Var02(CustomDevice):
"""Custom device representing IKEA of Sweden TRADFRI motion sensor E1745 second gen variation 2."""
signature = {
# <SimpleDescriptor endpoint=1 profile=260 device_type=2128
# device_version=1
# input_clusters=[0, 1, 3, 9, 32, 4096, 64636]
# output_clusters=[3, 4, 6, 8, 25, 4096]>
MODELS_INFO: [(IKEA, "TRADFRI motion sensor")],
ENDPOINTS: {
1: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.ON_OFF_SENSOR,
INPUT_CLUSTERS: [
Basic.cluster_id,
PowerConfiguration.cluster_id,
Identify.cluster_id,
Alarms.cluster_id,
PollControl.cluster_id,
LightLink.cluster_id,
IKEA_CLUSTER_ID,
],
OUTPUT_CLUSTERS: [
Identify.cluster_id,
Groups.cluster_id,
OnOff.cluster_id,
LevelControl.cluster_id,
Ota.cluster_id,
LightLink.cluster_id,
],
}
},
}
replacement = {
ENDPOINTS: {
1: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.ON_OFF_SENSOR,
INPUT_CLUSTERS: [
Basic.cluster_id,
DoublingPowerConfig2CRCluster,
Identify.cluster_id,
Alarms.cluster_id,
PollControl.cluster_id,
LightLink.cluster_id,
IKEA_CLUSTER_ID,
],
OUTPUT_CLUSTERS: [
Identify.cluster_id,
Groups.cluster_id,
OnOff.cluster_id,
LevelControl.cluster_id,
Ota.cluster_id,
LightLink.cluster_id,
],
}
}
}
class IkeaTradfriMotionE1525_Var01(CustomDevice):
"""Custom device representing IKEA of Sweden TRADFRI motion sensor E1525 first gen variation 1."""
signature = {
# <SimpleDescriptor endpoint=1 profile=260 device_type=2128
# device_version=1
# input_clusters=[0, 1, 3, 32, 4096, 64636]
# output_clusters=[3, 4, 6, 25, 4096]>
MODELS_INFO: [(IKEA, "TRADFRI motion sensor")],
ENDPOINTS: {
1: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.ON_OFF_SENSOR,
INPUT_CLUSTERS: [
Basic.cluster_id,
PowerConfiguration.cluster_id,
Identify.cluster_id,
PollControl.cluster_id,
LightLink.cluster_id,
IKEA_CLUSTER_ID,
WWAH_CLUSTER_ID,
],
OUTPUT_CLUSTERS: [
Identify.cluster_id,
Groups.cluster_id,
OnOff.cluster_id,
Ota.cluster_id,
LightLink.cluster_id,
],
}
},
}
replacement = {
ENDPOINTS: {
1: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.ON_OFF_SENSOR,
INPUT_CLUSTERS: [
Basic.cluster_id,
DoublingPowerConfig2CRCluster,
Identify.cluster_id,
PollControl.cluster_id,
LightLink.cluster_id,
IKEA_CLUSTER_ID,
WWAH_CLUSTER_ID,
],
OUTPUT_CLUSTERS: [
Identify.cluster_id,
Groups.cluster_id,
OnOff.cluster_id,
Ota.cluster_id,
LightLink.cluster_id,
],
}
}
} | zha-quirks | /zha_quirks-0.0.103-py3-none-any.whl/zhaquirks/ikea/motionzha.py | motionzha.py |
from zigpy.profiles import zha, zll
from zigpy.quirks import CustomDevice
from zigpy.zcl.clusters.closures import WindowCovering
from zigpy.zcl.clusters.general import (
Alarms,
Basic,
Groups,
Identify,
LevelControl,
OnOff,
Ota,
PollControl,
PowerConfiguration,
)
from zigpy.zcl.clusters.lightlink import LightLink
from zhaquirks.const import (
CLUSTER_ID,
COMMAND,
COMMAND_MOVE,
COMMAND_MOVE_ON_OFF,
COMMAND_OFF,
COMMAND_ON,
COMMAND_STOP,
COMMAND_STOP_ON_OFF,
DEVICE_TYPE,
DIM_DOWN,
DIM_UP,
ENDPOINT_ID,
ENDPOINTS,
INPUT_CLUSTERS,
LONG_PRESS,
LONG_RELEASE,
MODELS_INFO,
OUTPUT_CLUSTERS,
PARAMS,
PROFILE_ID,
SHORT_PRESS,
TURN_OFF,
TURN_ON,
)
from zhaquirks.ikea import IKEA, IKEA_CLUSTER_ID, DoublingPowerConfig1CRCluster
class IkeaTradfriRemote2Btn(CustomDevice):
"""Custom device representing IKEA of Sweden TRADFRI remote control."""
signature = {
# <SimpleDescriptor endpoint=1 profile=260 device_type=2080
# device_version=1
# input_clusters=[0, 1, 3, 9, 32, 4096, 64636]
# output_clusters=[3, 4, 6, 8, 25, 258, 4096]>
MODELS_INFO: [(IKEA, "TRADFRI on/off switch")],
ENDPOINTS: {
1: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.NON_COLOR_CONTROLLER,
INPUT_CLUSTERS: [
Basic.cluster_id,
PowerConfiguration.cluster_id,
Identify.cluster_id,
Alarms.cluster_id,
PollControl.cluster_id,
LightLink.cluster_id,
IKEA_CLUSTER_ID,
],
OUTPUT_CLUSTERS: [
Identify.cluster_id,
Groups.cluster_id,
OnOff.cluster_id,
LevelControl.cluster_id,
Ota.cluster_id,
WindowCovering.cluster_id,
LightLink.cluster_id,
],
}
},
}
replacement = {
ENDPOINTS: {
1: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.NON_COLOR_CONTROLLER,
INPUT_CLUSTERS: [
Basic.cluster_id,
DoublingPowerConfig1CRCluster,
Identify.cluster_id,
Alarms.cluster_id,
PollControl.cluster_id,
LightLink.cluster_id,
IKEA_CLUSTER_ID,
],
OUTPUT_CLUSTERS: [
Identify.cluster_id,
Groups.cluster_id,
OnOff.cluster_id,
LevelControl.cluster_id,
Ota.cluster_id,
WindowCovering.cluster_id,
LightLink.cluster_id,
],
}
}
}
device_automation_triggers = {
(SHORT_PRESS, TURN_ON): {COMMAND: COMMAND_ON, CLUSTER_ID: 6, ENDPOINT_ID: 1},
(LONG_PRESS, DIM_UP): {
COMMAND: COMMAND_MOVE_ON_OFF,
CLUSTER_ID: 8,
ENDPOINT_ID: 1,
PARAMS: {"move_mode": 0},
},
(LONG_RELEASE, DIM_UP): {
COMMAND: COMMAND_STOP_ON_OFF,
CLUSTER_ID: 8,
ENDPOINT_ID: 1,
},
(SHORT_PRESS, TURN_OFF): {COMMAND: COMMAND_OFF, CLUSTER_ID: 6, ENDPOINT_ID: 1},
(LONG_PRESS, DIM_DOWN): {
COMMAND: COMMAND_MOVE,
CLUSTER_ID: 8,
ENDPOINT_ID: 1,
PARAMS: {"move_mode": 1},
},
(LONG_RELEASE, DIM_DOWN): {
COMMAND: COMMAND_STOP,
CLUSTER_ID: 8,
ENDPOINT_ID: 1,
},
}
class IkeaTradfriRemote2BtnZLL(CustomDevice):
"""Custom device representing IKEA of Sweden TRADFRI remote control."""
signature = {
# <SimpleDescriptor endpoint=1 profile=49246 device_type=2080
# device_version=248
# input_clusters=[0, 1, 3, 9, 258, 4096, 64636]
# output_clusters=[3, 4, 6, 8, 25, 258, 4096]>
MODELS_INFO: [(IKEA, "TRADFRI on/off switch")],
ENDPOINTS: {
1: {
PROFILE_ID: zll.PROFILE_ID,
DEVICE_TYPE: zll.DeviceType.CONTROLLER,
INPUT_CLUSTERS: [
Basic.cluster_id,
PowerConfiguration.cluster_id,
Identify.cluster_id,
Alarms.cluster_id,
WindowCovering.cluster_id,
LightLink.cluster_id,
IKEA_CLUSTER_ID,
],
OUTPUT_CLUSTERS: [
Identify.cluster_id,
Groups.cluster_id,
OnOff.cluster_id,
LevelControl.cluster_id,
Ota.cluster_id,
WindowCovering.cluster_id,
LightLink.cluster_id,
],
}
},
}
replacement = {
ENDPOINTS: {
1: {
PROFILE_ID: zll.PROFILE_ID,
DEVICE_TYPE: zll.DeviceType.CONTROLLER,
INPUT_CLUSTERS: [
Basic.cluster_id,
DoublingPowerConfig1CRCluster,
Identify.cluster_id,
Alarms.cluster_id,
LightLink.cluster_id,
IKEA_CLUSTER_ID,
],
OUTPUT_CLUSTERS: [
Identify.cluster_id,
Groups.cluster_id,
OnOff.cluster_id,
LevelControl.cluster_id,
Ota.cluster_id,
WindowCovering.cluster_id,
LightLink.cluster_id,
],
}
}
}
device_automation_triggers = IkeaTradfriRemote2Btn.device_automation_triggers.copy() | zha-quirks | /zha_quirks-0.0.103-py3-none-any.whl/zhaquirks/ikea/twobtnremote.py | twobtnremote.py |
from zigpy.profiles import zha
from zigpy.quirks import CustomDevice
from zigpy.zcl.clusters.general import (
Basic,
Groups,
Identify,
LevelControl,
OnOff,
Ota,
PollControl,
PowerConfiguration,
)
from zigpy.zcl.clusters.lightlink import LightLink
from zhaquirks.const import (
CLUSTER_ID,
COMMAND,
COMMAND_MOVE,
COMMAND_MOVE_ON_OFF,
DEVICE_TYPE,
ENDPOINT_ID,
ENDPOINTS,
INPUT_CLUSTERS,
LEFT,
MODELS_INFO,
OUTPUT_CLUSTERS,
PARAMS,
PROFILE_ID,
RIGHT,
ROTATED,
)
from zhaquirks.ikea import IKEA, DoublingPowerConfig1CRXCluster
class IkeaDimmer(CustomDevice):
"""Custom device representing IKEA of Sweden TRADFRI wireless dimmer."""
signature = {
# <SimpleDescriptor endpoint=1 profile=260 device_type=2080
# device_version=1
# input_clusters=[0, 1, 3, 32, 4096]
# output_clusters=[3, 4, 6, 8, 25, 4096]
MODELS_INFO: [(IKEA, "TRADFRI wireless dimmer")],
ENDPOINTS: {
1: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.NON_COLOR_CONTROLLER,
INPUT_CLUSTERS: [
Basic.cluster_id,
PowerConfiguration.cluster_id,
Identify.cluster_id,
PollControl.cluster_id,
LightLink.cluster_id,
],
OUTPUT_CLUSTERS: [
Identify.cluster_id,
Groups.cluster_id,
OnOff.cluster_id,
LevelControl.cluster_id,
Ota.cluster_id,
LightLink.cluster_id,
],
}
},
}
replacement = {
ENDPOINTS: {
1: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.NON_COLOR_CONTROLLER,
INPUT_CLUSTERS: [
Basic.cluster_id,
DoublingPowerConfig1CRXCluster,
Identify.cluster_id,
PollControl.cluster_id,
LightLink.cluster_id,
],
OUTPUT_CLUSTERS: [
Identify.cluster_id,
Groups.cluster_id,
OnOff.cluster_id,
LevelControl.cluster_id,
Ota.cluster_id,
LightLink.cluster_id,
],
}
}
}
device_automation_triggers = {
(ROTATED, RIGHT): {
COMMAND: COMMAND_MOVE_ON_OFF,
CLUSTER_ID: 8,
ENDPOINT_ID: 1,
PARAMS: {"move_mode": 0},
},
(ROTATED, LEFT): {
COMMAND: COMMAND_MOVE,
CLUSTER_ID: 8,
ENDPOINT_ID: 1,
PARAMS: {"move_mode": 1},
},
} | zha-quirks | /zha_quirks-0.0.103-py3-none-any.whl/zhaquirks/ikea/dimmer.py | dimmer.py |
from zigpy.profiles import zgp, zha, zll
from zigpy.quirks import CustomDevice
from zigpy.zcl.clusters.general import (
Basic,
GreenPowerProxy,
Groups,
Identify,
LevelControl,
OnOff,
Ota,
PollControl,
Scenes,
)
from zigpy.zcl.clusters.lightlink import LightLink
from zhaquirks.const import (
DEVICE_TYPE,
ENDPOINTS,
INPUT_CLUSTERS,
MODELS_INFO,
OUTPUT_CLUSTERS,
PROFILE_ID,
)
from zhaquirks.ikea import IKEA, IKEA_CLUSTER_ID
class TradfriPlug(CustomDevice):
"""Tradfri Plug."""
signature = {
MODELS_INFO: [(IKEA, "TRADFRI control outlet")],
ENDPOINTS: {
# <SimpleDescriptor endpoint=1 profile=260 device_type=266
# device_version=0
# input_clusters=[0, 3, 4, 5, 6, 8, 64636] output_clusters=[5, 25, 32]>
1: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.ON_OFF_PLUG_IN_UNIT,
INPUT_CLUSTERS: [
Basic.cluster_id,
Identify.cluster_id,
Groups.cluster_id,
Scenes.cluster_id,
OnOff.cluster_id,
LevelControl.cluster_id,
IKEA_CLUSTER_ID,
],
OUTPUT_CLUSTERS: [
Scenes.cluster_id,
Ota.cluster_id,
PollControl.cluster_id,
],
},
# <SimpleDescriptor endpoint=2 profile=49246 device_type=16
# device_version=0
# input_clusters=[4096] output_clusters=[4096]>
2: {
PROFILE_ID: zll.PROFILE_ID,
DEVICE_TYPE: zll.DeviceType.ON_OFF_PLUGIN_UNIT,
INPUT_CLUSTERS: [LightLink.cluster_id],
OUTPUT_CLUSTERS: [LightLink.cluster_id],
},
# <SimpleDescriptor endpoint=242 profile=41440 device_type=97
# device_version=0
# input_clusters=[33] output_clusters=[33]>
242: {
PROFILE_ID: zgp.PROFILE_ID,
DEVICE_TYPE: zgp.DeviceType.PROXY_BASIC,
INPUT_CLUSTERS: [GreenPowerProxy.cluster_id],
OUTPUT_CLUSTERS: [GreenPowerProxy.cluster_id],
},
},
}
replacement = {
ENDPOINTS: {
1: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.ON_OFF_PLUG_IN_UNIT,
INPUT_CLUSTERS: [
Basic.cluster_id,
Identify.cluster_id,
Groups.cluster_id,
Scenes.cluster_id,
OnOff.cluster_id,
IKEA_CLUSTER_ID,
],
OUTPUT_CLUSTERS: [
Scenes.cluster_id,
Ota.cluster_id,
PollControl.cluster_id,
],
}
}
} | zha-quirks | /zha_quirks-0.0.103-py3-none-any.whl/zhaquirks/ikea/tradfriplug.py | tradfriplug.py |
import logging
from zigpy.quirks import CustomCluster
import zigpy.types as t
from zigpy.zcl import foundation
from zigpy.zcl.clusters.general import PowerConfiguration, Scenes
from zhaquirks import DoublingPowerConfigurationCluster, EventableCluster
_LOGGER = logging.getLogger(__name__)
IKEA = "IKEA of Sweden"
IKEA_CLUSTER_ID = 0xFC7C # decimal = 64636
WWAH_CLUSTER_ID = 0xFC57 # decimal = 64599 ('Works with all Hubs' cluster)
IKEA_SHORTCUT_CLUSTER_V1_ID = 0xFC7F # decimal = 64639 Shortcut V1 commands
IKEA_MATTER_SWITCH_CLUSTER_ID = 0xFC80 # decimal = 64640 Shortcut V2 commands
COMMAND_SHORTCUT_V1 = "shortcut_v1_events"
# PowerConfiguration cluster attributes
BATTERY_VOLTAGE = PowerConfiguration.attributes_by_name["battery_voltage"].id
BATTERY_SIZE = PowerConfiguration.attributes_by_name["battery_size"].id
BATTERY_QUANTITY = PowerConfiguration.attributes_by_name["battery_quantity"].id
BATTERY_RATED_VOLTAGE = PowerConfiguration.attributes_by_name[
"battery_rated_voltage"
].id
class ScenesCluster(CustomCluster, Scenes):
"""Ikea Scenes cluster."""
server_commands = Scenes.server_commands.copy()
server_commands.update(
{
0x0007: foundation.ZCLCommandDef(
"press",
{"param1": t.int16s, "param2": t.int8s, "param3": t.int8s},
False,
is_manufacturer_specific=True,
),
0x0008: foundation.ZCLCommandDef(
"hold",
{"param1": t.int16s, "param2": t.int8s},
False,
is_manufacturer_specific=True,
),
0x0009: foundation.ZCLCommandDef(
"release",
{
"param1": t.int16s,
},
False,
is_manufacturer_specific=True,
),
}
)
class ShortcutV1Cluster(EventableCluster):
"""Ikea Shortcut Button Cluster Variant 1."""
cluster_id = IKEA_SHORTCUT_CLUSTER_V1_ID
server_commands = {
0x01: foundation.ZCLCommandDef(
COMMAND_SHORTCUT_V1,
{
"shortcut_button": t.int8s,
"shortcut_event": t.int8s,
},
False,
is_manufacturer_specific=True,
),
}
class ShortcutV2Cluster(EventableCluster):
"""Ikea Shortcut Button Cluster Variant 2."""
cluster_id = IKEA_MATTER_SWITCH_CLUSTER_ID
server_commands = {
0x00: foundation.ZCLCommandDef(
"switch_latched",
{
"new_position": t.int8s,
},
False,
is_manufacturer_specific=True,
),
0x01: foundation.ZCLCommandDef(
"initial_press",
{
"new_position": t.int8s,
},
False,
is_manufacturer_specific=True,
),
0x02: foundation.ZCLCommandDef(
"long_press",
{
"previous_position": t.int8s,
},
False,
is_manufacturer_specific=True,
),
0x03: foundation.ZCLCommandDef(
"short_release",
{
"previous_position": t.int8s,
},
False,
is_manufacturer_specific=True,
),
0x04: foundation.ZCLCommandDef(
"long_release",
{
"previous_position": t.int8s,
},
False,
is_manufacturer_specific=True,
),
0x05: foundation.ZCLCommandDef(
"multi_press_ongoing",
{
"new_position": t.int8s,
# "current_number_of_presses_counted": t.int8s, # not implemented
},
False,
is_manufacturer_specific=True,
),
0x06: foundation.ZCLCommandDef(
"multi_press_complete",
{
"previous_position": t.int8s,
"total_number_of_presses_counted": t.int8s,
},
False,
is_manufacturer_specific=True,
),
}
# ZCL compliant IKEA power configuration clusters:
class PowerConfig2AAACluster(CustomCluster, PowerConfiguration):
"""Updating power attributes: 2 AAA."""
_CONSTANT_ATTRIBUTES = {
BATTERY_SIZE: 4,
BATTERY_QUANTITY: 2,
BATTERY_RATED_VOLTAGE: 15,
}
class PowerConfig2CRCluster(CustomCluster, PowerConfiguration):
"""Updating power attributes: 2 CR2032."""
_CONSTANT_ATTRIBUTES = {
BATTERY_SIZE: 10,
BATTERY_QUANTITY: 2,
BATTERY_RATED_VOLTAGE: 30,
}
class PowerConfig1CRCluster(CustomCluster, PowerConfiguration):
"""Updating power attributes: 1 CR2032."""
_CONSTANT_ATTRIBUTES = {
BATTERY_SIZE: 10,
BATTERY_QUANTITY: 1,
BATTERY_RATED_VOLTAGE: 30,
}
class PowerConfig1CRXCluster(CustomCluster, PowerConfiguration):
"""Updating power attributes: 1 CR2032 and zero voltage."""
_CONSTANT_ATTRIBUTES = {
BATTERY_VOLTAGE: 0,
BATTERY_SIZE: 10,
BATTERY_QUANTITY: 1,
BATTERY_RATED_VOLTAGE: 30,
}
# doubling IKEA power configuration clusters:
class DoublingPowerConfig2AAACluster(
DoublingPowerConfigurationCluster, PowerConfig2AAACluster
):
"""Doubling power configuration cluster. Updating power attributes: 2 AAA."""
class DoublingPowerConfig2CRCluster(
DoublingPowerConfigurationCluster, PowerConfig2CRCluster
):
"""Doubling power configuration cluster. Updating power attributes: 2 CR2032."""
class DoublingPowerConfig1CRCluster(
DoublingPowerConfigurationCluster, PowerConfig1CRCluster
):
"""Doubling power configuration cluster. Updating power attributes: 1 CR2032."""
class DoublingPowerConfig1CRXCluster(
DoublingPowerConfigurationCluster, PowerConfig1CRXCluster
):
"""Doubling power configuration cluster. Updating power attributes: 1 CR2032 and zero voltage.""" | zha-quirks | /zha_quirks-0.0.103-py3-none-any.whl/zhaquirks/ikea/__init__.py | __init__.py |
from copy import deepcopy
from zigpy.profiles import zgp, zha
from zigpy.quirks import CustomCluster, CustomDevice
import zigpy.types as t
from zigpy.zcl.clusters.general import (
Basic,
GreenPowerProxy,
Identify,
Ota,
PowerConfiguration,
)
from zigpy.zcl.clusters.homeautomation import ElectricalMeasurement, MeterIdentification
from zigpy.zcl.clusters.manufacturer_specific import ManufacturerSpecificCluster
from zigpy.zcl.clusters.smartenergy import Metering
from zhaquirks.const import (
DEVICE_TYPE,
ENDPOINTS,
INPUT_CLUSTERS,
MODELS_INFO,
OUTPUT_CLUSTERS,
PROFILE_ID,
)
from zhaquirks.lixee import LIXEE, ZLINKY_MANUFACTURER_CLUSTER_ID
class ZLinkyTICManufacturerCluster(CustomCluster, ManufacturerSpecificCluster):
"""ZLinkyTICManufacturerCluster manufacturer cluster."""
cluster_id = ZLINKY_MANUFACTURER_CLUSTER_ID
name = "ZLinky_TIC Manufacturer specific"
ep_attribute = "zlinky_manufacturer_specific"
# The attribute comments below are in French to match the reference documentation,
# see https://github.com/fairecasoimeme/Zlinky_TIC/tree/v9.0#synth%C3%A8se-d%C3%A9veloppeur
# and https://github.com/fairecasoimeme/Zlinky_TIC/blob/v9.0/ZLinky/Source/LixeeCluster.h
attributes = {
# Historical mode: OPTARIF "Option tarifaire" / String 4 car
# Standard mode: NGTF "Nom du calendrier tarifaire fournisseur" / String 16 car
0x0000: (
"hist_tariff_option_or_std_supplier_price_schedule_name",
t.LimitedCharString(16),
True,
),
# Historical mode: DEMAIN "Couleur du lendemain" / String 4 car
0x0001: ("hist_tomorrow_color", t.LimitedCharString(4), True),
# Historical mode: HHPHC "Horaire Heure Pleines Heures Creuses" / Uint8 1 car
0x0002: ("hist_schedule_peak_hours_off_peak_hours", t.uint8_t, True),
# Historical mode: PPOT "Présence des potentiels" (Triphasé) / Uint8 2 car
0x0003: ("hist_potentials_presence", t.uint8_t, True),
# Historical mode: PEJP "Préavis début EJP(30min)" / Uint8 2 car
0x0004: ("hist_ejp_start_notice", t.uint8_t, True),
# Historical mode: ADPS "Avertissement de Dépassement De Puissance Souscrite" / Uint16 3 car
0x0005: ("hist_subscribed_power_exceeding_warning", t.uint16_t, True),
# Historical mode: ADIR1 "Avertissement de Dépassement D'intensité phase 1" / Uint16 3 car
0x0006: ("hist_current_exceeding_warning_phase_1", t.uint16_t, True),
# Historical mode: ADIR2 "Avertissement de Dépassement D'intensité phase 2" / Uint16 3 car
0x0007: ("hist_current_exceeding_warning_phase_2", t.uint16_t, True),
# Historical mode: ADIR3 "Avertissement de Dépassement D'intensité phase 3" / Uint16 3 car
0x0008: ("hist_current_exceeding_warning_phase_3", t.uint16_t, True),
# Historical mode: MOTDETAT "Etat du Linky (From V13)" / String 6 car
0x0009: ("linky_status", t.LimitedCharString(6), True),
# Historical and Standard mode: "Linky acquisition time (From V7)"" / Uint8 1 car
0x0100: ("linky_acquisition_time", t.uint8_t, True),
# Standard mode: LTARF "Libellé tarif fournisseur en cours" / String 16 car
0x0200: (
"std_current_supplier_price_description",
t.LimitedCharString(16),
True,
),
# Standard mode: NTARF "Numéro de l’index tarifaire en cours" / Uint8 2 car
0x0201: ("std_current_tariff_index_number", t.uint8_t, True),
# Standard mode: DATE "Date et heure courant" / String 10 car
0x0202: ("std_current_date_and_time", t.LimitedCharString(10), True),
# Standard mode: EASD01 "Energie active soutirée Distributeur, index 01" / Uint32 9 car
0x0203: ("std_active_energy_withdrawn_distributor_index_01", t.uint32_t, True),
# Standard mode: EASD02 "Energie active soutirée Distributeur, index 02" / Uint32 9 car
0x0204: ("std_active_energy_withdrawn_distributor_index_02", t.uint32_t, True),
# Standard mode: EASD03 "Energie active soutirée Distributeur, index 03" / Uint32 9 car
0x0205: ("std_active_energy_withdrawn_distributor_index_03", t.uint32_t, True),
# Standard mode: EASD04 "Energie active soutirée Distributeur, index 04" / Uint32 9 car
0x0206: ("std_active_energy_withdrawn_distributor_index_04", t.uint32_t, True),
# Standard mode: SINSTI "Puissance app. Instantanée injectée" (Production) / Uint16 5 car
0x0207: ("std_apparent_power_injected_instantaneous", t.uint16_t, True),
# Standard mode: SMAXIN "Puissance app max. injectée n" (Production) / Uint16 5 car
0x0208: ("std_apparent_power_injected_max", t.uint16_t, True),
# Standard mode: SMAXIN-1 "Puissance app max. injectée n-1" (Production) / Uint16 5 car
0x0209: ("std_apparent_power_injected_max_1", t.uint16_t, True),
# Standard mode: CCAIN "Point n de la courbe de charge active injectée" (Production) / Uint16 5 car
0x0210: ("std_injected_active_load_curve_point_n", t.uint16_t, True),
# Standard mode: CCAIN-1 "Point n-1 de la courbe de charge active injectée" (Production) / Uint16 5 car
0x0211: ("std_injected_active_load_curve_point_n_1", t.uint16_t, True),
# Standard mode: SMAXN-1 "Puissance app. max. soutirée n-1" (Monophasé) / Uint16 5 car
# Standard mode: SMAXN1-1 "Puissance app. max. soutirée n-1 ph.1" (Triphasé) / Uint16 5 car
0x0212: ("std_apparent_power_withdrawn_max_phase_1_n_1", t.uint16_t, True),
# Standard mode: SMAXN2-1 "Puissance app. max. soutirée n-1 ph. 2" (Triphasé) / Uint16 5 car
0x0213: ("std_apparent_power_withdrawn_max_phase_2_n_1", t.uint16_t, True),
# Standard mode: SMAXN3-1 "Puissance app. max. soutirée n-1 ph. 3" (Triphasé) / Uint16 5 car
0x0214: ("std_apparent_power_withdrawn_max_phase_3_n_1", t.uint16_t, True),
# Standard mode: MSG1 "Message court" / String 32 car
0x0215: ("std_message_short", t.LimitedCharString(32), True),
# Standard mode: MSG2 "Message ultra court" / String 16 car
0x0216: ("std_message_ultra_short", t.LimitedCharString(16), True),
# Standard mode: STGE "Registre de Statuts" / String 8 car
0x0217: ("std_status_register", t.LimitedCharString(8), True),
# Standard mode: DPM1 "Début Pointe Mobile 1" / Uint8 2 car
0x0218: ("std_mobile_peak_start_1", t.uint8_t, True),
# Standard mode: FPM1 "Fin Pointe Mobile 1" / Uint8 2 car
0x0219: ("std_mobile_peak_end_1", t.uint8_t, True),
# Standard mode: DPM2 "Début Pointe Mobile 2" / Uint8 2 car
0x0220: ("std_mobile_peak_start_2", t.uint8_t, True),
# Standard mode: FPM2 "Fin Pointe Mobile 2" / Uint8 2 car
0x0221: ("std_mobile_peak_end_2", t.uint8_t, True),
# Standard mode: DPM3 "Début Pointe Mobile 3" / Uint8 2 car
0x0222: ("std_mobile_peak_start_3", t.uint8_t, True),
# Standard mode: FPM3 "Fin Pointe Mobile 3" / Uint8 2 car
0x0223: ("std_mobile_peak_end_3", t.uint8_t, True),
# Standard mode: RELAIS "RELAIS" / Uint16 3 car
0x0224: ("std_relay", t.uint8_t, True),
# Standard mode: NJOURF "Numéro du jour en cours calendrier fournisseur" / Uint8 2 car
0x0225: ("std_supplier_calendar_current_day_number", t.uint8_t, True),
# Standard mode: NJOURF+1 "Numéro du prochain jour calendrier fournisseur" / Uint8 2 car
0x0226: ("std_supplier_calendar_next_day_number", t.uint8_t, True),
# Standard mode: PJOURF+1 "Profil du prochain jour calendrier fournisseur" / String 98 car
0x0227: (
"std_supplier_calendar_next_day_profile",
t.LimitedCharString(98),
True,
),
# Standard mode: PPOINTE1 "Profil du prochain jour de pointe" / String 98 car
0x0228: ("std_next_peak_day_profile", t.LimitedCharString(98), True),
# Historical and Standard mode: - "Linky Mode (From V4)" / Uint8 1 car
0x0300: ("linky_mode", t.uint8_t, True),
}
class ZLinkyTICMetering(CustomCluster, Metering):
"""ZLinky_TIC custom metring cluster."""
# ZLinky_TIC reports current_summ_delivered in Wh
# Home Assistant expects kWh (1kWh = 1000 Wh)
MULTIPLIER = 0x0301
DIVISOR = 0x0302
_CONSTANT_ATTRIBUTES = {MULTIPLIER: 1, DIVISOR: 1000}
class ZLinkyTIC(CustomDevice):
"""ZLinky_TIC from LiXee."""
signature = {
MODELS_INFO: [(LIXEE, "ZLinky_TIC")],
ENDPOINTS: {
1: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.METER_INTERFACE,
INPUT_CLUSTERS: [
Basic.cluster_id,
Identify.cluster_id,
Metering.cluster_id,
MeterIdentification.cluster_id,
ElectricalMeasurement.cluster_id,
ZLinkyTICManufacturerCluster.cluster_id,
],
OUTPUT_CLUSTERS: [Ota.cluster_id],
},
242: {
PROFILE_ID: zgp.PROFILE_ID,
DEVICE_TYPE: zgp.DeviceType.PROXY_BASIC,
INPUT_CLUSTERS: [GreenPowerProxy.cluster_id],
OUTPUT_CLUSTERS: [GreenPowerProxy.cluster_id],
},
},
}
replacement = {
ENDPOINTS: {
1: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.METER_INTERFACE,
INPUT_CLUSTERS: [
Basic.cluster_id,
PowerConfiguration.cluster_id,
Identify.cluster_id,
ZLinkyTICMetering,
MeterIdentification.cluster_id,
ElectricalMeasurement.cluster_id,
ZLinkyTICManufacturerCluster,
],
OUTPUT_CLUSTERS: [Ota.cluster_id],
},
242: {
PROFILE_ID: zgp.PROFILE_ID,
DEVICE_TYPE: zgp.DeviceType.PROXY_BASIC,
INPUT_CLUSTERS: [GreenPowerProxy.cluster_id],
OUTPUT_CLUSTERS: [GreenPowerProxy.cluster_id],
},
},
}
class ZLinkyTICFWV12(ZLinkyTIC):
"""ZLinky_TIC from LiXee with firmware v12.0+."""
signature = deepcopy(ZLinkyTIC.signature)
# Insert PowerConfiguration cluster in signature for devices with firmware v12.0+
signature[ENDPOINTS][1][INPUT_CLUSTERS].insert(1, PowerConfiguration.cluster_id) | zha-quirks | /zha_quirks-0.0.103-py3-none-any.whl/zhaquirks/lixee/zlinky.py | zlinky.py |
from zigpy.profiles import zha
from zigpy.quirks import CustomCluster, CustomDevice
import zigpy.types as t
from zigpy.zcl import foundation
from zigpy.zcl.clusters.general import (
Basic,
BinaryInput,
Identify,
OnOff,
Ota,
PollControl,
PowerConfiguration,
Scenes,
Time,
)
from zigpy.zcl.clusters.measurement import TemperatureMeasurement
from zigpy.zcl.clusters.security import IasZone
from zhaquirks.const import (
DEVICE_TYPE,
ENDPOINTS,
INPUT_CLUSTERS,
MODELS_INFO,
OUTPUT_CLUSTERS,
PROFILE_ID,
)
from zhaquirks.develco import DEVELCO, DevelcoPowerConfiguration
class DevelcoIASZone(CustomCluster, IasZone):
"""IAS Zone."""
client_commands = IasZone.client_commands.copy()
client_commands[0x0000] = foundation.ZCLCommandDef(
"status_change_notification",
{
"zone_status": IasZone.ZoneStatus,
"extended_status": t.bitmap8,
# These two should not be optional
"zone_id?": t.uint8_t,
"delay?": t.uint16_t,
},
False,
is_manufacturer_specific=True,
)
class WISZB120(CustomDevice):
"""Custom device representing door/windows sensors."""
signature = {
# <SimpleDescriptor endpoint=1 profile=49353 device_type=1 device_version=1
# input_clusters=[3, 5, 6] output_clusters=[]>
# <SimpleDescriptor endpoint=35 profile=260 device_type=1026 device_version=0
# input_clusters=[0, 1, 3, 15, 32, 1280] output_clusters=[10, 25]>
# <SimpleDescriptor endpoint=38 profile=260 device_type=770 device_version=0
# input_clusters=[0, 3, 1026] output_clusters=[3]>
MODELS_INFO: [(DEVELCO, "WISZB-120")],
ENDPOINTS: {
1: {
PROFILE_ID: 0xC0C9,
DEVICE_TYPE: 1,
INPUT_CLUSTERS: [
Identify.cluster_id,
Scenes.cluster_id,
OnOff.cluster_id,
],
OUTPUT_CLUSTERS: [],
},
35: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.IAS_ZONE,
INPUT_CLUSTERS: [
Basic.cluster_id,
PowerConfiguration.cluster_id,
Identify.cluster_id,
BinaryInput.cluster_id,
PollControl.cluster_id,
IasZone.cluster_id,
],
OUTPUT_CLUSTERS: [Time.cluster_id, Ota.cluster_id],
},
38: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.TEMPERATURE_SENSOR,
INPUT_CLUSTERS: [
Basic.cluster_id,
Identify.cluster_id,
TemperatureMeasurement.cluster_id,
],
OUTPUT_CLUSTERS: [Identify.cluster_id],
},
},
}
replacement = {
ENDPOINTS: {
1: {
INPUT_CLUSTERS: [
Identify.cluster_id,
Scenes.cluster_id,
OnOff.cluster_id,
],
OUTPUT_CLUSTERS: [],
},
35: {
INPUT_CLUSTERS: [
Basic.cluster_id,
DevelcoPowerConfiguration,
Identify.cluster_id,
BinaryInput.cluster_id,
PollControl.cluster_id,
DevelcoIASZone,
],
OUTPUT_CLUSTERS: [Time.cluster_id, Ota.cluster_id],
},
38: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.TEMPERATURE_SENSOR,
INPUT_CLUSTERS: [
Basic.cluster_id,
Identify.cluster_id,
TemperatureMeasurement.cluster_id,
],
OUTPUT_CLUSTERS: [Identify.cluster_id],
},
}
} | zha-quirks | /zha_quirks-0.0.103-py3-none-any.whl/zhaquirks/develco/open_close.py | open_close.py |
import logging
from zigpy.profiles import zha
from zigpy.quirks import CustomCluster, CustomDevice
import zigpy.types as t
from zigpy.zcl.clusters.general import (
Basic,
Identify,
OnOff,
Ota,
PollControl,
PowerConfiguration,
Scenes,
Time,
)
from zigpy.zcl.clusters.measurement import RelativeHumidity, TemperatureMeasurement
from zhaquirks import Bus, LocalDataCluster
from zhaquirks.const import (
DEVICE_TYPE,
ENDPOINTS,
INPUT_CLUSTERS,
MODELS_INFO,
OUTPUT_CLUSTERS,
PROFILE_ID,
)
from zhaquirks.develco import DEVELCO, DevelcoPowerConfiguration
MANUFACTURER = 0x1015
VOC_MEASURED_VALUE = 0x0000
VOC_MIN_MEASURED_VALUE = 0x0001
VOC_MAX_MEASURED_VALUE = 0x0002
VOC_RESOLUTION = 0x0003
VOC_REPORTED = "voc_reported"
MIN_VOC_REPORTED = "min_voc_reported"
MAX_VOC_REPORTED = "max_voc_reported"
VOC_RESOLUTION_REPORTED = "voc_resolution_reported"
_LOGGER = logging.getLogger(__name__)
class DevelcoVOCMeasurement(CustomCluster):
"""Input Cluster to route manufacturer specific VOC cluster to actual VOC cluster."""
cluster_id = 0xFC03
name = "VOC Level"
ep_attribute = "voc_level"
attributes = {
VOC_MEASURED_VALUE: ("measured_value", t.uint16_t, True),
VOC_MIN_MEASURED_VALUE: ("min_measured_value", t.uint16_t, True),
VOC_MAX_MEASURED_VALUE: ("max_measured_value", t.uint16_t, True),
VOC_RESOLUTION: ("resolution", t.uint16_t, True),
}
server_commands = {}
client_commands = {}
def __init__(self, *args, **kwargs):
"""Init."""
self._current_state = {}
super().__init__(*args, **kwargs)
self.endpoint.device.app_cluster = self
def _update_attribute(self, attrid, value):
super()._update_attribute(attrid, value)
if attrid == VOC_MEASURED_VALUE and value is not None:
self.endpoint.device.voc_bus.listener_event(VOC_REPORTED, value)
if attrid == VOC_MIN_MEASURED_VALUE and value is not None:
self.endpoint.device.voc_bus.listener_event(MIN_VOC_REPORTED, value)
if attrid == VOC_MAX_MEASURED_VALUE and value is not None:
self.endpoint.device.voc_bus.listener_event(MAX_VOC_REPORTED, value)
if attrid == VOC_RESOLUTION and value is not None:
self.endpoint.device.voc_bus.listener_event(VOC_RESOLUTION_REPORTED, value)
_LOGGER.debug(
"%s Develco VOC : [%s]",
self.endpoint.device.ieee,
self._attr_cache,
)
class DevelcoRelativeHumidity(CustomCluster, RelativeHumidity):
"""Handles invalid values for Humidity."""
def _update_attribute(self, attrid, value):
# Drop values out of specified range (0-100% RH)
if 0 <= value <= 10000:
super()._update_attribute(attrid, value)
_LOGGER.debug(
"%s Develco Humidity : [%s]",
self.endpoint.device.ieee,
self._attr_cache,
)
class DevelcoTemperatureMeasurement(CustomCluster, TemperatureMeasurement):
"""Handles invalid values for Temperature."""
def _update_attribute(self, attrid, value):
# Drop values out of specified range (0-50°C)
if 0 <= value <= 5000:
super()._update_attribute(attrid, value)
_LOGGER.debug(
"%s Develco Temperature : [%s]",
self.endpoint.device.ieee,
self._attr_cache,
)
class EmulatedVOCMeasurement(LocalDataCluster):
"""VOC measurement cluster to receive reports from the Develco VOC cluster."""
cluster_id = 0x042E
name = "VOC Level"
ep_attribute = "voc_level"
attributes = {
VOC_MEASURED_VALUE: ("measured_value", t.uint16_t, True),
VOC_MIN_MEASURED_VALUE: ("min_measured_value", t.uint16_t, True),
VOC_MAX_MEASURED_VALUE: ("max_measured_value", t.uint16_t, True),
VOC_RESOLUTION: ("resolution", t.uint16_t, True),
}
MEASURED_VALUE_ID = 0x0000
MIN_MEASURED_VALUE_ID = 0x0001
MAX_MEASURED_VALUE_ID = 0x0002
RESOLUTION_ID = 0x0003
def __init__(self, *args, **kwargs):
"""Init."""
super().__init__(*args, **kwargs)
self.endpoint.device.voc_bus.add_listener(self)
async def bind(self):
"""Bind cluster."""
result = await self.endpoint.device.app_cluster.bind()
return result
async def write_attributes(self, attributes, manufacturer=None):
"""Ignore write_attributes."""
return (0,)
def _update_attribute(self, attrid, value):
# Drop values out of specified range (0-60000 ppb)
if 0 <= value <= 60000:
# Convert ppb into mg/m³ approximation according to develco spec
value = value * 0.0000045
super()._update_attribute(attrid, value)
def voc_reported(self, value):
"""VOC reported."""
self._update_attribute(self.MEASURED_VALUE_ID, value)
def min_voc_reported(self, value):
"""Minimum Measured VOC reported."""
self._update_attribute(self.MIN_MEASURED_VALUE_ID, value)
def max_voc_reported(self, value):
"""Maximum Measured VOC reported."""
self._update_attribute(self.MAX_MEASURED_VALUE_ID, value)
def voc_resolution_reported(self, value):
"""VOC Resolution reported."""
self._update_attribute(self.RESOLUTION_ID, value)
class AQSZB110(CustomDevice):
"""Custom device Develco air quality sensor."""
manufacturer_id_override = MANUFACTURER
def __init__(self, *args, **kwargs):
"""Init."""
self.voc_bus = Bus()
super().__init__(*args, **kwargs)
signature = {
# <SimpleDescriptor endpoint=1 profile=49353 device_type=1 device_version=1
# input_clusters=[3, 5, 6] output_clusters=[]>
# <SimpleDescriptor endpoint=38 profile=260 device_type=770 device_version=0
# input_clusters=[0, 1, 3, 32, 1026, 1029, 64515] output_clusters=[3, 10, 25]>
MODELS_INFO: [
(DEVELCO, "AQSZB-110"),
("frient A/S", "AQSZB-110"),
],
ENDPOINTS: {
1: {
PROFILE_ID: 0xC0C9,
DEVICE_TYPE: 1,
INPUT_CLUSTERS: [
Identify.cluster_id,
Scenes.cluster_id,
OnOff.cluster_id,
],
OUTPUT_CLUSTERS: [],
},
38: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.TEMPERATURE_SENSOR,
INPUT_CLUSTERS: [
Basic.cluster_id,
PowerConfiguration.cluster_id,
Identify.cluster_id,
PollControl.cluster_id,
TemperatureMeasurement.cluster_id,
RelativeHumidity.cluster_id,
0xFC03,
],
OUTPUT_CLUSTERS: [Identify.cluster_id, Time.cluster_id, Ota.cluster_id],
},
},
}
replacement = {
ENDPOINTS: {
1: {
PROFILE_ID: 0xC0C9,
DEVICE_TYPE: 1,
INPUT_CLUSTERS: [
Identify.cluster_id,
Scenes.cluster_id,
OnOff.cluster_id,
],
OUTPUT_CLUSTERS: [],
},
38: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.TEMPERATURE_SENSOR,
INPUT_CLUSTERS: [
Basic.cluster_id,
DevelcoPowerConfiguration,
Identify.cluster_id,
PollControl.cluster_id,
DevelcoTemperatureMeasurement,
DevelcoRelativeHumidity,
DevelcoVOCMeasurement,
EmulatedVOCMeasurement,
],
OUTPUT_CLUSTERS: [Identify.cluster_id, Time.cluster_id, Ota.cluster_id],
},
},
} | zha-quirks | /zha_quirks-0.0.103-py3-none-any.whl/zhaquirks/develco/air_quality.py | air_quality.py |
from zigpy.profiles import zha
from zigpy.quirks import CustomDevice
from zigpy.zcl.clusters.general import (
Basic,
BinaryInput,
Identify,
OnOff,
Ota,
PollControl,
PowerConfiguration,
Scenes,
Time,
)
from zigpy.zcl.clusters.measurement import (
IlluminanceMeasurement,
OccupancySensing,
TemperatureMeasurement,
)
from zigpy.zcl.clusters.security import IasZone
from zhaquirks.const import (
DEVICE_TYPE,
ENDPOINTS,
INPUT_CLUSTERS,
MODELS_INFO,
OUTPUT_CLUSTERS,
PROFILE_ID,
)
from zhaquirks.develco import DEVELCO, FRIENT, DevelcoIasZone, DevelcoPowerConfiguration
MANUFACTURER = 0x1015
class MOSZB140(CustomDevice):
"""Custom device Develco Motion Sensor Pro."""
manufacturer_id_override = MANUFACTURER
signature = {
# <SimpleDescriptor endpoint=1 profile=49353 device_type=1 device_version=1
# input_clusters=[3, 5, 6] output_clusters=[]>
# <SimpleDescriptor endpoint=34 profile=260 device_type=263 device_version=0
# input_clusters=[0, 3, 1030] output_clusters=[]>
# <SimpleDescriptor endpoint=35 profile=260 device_type=1026 device_version=0
# input_clusters=[0, 1, 3, 15, 32, 1280] output_clusters=[10, 25]>
# <SimpleDescriptor endpoint=38 profile=260 device_type=770 device_version=0
# input_clusters=[0, 3, 1026] output_clusters=[3]>
# <SimpleDescriptor endpoint=39 profile=260 device_type=262 device_version=0
# input_clusters=[0, 3, 1024] output_clusters=[]>
# <SimpleDescriptor endpoint=40 profile=260 device_type=263 device_version=0
# input_clusters=[0, 3, 1030] output_clusters=[]>
# <SimpleDescriptor endpoint=41 profile=260 device_type=263 device_version=0
# input_clusters=[0, 3, 1030] output_clusters=[]>
MODELS_INFO: [(DEVELCO, "MOSZB-140"), (FRIENT, "MOSZB-140")],
ENDPOINTS: {
1: {
PROFILE_ID: 0xC0C9,
DEVICE_TYPE: 1,
INPUT_CLUSTERS: [
Identify.cluster_id,
Scenes.cluster_id,
OnOff.cluster_id,
],
OUTPUT_CLUSTERS: [],
},
34: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.OCCUPANCY_SENSOR,
INPUT_CLUSTERS: [
Basic.cluster_id,
Identify.cluster_id,
OccupancySensing.cluster_id,
],
OUTPUT_CLUSTERS: [],
},
35: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.IAS_ZONE,
INPUT_CLUSTERS: [
Basic.cluster_id,
PowerConfiguration.cluster_id,
Identify.cluster_id,
BinaryInput.cluster_id,
PollControl.cluster_id,
IasZone.cluster_id,
],
OUTPUT_CLUSTERS: [
Time.cluster_id,
Ota.cluster_id,
],
},
38: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.TEMPERATURE_SENSOR,
INPUT_CLUSTERS: [
Basic.cluster_id,
Identify.cluster_id,
TemperatureMeasurement.cluster_id,
],
OUTPUT_CLUSTERS: [Identify.cluster_id],
},
39: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.LIGHT_SENSOR,
INPUT_CLUSTERS: [
Basic.cluster_id,
Identify.cluster_id,
IlluminanceMeasurement.cluster_id,
],
OUTPUT_CLUSTERS: [],
},
40: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.OCCUPANCY_SENSOR,
INPUT_CLUSTERS: [
Basic.cluster_id,
Identify.cluster_id,
OccupancySensing.cluster_id,
],
OUTPUT_CLUSTERS: [],
},
41: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.OCCUPANCY_SENSOR,
INPUT_CLUSTERS: [
Basic.cluster_id,
Identify.cluster_id,
OccupancySensing.cluster_id,
],
OUTPUT_CLUSTERS: [],
},
},
}
replacement = {
ENDPOINTS: {
1: {
PROFILE_ID: 0xC0C9,
DEVICE_TYPE: 1,
INPUT_CLUSTERS: [
Identify.cluster_id,
Scenes.cluster_id,
OnOff.cluster_id,
],
OUTPUT_CLUSTERS: [],
},
34: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.OCCUPANCY_SENSOR,
INPUT_CLUSTERS: [
Basic.cluster_id,
Identify.cluster_id,
OccupancySensing.cluster_id,
],
OUTPUT_CLUSTERS: [],
},
35: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.IAS_ZONE,
INPUT_CLUSTERS: [
Basic.cluster_id,
DevelcoPowerConfiguration,
Identify.cluster_id,
BinaryInput.cluster_id,
PollControl.cluster_id,
DevelcoIasZone,
],
OUTPUT_CLUSTERS: [Time.cluster_id, Ota.cluster_id],
},
38: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.TEMPERATURE_SENSOR,
INPUT_CLUSTERS: [
Basic.cluster_id,
Identify.cluster_id,
TemperatureMeasurement.cluster_id,
],
OUTPUT_CLUSTERS: [Identify.cluster_id],
},
39: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.LIGHT_SENSOR,
INPUT_CLUSTERS: [
Basic.cluster_id,
Identify.cluster_id,
IlluminanceMeasurement.cluster_id,
],
OUTPUT_CLUSTERS: [],
},
40: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.OCCUPANCY_SENSOR,
INPUT_CLUSTERS: [
Basic.cluster_id,
Identify.cluster_id,
OccupancySensing.cluster_id,
],
OUTPUT_CLUSTERS: [],
},
41: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.OCCUPANCY_SENSOR,
INPUT_CLUSTERS: [
Basic.cluster_id,
Identify.cluster_id,
OccupancySensing.cluster_id,
],
OUTPUT_CLUSTERS: [],
},
}
}
class MOSZB140_Var02(CustomDevice):
"""Custom device Develco Motion Sensor Pro (variation 02)."""
manufacturer_id_override = MANUFACTURER
signature = {
# <SimpleDescriptor endpoint=1 profile=49353 device_type=1 device_version=1
# input_clusters=[3, 5, 6] output_clusters=[]>
# <SimpleDescriptor endpoint=34 profile=260 device_type=263 device_version=0
# input_clusters=[0, 3, 1030] output_clusters=[]>
# <SimpleDescriptor endpoint=35 profile=260 device_type=1026 device_version=0
# input_clusters=[0, 1, 3, 15, 32, 1280] output_clusters=[3, 10, 25]>
# <SimpleDescriptor endpoint=38 profile=260 device_type=770 device_version=0
# input_clusters=[0, 3, 1026] output_clusters=[]>
# <SimpleDescriptor endpoint=39 profile=260 device_type=262 device_version=0
# input_clusters=[0, 3, 1024] output_clusters=[]>
# <SimpleDescriptor endpoint=40 profile=260 device_type=263 device_version=0
# input_clusters=[0, 3, 1030] output_clusters=[]>
# <SimpleDescriptor endpoint=41 profile=260 device_type=263 device_version=0
# input_clusters=[0, 3, 1030] output_clusters=[]>
MODELS_INFO: [(DEVELCO, "MOSZB-140"), (FRIENT, "MOSZB-140")],
ENDPOINTS: {
1: {
PROFILE_ID: 0xC0C9,
DEVICE_TYPE: 1,
INPUT_CLUSTERS: [
Identify.cluster_id,
Scenes.cluster_id,
OnOff.cluster_id,
],
OUTPUT_CLUSTERS: [],
},
34: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.OCCUPANCY_SENSOR,
INPUT_CLUSTERS: [
Basic.cluster_id,
Identify.cluster_id,
OccupancySensing.cluster_id,
],
OUTPUT_CLUSTERS: [],
},
35: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.IAS_ZONE,
INPUT_CLUSTERS: [
Basic.cluster_id,
PowerConfiguration.cluster_id,
Identify.cluster_id,
BinaryInput.cluster_id,
PollControl.cluster_id,
IasZone.cluster_id,
],
OUTPUT_CLUSTERS: [
Identify.cluster_id,
Time.cluster_id,
Ota.cluster_id,
],
},
38: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.TEMPERATURE_SENSOR,
INPUT_CLUSTERS: [
Basic.cluster_id,
Identify.cluster_id,
TemperatureMeasurement.cluster_id,
],
OUTPUT_CLUSTERS: [],
},
39: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.LIGHT_SENSOR,
INPUT_CLUSTERS: [
Basic.cluster_id,
Identify.cluster_id,
IlluminanceMeasurement.cluster_id,
],
OUTPUT_CLUSTERS: [],
},
40: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.OCCUPANCY_SENSOR,
INPUT_CLUSTERS: [
Basic.cluster_id,
Identify.cluster_id,
OccupancySensing.cluster_id,
],
OUTPUT_CLUSTERS: [],
},
41: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.OCCUPANCY_SENSOR,
INPUT_CLUSTERS: [
Basic.cluster_id,
Identify.cluster_id,
OccupancySensing.cluster_id,
],
OUTPUT_CLUSTERS: [],
},
},
}
replacement = {
ENDPOINTS: {
1: {
PROFILE_ID: 0xC0C9,
DEVICE_TYPE: 1,
INPUT_CLUSTERS: [
Identify.cluster_id,
Scenes.cluster_id,
OnOff.cluster_id,
],
OUTPUT_CLUSTERS: [],
},
34: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.OCCUPANCY_SENSOR,
INPUT_CLUSTERS: [
Basic.cluster_id,
Identify.cluster_id,
OccupancySensing.cluster_id,
],
OUTPUT_CLUSTERS: [],
},
35: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.IAS_ZONE,
INPUT_CLUSTERS: [
Basic.cluster_id,
DevelcoPowerConfiguration,
Identify.cluster_id,
BinaryInput.cluster_id,
PollControl.cluster_id,
DevelcoIasZone,
],
OUTPUT_CLUSTERS: [
Identify.cluster_id,
Time.cluster_id,
Ota.cluster_id,
],
},
38: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.TEMPERATURE_SENSOR,
INPUT_CLUSTERS: [
Basic.cluster_id,
Identify.cluster_id,
TemperatureMeasurement.cluster_id,
],
OUTPUT_CLUSTERS: [],
},
39: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.LIGHT_SENSOR,
INPUT_CLUSTERS: [
Basic.cluster_id,
Identify.cluster_id,
IlluminanceMeasurement.cluster_id,
],
OUTPUT_CLUSTERS: [],
},
40: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.OCCUPANCY_SENSOR,
INPUT_CLUSTERS: [
Basic.cluster_id,
Identify.cluster_id,
OccupancySensing.cluster_id,
],
OUTPUT_CLUSTERS: [],
},
41: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.OCCUPANCY_SENSOR,
INPUT_CLUSTERS: [
Basic.cluster_id,
Identify.cluster_id,
OccupancySensing.cluster_id,
],
OUTPUT_CLUSTERS: [],
},
}
} | zha-quirks | /zha_quirks-0.0.103-py3-none-any.whl/zhaquirks/develco/motion.py | motion.py |
import zigpy.profiles.zha
from zigpy.quirks import CustomDevice
from zigpy.zcl.clusters.general import (
Basic,
BinaryInput,
Identify,
OnOff,
Ota,
PollControl,
PowerConfiguration,
Scenes,
Time,
)
from zigpy.zcl.clusters.measurement import TemperatureMeasurement
from zigpy.zcl.clusters.security import IasWd, IasZone
from zhaquirks.const import (
DEVICE_TYPE,
ENDPOINTS,
INPUT_CLUSTERS,
MODELS_INFO,
OUTPUT_CLUSTERS,
PROFILE_ID,
)
from . import DEVELCO, FRIENT, DevelcoIasZone, DevelcoPowerConfiguration
MANUFACTURER = 0x1015
class SMSZB120(CustomDevice):
"""Custom device heat alarm."""
manufacturer_id_override = MANUFACTURER
signature = {
# <SimpleDescriptor endpoint=1 profile=49353 device_type=1 device_version=1
# input_clusters=[3, 5, 6] output_clusters=[]>
# <SimpleDescriptor endpoint=35 profile=260 device_type=1026 device_version=0
# input_clusters=[0, 1, 3, 15, 32, 1280, 1282] output_clusters=[10, 25]>
# <SimpleDescriptor endpoint=38 profile=260 device_type=770 device_version=0
# input_clusters=[0, 3, 1026] output_clusters=[3]>
MODELS_INFO: [(DEVELCO, "SMSZB-120"), (FRIENT, "SMSZB-120")],
ENDPOINTS: {
1: {
PROFILE_ID: 49353,
DEVICE_TYPE: 1,
INPUT_CLUSTERS: [
Identify.cluster_id,
Scenes.cluster_id,
OnOff.cluster_id,
],
OUTPUT_CLUSTERS: [],
},
35: {
PROFILE_ID: zigpy.profiles.zha.PROFILE_ID,
DEVICE_TYPE: zigpy.profiles.zha.DeviceType.IAS_ZONE,
INPUT_CLUSTERS: [
Basic.cluster_id,
PowerConfiguration.cluster_id,
Identify.cluster_id,
BinaryInput.cluster_id,
PollControl.cluster_id,
IasZone.cluster_id,
IasWd.cluster_id,
],
OUTPUT_CLUSTERS: [Time.cluster_id, Ota.cluster_id],
},
38: {
PROFILE_ID: zigpy.profiles.zha.PROFILE_ID,
DEVICE_TYPE: zigpy.profiles.zha.DeviceType.TEMPERATURE_SENSOR,
INPUT_CLUSTERS: [
Basic.cluster_id,
Identify.cluster_id,
TemperatureMeasurement.cluster_id,
],
OUTPUT_CLUSTERS: [Identify.cluster_id],
},
},
}
replacement = {
ENDPOINTS: {
1: {
PROFILE_ID: 49353,
DEVICE_TYPE: 1,
INPUT_CLUSTERS: [
Identify.cluster_id,
Scenes.cluster_id,
OnOff.cluster_id,
],
OUTPUT_CLUSTERS: [],
},
35: {
PROFILE_ID: zigpy.profiles.zha.PROFILE_ID,
DEVICE_TYPE: zigpy.profiles.zha.DeviceType.IAS_ZONE,
INPUT_CLUSTERS: [
Basic.cluster_id,
DevelcoPowerConfiguration,
Identify.cluster_id,
BinaryInput.cluster_id,
PollControl.cluster_id,
DevelcoIasZone,
IasWd.cluster_id,
],
OUTPUT_CLUSTERS: [Time.cluster_id, Ota.cluster_id],
},
38: {
PROFILE_ID: zigpy.profiles.zha.PROFILE_ID,
DEVICE_TYPE: zigpy.profiles.zha.DeviceType.TEMPERATURE_SENSOR,
INPUT_CLUSTERS: [
Basic.cluster_id,
Identify.cluster_id,
TemperatureMeasurement.cluster_id,
],
OUTPUT_CLUSTERS: [Identify.cluster_id],
},
},
} | zha-quirks | /zha_quirks-0.0.103-py3-none-any.whl/zhaquirks/develco/smoke_alarm.py | smoke_alarm.py |
import zigpy.profiles.zha
from zigpy.quirks import CustomDevice
from zigpy.zcl.clusters.general import (
Basic,
BinaryInput,
Identify,
OnOff,
Ota,
PollControl,
PowerConfiguration,
Scenes,
Time,
)
from zigpy.zcl.clusters.measurement import TemperatureMeasurement
from zigpy.zcl.clusters.security import IasWd, IasZone
from zhaquirks.const import (
DEVICE_TYPE,
ENDPOINTS,
INPUT_CLUSTERS,
MODELS_INFO,
OUTPUT_CLUSTERS,
PROFILE_ID,
)
from zhaquirks.develco import DEVELCO, FRIENT, DevelcoIasZone, DevelcoPowerConfiguration
MANUFACTURER = 0x1015
class HESZB120(CustomDevice):
"""Custom device heat alarm."""
manufacturer_id_override = MANUFACTURER
signature = {
# <SimpleDescriptor endpoint=1 profile=49353 device_type=1 device_version=1
# input_clusters=[3, 5, 6] output_clusters=[]>
# <SimpleDescriptor endpoint=35 profile=260 device_type=1026 device_version=0
# input_clusters=[0, 1, 3, 15, 32, 1280, 1282] output_clusters=[10, 25]>
# <SimpleDescriptor endpoint=38 profile=260 device_type=770 device_version=0
# input_clusters=[0, 3, 1026] output_clusters=[3]>
MODELS_INFO: [(DEVELCO, "HESZB-120"), (FRIENT, "HESZB-120")],
ENDPOINTS: {
1: {
PROFILE_ID: 49353,
DEVICE_TYPE: 1,
INPUT_CLUSTERS: [
Identify.cluster_id,
Scenes.cluster_id,
OnOff.cluster_id,
],
OUTPUT_CLUSTERS: [],
},
35: {
PROFILE_ID: zigpy.profiles.zha.PROFILE_ID,
DEVICE_TYPE: zigpy.profiles.zha.DeviceType.IAS_CONTROL,
INPUT_CLUSTERS: [
Basic.cluster_id,
PowerConfiguration.cluster_id,
Identify.cluster_id,
BinaryInput.cluster_id,
PollControl.cluster_id,
IasZone.cluster_id,
IasWd.cluster_id,
],
OUTPUT_CLUSTERS: [Time.cluster_id, Ota.cluster_id],
},
38: {
PROFILE_ID: zigpy.profiles.zha.PROFILE_ID,
DEVICE_TYPE: zigpy.profiles.zha.DeviceType.TEMPERATURE_SENSOR,
INPUT_CLUSTERS: [
Basic.cluster_id,
Identify.cluster_id,
TemperatureMeasurement.cluster_id,
],
OUTPUT_CLUSTERS: [Identify.cluster_id],
},
},
}
replacement = {
ENDPOINTS: {
1: {
PROFILE_ID: 49353,
DEVICE_TYPE: 1,
INPUT_CLUSTERS: [
Identify.cluster_id,
Scenes.cluster_id,
OnOff.cluster_id,
],
OUTPUT_CLUSTERS: [],
},
35: {
PROFILE_ID: zigpy.profiles.zha.PROFILE_ID,
DEVICE_TYPE: zigpy.profiles.zha.DeviceType.IAS_CONTROL,
INPUT_CLUSTERS: [
Basic.cluster_id,
DevelcoPowerConfiguration,
Identify.cluster_id,
BinaryInput.cluster_id,
PollControl.cluster_id,
DevelcoIasZone,
IasWd.cluster_id,
],
OUTPUT_CLUSTERS: [Time.cluster_id, Ota.cluster_id],
},
38: {
PROFILE_ID: zigpy.profiles.zha.PROFILE_ID,
DEVICE_TYPE: zigpy.profiles.zha.DeviceType.TEMPERATURE_SENSOR,
INPUT_CLUSTERS: [
Basic.cluster_id,
Identify.cluster_id,
TemperatureMeasurement.cluster_id,
],
OUTPUT_CLUSTERS: [Identify.cluster_id],
},
},
}
class HESZB120F(CustomDevice):
"""Frient A/S Heat Alarm."""
manufacturer_id_override = MANUFACTURER
signature = {
# <SimpleDescriptor endpoint=1 profile=49353 device_type=1 device_version=1
# input_clusters=[3, 5, 6] output_clusters=[]>
# <SimpleDescriptor endpoint=35 profile=260 device_type=1026 device_version=0
# input_clusters=[0, 1, 3, 15, 32, 1280, 1282] output_clusters=[10, 25]>
# <SimpleDescriptor endpoint=38 profile=260 device_type=770 device_version=0
# input_clusters=[0, 3, 1026] output_clusters=[3]>
MODELS_INFO: [
(FRIENT, "HESZB-120"),
],
ENDPOINTS: {
1: {
PROFILE_ID: 49353,
DEVICE_TYPE: 1,
INPUT_CLUSTERS: [
Identify.cluster_id,
Scenes.cluster_id,
OnOff.cluster_id,
],
OUTPUT_CLUSTERS: [],
},
35: {
PROFILE_ID: zigpy.profiles.zha.PROFILE_ID,
DEVICE_TYPE: zigpy.profiles.zha.DeviceType.IAS_ZONE,
INPUT_CLUSTERS: [
Basic.cluster_id,
PowerConfiguration.cluster_id,
Identify.cluster_id,
BinaryInput.cluster_id,
PollControl.cluster_id,
IasZone.cluster_id,
IasWd.cluster_id,
],
OUTPUT_CLUSTERS: [Time.cluster_id, Ota.cluster_id],
},
38: {
PROFILE_ID: zigpy.profiles.zha.PROFILE_ID,
DEVICE_TYPE: zigpy.profiles.zha.DeviceType.TEMPERATURE_SENSOR,
INPUT_CLUSTERS: [
Basic.cluster_id,
Identify.cluster_id,
TemperatureMeasurement.cluster_id,
],
OUTPUT_CLUSTERS: [Identify.cluster_id],
},
},
}
replacement = {
ENDPOINTS: {
1: {
PROFILE_ID: 49353,
DEVICE_TYPE: 1,
INPUT_CLUSTERS: [
Identify.cluster_id,
Scenes.cluster_id,
OnOff.cluster_id,
],
OUTPUT_CLUSTERS: [],
},
35: {
PROFILE_ID: zigpy.profiles.zha.PROFILE_ID,
DEVICE_TYPE: zigpy.profiles.zha.DeviceType.IAS_ZONE,
INPUT_CLUSTERS: [
Basic.cluster_id,
DevelcoPowerConfiguration,
Identify.cluster_id,
BinaryInput.cluster_id,
PollControl.cluster_id,
DevelcoIasZone,
IasWd.cluster_id,
],
OUTPUT_CLUSTERS: [Time.cluster_id, Ota.cluster_id],
},
38: {
PROFILE_ID: zigpy.profiles.zha.PROFILE_ID,
DEVICE_TYPE: zigpy.profiles.zha.DeviceType.TEMPERATURE_SENSOR,
INPUT_CLUSTERS: [
Basic.cluster_id,
Identify.cluster_id,
TemperatureMeasurement.cluster_id,
],
OUTPUT_CLUSTERS: [Identify.cluster_id],
},
},
} | zha-quirks | /zha_quirks-0.0.103-py3-none-any.whl/zhaquirks/develco/heat_alarm.py | heat_alarm.py |
from zigpy.profiles import zha
from zigpy.quirks import CustomCluster, CustomDevice
from zigpy.zcl.clusters.general import (
Alarms,
Basic,
DeviceTemperature,
Groups,
Identify,
OnOff,
Ota,
Scenes,
Time,
)
from zigpy.zcl.clusters.homeautomation import ElectricalMeasurement
from zigpy.zcl.clusters.measurement import OccupancySensing
from zigpy.zcl.clusters.smartenergy import Metering
from zhaquirks.const import (
DEVICE_TYPE,
ENDPOINTS,
INPUT_CLUSTERS,
MODELS_INFO,
OUTPUT_CLUSTERS,
PROFILE_ID,
)
from zhaquirks.develco import DEVELCO
DEV_TEMP_ID = DeviceTemperature.attributes_by_name["current_temperature"].id
class DevelcoDeviceTemperature(CustomCluster, DeviceTemperature):
"""Custom device temperature cluster to multiply the temperature by 100."""
def _update_attribute(self, attrid, value):
if attrid == DEV_TEMP_ID:
value = value * 100
super()._update_attribute(attrid, value)
class SPLZB131(CustomDevice):
"""Custom device Develco smart plug device."""
signature = {
MODELS_INFO: [(DEVELCO, "SPLZB-131")],
ENDPOINTS: {
1: {
PROFILE_ID: 0xC0C9,
DEVICE_TYPE: 1,
INPUT_CLUSTERS: [
Scenes.cluster_id,
OnOff.cluster_id,
],
OUTPUT_CLUSTERS: [],
},
2: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.SMART_PLUG,
INPUT_CLUSTERS: [
Basic.cluster_id,
DeviceTemperature.cluster_id,
Identify.cluster_id,
Groups.cluster_id,
Scenes.cluster_id,
OnOff.cluster_id,
Alarms.cluster_id,
Metering.cluster_id,
ElectricalMeasurement.cluster_id,
],
OUTPUT_CLUSTERS: [
Basic.cluster_id,
Identify.cluster_id,
Time.cluster_id,
Ota.cluster_id,
OccupancySensing.cluster_id,
],
},
},
}
replacement = {
ENDPOINTS: {
2: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.SMART_PLUG,
INPUT_CLUSTERS: [
Basic.cluster_id,
DevelcoDeviceTemperature,
Identify.cluster_id,
Groups.cluster_id,
Scenes.cluster_id,
OnOff.cluster_id,
Alarms.cluster_id,
Metering.cluster_id,
ElectricalMeasurement.cluster_id,
],
OUTPUT_CLUSTERS: [
Basic.cluster_id,
Identify.cluster_id,
Time.cluster_id,
Ota.cluster_id,
OccupancySensing.cluster_id,
],
},
}
} | zha-quirks | /zha_quirks-0.0.103-py3-none-any.whl/zhaquirks/develco/power_plug.py | power_plug.py |
# pylint disable=C0103
from zigpy.profiles import zha
from zigpy.quirks import CustomDevice
from zigpy.zcl.clusters.general import (
Basic,
Identify,
OnOff,
OnOffConfiguration,
Ota,
PollControl,
PowerConfiguration,
)
from zigpy.zcl.clusters.homeautomation import Diagnostic
from zhaquirks import PowerConfigurationCluster
from zhaquirks.centralite import CENTRALITE
from zhaquirks.const import (
BUTTON_1,
BUTTON_2,
BUTTON_3,
BUTTON_4,
COMMAND,
COMMAND_PRESS,
DEVICE_TYPE,
ENDPOINT_ID,
ENDPOINTS,
INPUT_CLUSTERS,
MODELS_INFO,
OUTPUT_CLUSTERS,
PROFILE_ID,
SHORT_PRESS,
)
class CustomPowerConfigurationCluster(PowerConfigurationCluster):
"""Custom PowerConfigurationCluster."""
cluster_id = PowerConfiguration.cluster_id
MIN_VOLTS = 2.1
MAX_VOLTS = 3.0
class CentraLite3450L(CustomDevice):
"""Custom device representing centralite 3450L."""
signature = {
# <SimpleDescriptor endpoint=1 profile=260 device_type=6
# device_version=0
# input_clusters=[0, 1, 3, 7, 20, b05]
# output_clusters=[3, 6, 19]>
MODELS_INFO: [(CENTRALITE, "3450-L"), (CENTRALITE, "3450-L2")],
ENDPOINTS: {
1: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.REMOTE_CONTROL,
INPUT_CLUSTERS: [
Basic.cluster_id,
PowerConfiguration.cluster_id,
Identify.cluster_id,
OnOffConfiguration.cluster_id,
PollControl.cluster_id,
Diagnostic.cluster_id,
],
OUTPUT_CLUSTERS: [
Identify.cluster_id,
OnOff.cluster_id,
Ota.cluster_id,
],
},
2: {
# input_clusters=[7]
# output_clusters=[6]>
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.REMOTE_CONTROL,
INPUT_CLUSTERS: [OnOffConfiguration.cluster_id],
OUTPUT_CLUSTERS: [OnOff.cluster_id],
},
3: {
# input_clusters=[7]
# output_clusters=[6]>
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.REMOTE_CONTROL,
INPUT_CLUSTERS: [OnOffConfiguration.cluster_id],
OUTPUT_CLUSTERS: [OnOff.cluster_id],
},
4: {
# input_clusters=[7]
# output_clusters=[6]>
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.REMOTE_CONTROL,
INPUT_CLUSTERS: [OnOffConfiguration.cluster_id],
OUTPUT_CLUSTERS: [OnOff.cluster_id],
},
},
}
replacement = {
ENDPOINTS: {
1: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.REMOTE_CONTROL,
INPUT_CLUSTERS: [
Basic.cluster_id,
CustomPowerConfigurationCluster,
Identify.cluster_id,
OnOffConfiguration.cluster_id,
PollControl.cluster_id,
Diagnostic.cluster_id,
],
OUTPUT_CLUSTERS: [
Identify.cluster_id,
OnOff.cluster_id,
Ota.cluster_id,
],
},
2: {
# input_clusters=[7]
# output_clusters=[6]>
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.REMOTE_CONTROL,
INPUT_CLUSTERS: [OnOffConfiguration.cluster_id],
OUTPUT_CLUSTERS: [OnOff.cluster_id],
},
3: {
# input_clusters=[7]
# output_clusters=[6]>
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.REMOTE_CONTROL,
INPUT_CLUSTERS: [OnOffConfiguration.cluster_id],
OUTPUT_CLUSTERS: [OnOff.cluster_id],
},
4: {
# input_clusters=[7]
# output_clusters=[6]>
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.REMOTE_CONTROL,
INPUT_CLUSTERS: [OnOffConfiguration.cluster_id],
OUTPUT_CLUSTERS: [OnOff.cluster_id],
},
}
}
device_automation_triggers = {
(SHORT_PRESS, BUTTON_1): {COMMAND: COMMAND_PRESS, ENDPOINT_ID: 1},
(SHORT_PRESS, BUTTON_2): {COMMAND: COMMAND_PRESS, ENDPOINT_ID: 2},
(SHORT_PRESS, BUTTON_3): {COMMAND: COMMAND_PRESS, ENDPOINT_ID: 3},
(SHORT_PRESS, BUTTON_4): {COMMAND: COMMAND_PRESS, ENDPOINT_ID: 4},
} | zha-quirks | /zha_quirks-0.0.103-py3-none-any.whl/zhaquirks/centralite/motionandtemp.py | motionandtemp.py |
from zigpy.profiles import zha
from zigpy.quirks import CustomDevice
from zigpy.zcl.clusters.general import Basic, Identify, Ota, PollControl, Time
from zigpy.zcl.clusters.homeautomation import Diagnostic
from zigpy.zcl.clusters.hvac import Fan, Thermostat, UserInterface
from zhaquirks import PowerConfigurationCluster
from zhaquirks.centralite import CENTRALITE
from zhaquirks.const import (
DEVICE_TYPE,
ENDPOINTS,
INPUT_CLUSTERS,
MODELS_INFO,
OUTPUT_CLUSTERS,
PROFILE_ID,
)
class CentraLite3157100(CustomDevice):
"""Custom device representing centralite 3157100."""
signature = {
# <SimpleDescriptor endpoint=1 profile=260 device_type=769
# device_version=0
# input_clusters=[0, 1, 3, 513, 514, 516, 32, 2821]
# output_clusters=[10, 25]>
MODELS_INFO: [(CENTRALITE, "3157100"), ("Centralite", "3157100")],
ENDPOINTS: {
1: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.THERMOSTAT,
INPUT_CLUSTERS: [
Basic.cluster_id,
PowerConfigurationCluster.cluster_id,
Identify.cluster_id,
Thermostat.cluster_id,
Fan.cluster_id,
UserInterface.cluster_id,
PollControl.cluster_id,
Diagnostic.cluster_id,
],
OUTPUT_CLUSTERS: [Time.cluster_id, Ota.cluster_id],
}
},
}
replacement = {
ENDPOINTS: {
1: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.THERMOSTAT,
INPUT_CLUSTERS: [
Basic.cluster_id,
PowerConfigurationCluster,
Identify.cluster_id,
Thermostat.cluster_id,
Fan.cluster_id,
UserInterface.cluster_id,
PollControl.cluster_id,
Diagnostic.cluster_id,
],
OUTPUT_CLUSTERS: [Time.cluster_id, Ota.cluster_id],
}
}
} | zha-quirks | /zha_quirks-0.0.103-py3-none-any.whl/zhaquirks/centralite/cl_3157100.py | cl_3157100.py |
from zigpy.profiles import zha
from zigpy.quirks import CustomDevice
from zigpy.zcl.clusters.general import Basic, Identify, Ota, PollControl
from zigpy.zcl.clusters.homeautomation import Diagnostic
from zigpy.zcl.clusters.measurement import OccupancySensing, TemperatureMeasurement
from zigpy.zcl.clusters.security import IasZone
from zhaquirks import PowerConfigurationCluster
from zhaquirks.centralite import CENTRALITE
from zhaquirks.const import (
DEVICE_TYPE,
ENDPOINTS,
INPUT_CLUSTERS,
MODELS_INFO,
OUTPUT_CLUSTERS,
PROFILE_ID,
)
class CentraLite3305S(CustomDevice):
"""Custom device representing centralite 3305."""
signature = {
# <SimpleDescriptor endpoint=1 profile=260 device_type=1026
# device_version=0
# input_clusters=[0, 1, 3, 1026, 1280, 32, 2821]
# output_clusters=[25]>
MODELS_INFO: [
(CENTRALITE, "3305-S"),
(CENTRALITE, "3305"),
(CENTRALITE, "3325-S"),
(CENTRALITE, "3325"),
(CENTRALITE, "3326-L"),
(CENTRALITE, "3326"),
(CENTRALITE, "3328-G"),
(CENTRALITE, "Motion Sensor-A"),
],
ENDPOINTS: {
1: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.IAS_ZONE,
INPUT_CLUSTERS: [
Basic.cluster_id,
PowerConfigurationCluster.cluster_id,
Identify.cluster_id,
PollControl.cluster_id,
TemperatureMeasurement.cluster_id,
IasZone.cluster_id,
Diagnostic.cluster_id,
],
OUTPUT_CLUSTERS: [Ota.cluster_id],
},
# <SimpleDescriptor endpoint=2 profile=260 device_type=263
# device_version=0
# input_clusters=[0, 1, 3, 1030, 2821]
# output_clusters=[3]>
2: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.OCCUPANCY_SENSOR,
INPUT_CLUSTERS: [
Basic.cluster_id,
PowerConfigurationCluster.cluster_id,
Identify.cluster_id,
OccupancySensing.cluster_id,
Diagnostic.cluster_id,
],
OUTPUT_CLUSTERS: [Identify.cluster_id],
},
},
}
replacement = {
ENDPOINTS: {
1: {
INPUT_CLUSTERS: [
Basic.cluster_id,
PowerConfigurationCluster,
Identify.cluster_id,
PollControl.cluster_id,
TemperatureMeasurement.cluster_id,
IasZone.cluster_id,
Diagnostic.cluster_id,
],
OUTPUT_CLUSTERS: [Ota.cluster_id],
},
2: {
INPUT_CLUSTERS: [
Basic.cluster_id,
Identify.cluster_id,
OccupancySensing.cluster_id,
Diagnostic.cluster_id,
],
OUTPUT_CLUSTERS: [Identify.cluster_id],
},
}
}
class CentraLite3305S2(CentraLite3305S):
"""Custom device representing centralite 3305 with one endpoint."""
signature = {
MODELS_INFO: [(CENTRALITE, "3305")],
ENDPOINTS: {1: {**CentraLite3305S.signature["endpoints"][1]}},
}
replacement = {ENDPOINTS: {1: {**CentraLite3305S.replacement["endpoints"][1]}}} | zha-quirks | /zha_quirks-0.0.103-py3-none-any.whl/zhaquirks/centralite/cl_3305S.py | cl_3305S.py |
from zigpy.profiles import zha
from zigpy.quirks import CustomDevice
from zigpy.zcl.clusters.general import Basic, BinaryInput, Identify, Ota, PollControl
from zigpy.zcl.clusters.homeautomation import Diagnostic
from zigpy.zcl.clusters.measurement import TemperatureMeasurement
from zigpy.zcl.clusters.security import IasZone
from zhaquirks import PowerConfigurationCluster
from zhaquirks.centralite import CENTRALITE
from zhaquirks.const import (
DEVICE_TYPE,
ENDPOINTS,
INPUT_CLUSTERS,
MODELS_INFO,
OUTPUT_CLUSTERS,
PROFILE_ID,
)
MANUFACTURER_SPECIFIC_CLUSTER_ID = 0xFC0F # decimal = 64527
MANUFACTURER_SPECIFIC_PROFILE_ID = 0xC2DF # decimal = 49887
class CentraLiteIASSensor(CustomDevice):
"""Custom device representing centralite ias sensors."""
signature = {
# <SimpleDescriptor endpoint=1 profile=260 device_type=1026
# device_version=0
# input_clusters=[0, 1, 3, 32, 1026, 1280, 2821]
# output_clusters=[25]>
MODELS_INFO: [
(CENTRALITE, "3300-S"),
(CENTRALITE, "3315-G"),
(CENTRALITE, "3315-L"),
(CENTRALITE, "3315-S"),
(CENTRALITE, "3315-Seu"),
(CENTRALITE, "3315"),
(CENTRALITE, "3320-L"),
(CENTRALITE, "Contact Sensor-A"),
],
ENDPOINTS: {
1: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.IAS_ZONE,
INPUT_CLUSTERS: [
Basic.cluster_id,
PowerConfigurationCluster.cluster_id,
Identify.cluster_id,
PollControl.cluster_id,
TemperatureMeasurement.cluster_id,
IasZone.cluster_id,
Diagnostic.cluster_id,
],
OUTPUT_CLUSTERS: [Ota.cluster_id],
},
# <SimpleDescriptor endpoint=2 profile=49887 device_type=12
# device_version=0
# input_clusters=[0, 1, 3, 2821, 64527]
# output_clusters=[3]>
2: {
PROFILE_ID: MANUFACTURER_SPECIFIC_PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.SIMPLE_SENSOR,
INPUT_CLUSTERS: [
Basic.cluster_id,
PowerConfigurationCluster.cluster_id,
Identify.cluster_id,
Diagnostic.cluster_id,
MANUFACTURER_SPECIFIC_CLUSTER_ID,
],
OUTPUT_CLUSTERS: [Identify.cluster_id],
},
},
}
replacement = {
ENDPOINTS: {
1: {
INPUT_CLUSTERS: [
Basic.cluster_id,
PowerConfigurationCluster,
Identify.cluster_id,
PollControl.cluster_id,
TemperatureMeasurement.cluster_id,
IasZone.cluster_id,
Diagnostic.cluster_id,
],
OUTPUT_CLUSTERS: [Ota.cluster_id],
},
2: {
INPUT_CLUSTERS: [
Basic.cluster_id,
Identify.cluster_id,
Diagnostic.cluster_id,
MANUFACTURER_SPECIFIC_CLUSTER_ID,
],
OUTPUT_CLUSTERS: [Identify.cluster_id],
},
}
}
class CentraLiteIASSensorV2(CustomDevice):
"""Custom device representing centralite ias sensors."""
signature = {
# <SimpleDescriptor endpoint=1 profile=260 device_type=1026
# device_version=0
# input_clusters=[0, 1, 3, 32, 1026, 1280, 2821]
# output_clusters=[25]>
MODELS_INFO: CentraLiteIASSensor.signature[MODELS_INFO],
ENDPOINTS: {
1: CentraLiteIASSensor.signature[ENDPOINTS][1],
# <SimpleDescriptor endpoint=2 profile=49887 device_type=12
# device_version=0
# input_clusters=[0, 1, 3, 15, 2821, 64527]
# output_clusters=[3]>
2: {
PROFILE_ID: MANUFACTURER_SPECIFIC_PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.SIMPLE_SENSOR,
INPUT_CLUSTERS: [
Basic.cluster_id,
BinaryInput.cluster_id,
PowerConfigurationCluster.cluster_id,
Identify.cluster_id,
Diagnostic.cluster_id,
MANUFACTURER_SPECIFIC_CLUSTER_ID,
],
OUTPUT_CLUSTERS: [Identify.cluster_id],
},
},
}
replacement = CentraLiteIASSensor.replacement
class CentraLiteIASSensorV3(CustomDevice):
"""Custom device representing centralite ias sensors."""
signature = {
# <SimpleDescriptor endpoint=1 profile=260 device_type=1026
# device_version=0
# input_clusters=[0, 1, 3, 32, 1026, 1280, 2821]
# output_clusters=[25]>
MODELS_INFO: CentraLiteIASSensor.signature[MODELS_INFO],
ENDPOINTS: {
1: CentraLiteIASSensor.signature[ENDPOINTS][1],
# <SimpleDescriptor endpoint=2 profile=49887 device_type=12
# device_version=0
# input_clusters=[0, 1, 3, 15, 2821]
# output_clusters=[3]>
2: {
PROFILE_ID: MANUFACTURER_SPECIFIC_PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.SIMPLE_SENSOR,
INPUT_CLUSTERS: [
Basic.cluster_id,
BinaryInput.cluster_id,
PowerConfigurationCluster.cluster_id,
Identify.cluster_id,
Diagnostic.cluster_id,
],
OUTPUT_CLUSTERS: [Identify.cluster_id],
},
},
}
replacement = CentraLiteIASSensor.replacement | zha-quirks | /zha_quirks-0.0.103-py3-none-any.whl/zhaquirks/centralite/ias.py | ias.py |
from zigpy.profiles import zha
from zigpy.quirks import CustomDevice
from zigpy.zcl.clusters.general import (
Basic,
Identify,
LevelControl,
OnOff,
Ota,
PollControl,
)
from zigpy.zcl.clusters.homeautomation import Diagnostic
from zigpy.zcl.clusters.measurement import TemperatureMeasurement
from zhaquirks import PowerConfigurationCluster
from zhaquirks.centralite import CENTRALITE
from zhaquirks.const import (
COMMAND,
COMMAND_MOVE,
COMMAND_MOVE_ON_OFF,
COMMAND_OFF,
COMMAND_ON,
DEVICE_TYPE,
DIM_DOWN,
DIM_UP,
ENDPOINTS,
INPUT_CLUSTERS,
MODELS_INFO,
OUTPUT_CLUSTERS,
PROFILE_ID,
SHORT_PRESS,
TURN_OFF,
TURN_ON,
)
from zhaquirks.osram import OSRAM
class CustomPowerConfigurationCluster(PowerConfigurationCluster):
"""Custom PowerConfigurationCluster."""
cluster_id = PowerConfigurationCluster.cluster_id
MIN_VOLTS = 2.1
MAX_VOLTS = 3.0
class CentraLite3130(CustomDevice):
"""Custom device representing centralite 3130."""
signature = {
# <SimpleDescriptor endpoint=1 profile=260 device_type=1
# device_version=0
# input_clusters=[0, 1, 3, 32, 1026, 2821]
# output_clusters=[3, 6, 8, 25]>
MODELS_INFO: [(OSRAM, "LIGHTIFY Dimming Switch"), (CENTRALITE, "3130")],
ENDPOINTS: {
1: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.LEVEL_CONTROL_SWITCH,
INPUT_CLUSTERS: [
Basic.cluster_id,
CustomPowerConfigurationCluster.cluster_id,
Identify.cluster_id,
PollControl.cluster_id,
TemperatureMeasurement.cluster_id,
Diagnostic.cluster_id,
],
OUTPUT_CLUSTERS: [
Identify.cluster_id,
OnOff.cluster_id,
LevelControl.cluster_id,
Ota.cluster_id,
],
}
},
}
replacement = {
ENDPOINTS: {
1: {
INPUT_CLUSTERS: [
Basic.cluster_id,
CustomPowerConfigurationCluster,
Identify.cluster_id,
PollControl.cluster_id,
Diagnostic.cluster_id,
],
OUTPUT_CLUSTERS: [
Identify.cluster_id,
OnOff.cluster_id,
LevelControl.cluster_id,
Ota.cluster_id,
],
}
}
}
device_automation_triggers = {
(SHORT_PRESS, TURN_ON): {COMMAND: COMMAND_ON},
(SHORT_PRESS, TURN_OFF): {COMMAND: COMMAND_OFF},
(SHORT_PRESS, DIM_UP): {COMMAND: COMMAND_MOVE_ON_OFF},
(SHORT_PRESS, DIM_DOWN): {COMMAND: COMMAND_MOVE},
} | zha-quirks | /zha_quirks-0.0.103-py3-none-any.whl/zhaquirks/centralite/cl_3130.py | cl_3130.py |
from zigpy.profiles import zha
from zigpy.quirks import CustomDevice
from zigpy.zcl.clusters.general import Basic, Identify, Ota, PollControl
from zigpy.zcl.clusters.homeautomation import Diagnostic
from zigpy.zcl.clusters.measurement import TemperatureMeasurement
from zigpy.zcl.clusters.security import IasZone
from zhaquirks import PowerConfigurationCluster
from zhaquirks.centralite import CENTRALITE
from zhaquirks.const import (
DEVICE_TYPE,
ENDPOINTS,
INPUT_CLUSTERS,
MODELS_INFO,
OUTPUT_CLUSTERS,
PROFILE_ID,
)
MANUFACTURER_SPECIFIC_CLUSTER_ID = 0xFC46 # decimal = 64582
MANUFACTURER_SPECIFIC_PROFILE_ID = 0xC2DF # decimal = 49887
class CentraLiteMotionSensor(CustomDevice):
"""Custom device representing centralite motion (only) sensors."""
signature = {
# <SimpleDescriptor endpoint=1 profile=260 device_type=1026
# device_version=0
# input_clusters=[0, 1, 3, 1026, 1280, 32, 2821]
# output_clusters=[25]>
MODELS_INFO: [
(CENTRALITE, "3305-S"),
(CENTRALITE, "3325-S"),
(CENTRALITE, "3326-L"),
],
ENDPOINTS: {
1: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.IAS_ZONE,
INPUT_CLUSTERS: [
Basic.cluster_id,
PowerConfigurationCluster.cluster_id,
Identify.cluster_id,
PollControl.cluster_id,
TemperatureMeasurement.cluster_id,
IasZone.cluster_id,
Diagnostic.cluster_id,
],
OUTPUT_CLUSTERS: [Ota.cluster_id],
},
# <SimpleDescriptor endpoint=2 profile=49887 device_type=263
# device_version=0
# input_clusters=[0, 1, 3, 2821, 64582]
# output_clusters=[3]>
2: {
PROFILE_ID: MANUFACTURER_SPECIFIC_PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.OCCUPANCY_SENSOR,
INPUT_CLUSTERS: [
Basic.cluster_id,
PowerConfigurationCluster.cluster_id,
Identify.cluster_id,
Diagnostic.cluster_id,
MANUFACTURER_SPECIFIC_CLUSTER_ID,
],
OUTPUT_CLUSTERS: [Identify.cluster_id],
},
},
}
replacement = {
ENDPOINTS: {
1: {
INPUT_CLUSTERS: [
Basic.cluster_id,
PowerConfigurationCluster,
Identify.cluster_id,
PollControl.cluster_id,
TemperatureMeasurement.cluster_id,
IasZone.cluster_id,
Diagnostic.cluster_id,
],
OUTPUT_CLUSTERS: [Ota.cluster_id],
},
2: {
INPUT_CLUSTERS: [
Basic.cluster_id,
Identify.cluster_id,
Diagnostic.cluster_id,
MANUFACTURER_SPECIFIC_CLUSTER_ID,
],
OUTPUT_CLUSTERS: [Identify.cluster_id],
},
}
} | zha-quirks | /zha_quirks-0.0.103-py3-none-any.whl/zhaquirks/centralite/motion.py | motion.py |
# pylint disable=C0103
from zigpy.profiles import zha
from zigpy.quirks import CustomDevice
from zigpy.zcl.clusters.general import (
Basic,
Identify,
OnOff,
OnOffConfiguration,
Ota,
PollControl,
)
from zigpy.zcl.clusters.homeautomation import Diagnostic
from zigpy.zcl.clusters.measurement import TemperatureMeasurement
from zhaquirks import PowerConfigurationCluster
from zhaquirks.centralite import CENTRALITE
from zhaquirks.const import (
BUTTON_1,
COMMAND,
COMMAND_OFF,
COMMAND_ON,
DEVICE_TYPE,
ENDPOINTS,
INPUT_CLUSTERS,
MODELS_INFO,
OUTPUT_CLUSTERS,
PROFILE_ID,
SHORT_PRESS,
SHORT_RELEASE,
)
class CustomPowerConfigurationCluster(PowerConfigurationCluster):
"""Custom PowerConfigurationCluster."""
cluster_id = PowerConfigurationCluster.cluster_id
MIN_VOLTS = 2.1
MAX_VOLTS = 3.0
class CentraLite3460L(CustomDevice):
"""Custom device representing centralite 3460L."""
signature = {
# <SimpleDescriptor endpoint=1 profile=260 device_type=6
# device_version=0
# input_clusters=[0, 1, 3, 7, 32, 1026, 2821]
# output_clusters=[3, 6, 25]>
MODELS_INFO: [(CENTRALITE, "3460-L")],
ENDPOINTS: {
1: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.REMOTE_CONTROL,
INPUT_CLUSTERS: [
Basic.cluster_id,
CustomPowerConfigurationCluster.cluster_id,
Identify.cluster_id,
OnOffConfiguration.cluster_id,
PollControl.cluster_id,
TemperatureMeasurement.cluster_id,
Diagnostic.cluster_id,
],
OUTPUT_CLUSTERS: [
Identify.cluster_id,
OnOff.cluster_id,
Ota.cluster_id,
],
}
},
}
replacement = {
ENDPOINTS: {
1: {
INPUT_CLUSTERS: [
Basic.cluster_id,
CustomPowerConfigurationCluster,
Identify.cluster_id,
OnOffConfiguration.cluster_id,
PollControl.cluster_id,
TemperatureMeasurement.cluster_id,
Diagnostic.cluster_id,
],
OUTPUT_CLUSTERS: [
Identify.cluster_id,
OnOff.cluster_id,
Ota.cluster_id,
],
}
}
}
device_automation_triggers = {
(SHORT_PRESS, BUTTON_1): {COMMAND: COMMAND_ON},
(SHORT_RELEASE, BUTTON_1): {COMMAND: COMMAND_OFF},
} | zha-quirks | /zha_quirks-0.0.103-py3-none-any.whl/zhaquirks/centralite/cl_3460L.py | cl_3460L.py |
from zigpy.profiles import zha
from zigpy.quirks import CustomCluster, CustomDevice
import zigpy.types as t
from zigpy.zcl.clusters.general import Basic, Identify, Ota, PollControl
from zigpy.zcl.clusters.homeautomation import Diagnostic
from zigpy.zcl.clusters.measurement import TemperatureMeasurement
from zhaquirks import PowerConfigurationCluster
from zhaquirks.centralite import CENTRALITE
from zhaquirks.const import (
DEVICE_TYPE,
ENDPOINTS,
INPUT_CLUSTERS,
MODELS_INFO,
OUTPUT_CLUSTERS,
PROFILE_ID,
)
SMRT_THINGS_REL_HUM_CLSTR = 0xFC45
class SmartthingsRelativeHumidityCluster(CustomCluster):
"""Smart Things Relative Humidity Cluster."""
cluster_id = SMRT_THINGS_REL_HUM_CLSTR
name = "Smartthings Relative Humidity Measurement"
ep_attribute = "humidity"
attributes = {
# Relative Humidity Measurement Information
0x0000: ("measured_value", t.int16s, True)
}
class CentraLite3310S(CustomDevice):
"""CentraLite3310S custom device implementation."""
signature = {
# <SimpleDescriptor endpoint=1 profile=260 device_type=770
# device_version=0
# input_clusters=[0, 1, 3, 32, 1026, 2821, 64581]
# output_clusters=[3, 25]>
MODELS_INFO: [
(CENTRALITE, "3310-G"),
(CENTRALITE, "3310-S"),
(CENTRALITE, "3310"),
],
ENDPOINTS: {
1: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.TEMPERATURE_SENSOR,
INPUT_CLUSTERS: [
Basic.cluster_id,
PowerConfigurationCluster.cluster_id,
Identify.cluster_id,
PollControl.cluster_id,
TemperatureMeasurement.cluster_id,
Diagnostic.cluster_id,
SmartthingsRelativeHumidityCluster.cluster_id,
],
OUTPUT_CLUSTERS: [Identify.cluster_id, Ota.cluster_id],
}
},
}
replacement = {
ENDPOINTS: {
1: {
INPUT_CLUSTERS: [
Basic.cluster_id,
PowerConfigurationCluster,
Identify.cluster_id,
PollControl.cluster_id,
TemperatureMeasurement.cluster_id,
Diagnostic.cluster_id,
SmartthingsRelativeHumidityCluster,
],
OUTPUT_CLUSTERS: [Identify.cluster_id, Ota.cluster_id],
}
}
} | zha-quirks | /zha_quirks-0.0.103-py3-none-any.whl/zhaquirks/centralite/cl_3310S.py | cl_3310S.py |
# pylint disable=C0103
from zigpy.profiles import zha
from zigpy.quirks import CustomDevice
from zigpy.zcl.clusters.general import Basic, Identify, Ota, PollControl
from zigpy.zcl.clusters.homeautomation import Diagnostic
from zigpy.zcl.clusters.measurement import TemperatureMeasurement
from zigpy.zcl.clusters.security import IasZone
from zhaquirks import PowerConfigurationCluster
from zhaquirks.centralite import CENTRALITE, CentraLiteAccelCluster
from zhaquirks.const import (
DEVICE_TYPE,
ENDPOINTS,
INPUT_CLUSTERS,
MODELS_INFO,
OUTPUT_CLUSTERS,
PROFILE_ID,
)
from zhaquirks.samjin import SAMJIN
MANUFACTURER_SPECIFIC_CLUSTER_ID = 0xFC0F # decimal = 64527
MANUFACTURER_SPECIFIC_PROFILE_ID = 0xC2DF # decimal = 49887
class CentraLite3321S(CustomDevice):
"""CentraLite3321S custom device implementation."""
signature = {
# <SimpleDescriptor endpoint=1 profile=260 device_type=1026
# device_version=0
# input_clusters=[0, 1, 3, 1026, 1280, 32, 2821, 64514]
# output_clusters=[25]>
MODELS_INFO: [
(CENTRALITE, "3320"),
(CENTRALITE, "3321-S"),
(CENTRALITE, "3321"),
(SAMJIN, "multi"),
],
ENDPOINTS: {
1: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.IAS_ZONE,
INPUT_CLUSTERS: [
Basic.cluster_id,
PowerConfigurationCluster.cluster_id,
Identify.cluster_id,
PollControl.cluster_id,
TemperatureMeasurement.cluster_id,
IasZone.cluster_id,
Diagnostic.cluster_id,
CentraLiteAccelCluster.cluster_id,
],
OUTPUT_CLUSTERS: [Ota.cluster_id],
},
# <SimpleDescriptor endpoint=2 profile=49887 device_type=12
# device_version=0
# input_clusters=[0, 1, 3, 2821, 64527]
# output_clusters=[3]>
2: {
PROFILE_ID: MANUFACTURER_SPECIFIC_PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.SIMPLE_SENSOR,
INPUT_CLUSTERS: [
Basic.cluster_id,
PowerConfigurationCluster.cluster_id,
Identify.cluster_id,
Diagnostic.cluster_id,
MANUFACTURER_SPECIFIC_CLUSTER_ID,
],
OUTPUT_CLUSTERS: [Identify.cluster_id],
},
},
}
replacement = {
ENDPOINTS: {
1: {
INPUT_CLUSTERS: [
Basic.cluster_id,
PowerConfigurationCluster,
Identify.cluster_id,
PollControl.cluster_id,
TemperatureMeasurement.cluster_id,
IasZone.cluster_id,
Diagnostic.cluster_id,
CentraLiteAccelCluster,
],
OUTPUT_CLUSTERS: [Ota.cluster_id],
},
2: {
INPUT_CLUSTERS: [
Basic.cluster_id,
Identify.cluster_id,
Diagnostic.cluster_id,
MANUFACTURER_SPECIFIC_CLUSTER_ID,
],
OUTPUT_CLUSTERS: [Identify.cluster_id],
},
}
} | zha-quirks | /zha_quirks-0.0.103-py3-none-any.whl/zhaquirks/centralite/cl_3321S.py | cl_3321S.py |
from zigpy.profiles import zha
from zigpy.quirks import CustomDevice
from zigpy.zcl.clusters.general import Basic, BinaryInput, Identify, Ota, PollControl
from zigpy.zcl.clusters.homeautomation import Diagnostic
from zigpy.zcl.clusters.measurement import TemperatureMeasurement
from zigpy.zcl.clusters.security import IasZone
from zhaquirks import PowerConfigurationCluster
from zhaquirks.centralite import CENTRALITE
from zhaquirks.const import (
DEVICE_TYPE,
ENDPOINTS,
INPUT_CLUSTERS,
MODELS_INFO,
OUTPUT_CLUSTERS,
PROFILE_ID,
)
MANUFACTURER_SPECIFIC_PROFILE_ID = 0xC2DF # decimal = 49887
class CentraLite3300S(CustomDevice):
"""Custom device representing centralite 3300."""
signature = {
# <SimpleDescriptor endpoint=1 profile=260 device_type=1026
# device_version=0
# input_clusters=[0, 1, 3, 1026, 1280, 32, 2821]
# output_clusters=[25]>
MODELS_INFO: [
(CENTRALITE, "3300"),
(CENTRALITE, "3300-S"),
(CENTRALITE, "3323-G"),
],
ENDPOINTS: {
1: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.IAS_ZONE,
INPUT_CLUSTERS: [
Basic.cluster_id,
PowerConfigurationCluster.cluster_id,
Identify.cluster_id,
PollControl.cluster_id,
TemperatureMeasurement.cluster_id,
IasZone.cluster_id,
Diagnostic.cluster_id,
],
OUTPUT_CLUSTERS: [Ota.cluster_id],
},
# <SimpleDescriptor endpoint=2 profile=49887 device_type=12
# device_version=0
# input_clusters=[0, 1, 3, 15, 2821]
# output_clusters=[3]>
2: {
PROFILE_ID: MANUFACTURER_SPECIFIC_PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.SIMPLE_SENSOR,
INPUT_CLUSTERS: [
Basic.cluster_id,
PowerConfigurationCluster.cluster_id,
Identify.cluster_id,
BinaryInput.cluster_id,
Diagnostic.cluster_id,
],
OUTPUT_CLUSTERS: [Identify.cluster_id],
},
},
}
replacement = {
ENDPOINTS: {
1: {
INPUT_CLUSTERS: [
Basic.cluster_id,
PowerConfigurationCluster,
Identify.cluster_id,
PollControl.cluster_id,
TemperatureMeasurement.cluster_id,
IasZone.cluster_id,
Diagnostic.cluster_id,
],
OUTPUT_CLUSTERS: [Ota.cluster_id],
},
2: {
INPUT_CLUSTERS: [
Basic.cluster_id,
Identify.cluster_id,
Diagnostic.cluster_id,
],
OUTPUT_CLUSTERS: [Identify.cluster_id],
},
}
} | zha-quirks | /zha_quirks-0.0.103-py3-none-any.whl/zhaquirks/centralite/cl_3300S.py | cl_3300S.py |
from zigpy.profiles import zha
from zigpy.quirks import CustomDevice
from zigpy.zcl.clusters.general import Basic, Identify, Ota, PollControl
from zigpy.zcl.clusters.homeautomation import Diagnostic
from zigpy.zcl.clusters.measurement import TemperatureMeasurement
from zigpy.zcl.clusters.security import IasZone
from zhaquirks import PowerConfigurationCluster
from zhaquirks.const import (
DEVICE_TYPE,
ENDPOINTS,
INPUT_CLUSTERS,
MODELS_INFO,
OUTPUT_CLUSTERS,
PROFILE_ID,
)
from zhaquirks.imagic import IMAGIC
MANUFACTURER_SPECIFIC_CLUSTER_ID = 0xFC01 # decimal = 64513
MANUFACTURER_SPECIFIC_CLUSTER_ID_2 = 0xFC02 # decimal = 64514
class iMagic1116(CustomDevice):
"""Custom device representing iMagic 1116-S sensor."""
signature = {
# <SimpleDescriptor endpoint=1 profile=260 device_type=1026
# device_version=0
# input_clusters=[0, 1, 3, 32, 1026, 1280, 2821, 64513, 64514]
# output_clusters=[3, 25]>
MODELS_INFO: [(IMAGIC, "1116-S")],
ENDPOINTS: {
1: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.IAS_ZONE,
INPUT_CLUSTERS: [
Basic.cluster_id,
PowerConfigurationCluster.cluster_id,
Identify.cluster_id,
MANUFACTURER_SPECIFIC_CLUSTER_ID,
MANUFACTURER_SPECIFIC_CLUSTER_ID_2,
PollControl.cluster_id,
TemperatureMeasurement.cluster_id,
IasZone.cluster_id,
Diagnostic.cluster_id,
],
OUTPUT_CLUSTERS: [Ota.cluster_id, Identify.cluster_id],
},
},
}
replacement = {
ENDPOINTS: {
1: {
INPUT_CLUSTERS: [
Basic.cluster_id,
PowerConfigurationCluster,
Identify.cluster_id,
MANUFACTURER_SPECIFIC_CLUSTER_ID,
MANUFACTURER_SPECIFIC_CLUSTER_ID_2,
PollControl.cluster_id,
TemperatureMeasurement.cluster_id,
IasZone.cluster_id,
Diagnostic.cluster_id,
],
OUTPUT_CLUSTERS: [Ota.cluster_id, Identify.cluster_id],
},
}
} | zha-quirks | /zha_quirks-0.0.103-py3-none-any.whl/zhaquirks/imagic/im1116s.py | im1116s.py |
from zigpy.profiles import zha
from zigpy.quirks import CustomDevice
from zigpy.zcl.clusters.general import (
Basic,
Identify,
Ota,
PollControl,
PowerConfiguration,
)
from zigpy.zcl.clusters.homeautomation import Diagnostic
from zigpy.zcl.clusters.measurement import RelativeHumidity, TemperatureMeasurement
from zigpy.zcl.clusters.security import IasZone
from zhaquirks import PowerConfigurationCluster
from zhaquirks.const import (
DEVICE_TYPE,
ENDPOINTS,
INPUT_CLUSTERS,
MODELS_INFO,
OUTPUT_CLUSTERS,
PROFILE_ID,
)
from zhaquirks.imagic import IMAGIC
MANUFACTURER_SPECIFIC_PROFILE_ID = 0xFC01
MANUFACTURER_SPECIFIC_PROFILE_ID2 = 0xFC02
class Greatstar(CustomDevice):
"""Custom device representing iMagic by Greatstar motion sensors."""
signature = {
# <SimpleDescriptor endpoint=1 profile=260 device_type=0x0402
# device_version=0
# input_clusters=["0x0000", "0x0001", "0x0003","0x0020","0x0402", "0x0405", "0x0500", "0x0b05","0xfc01","0xfc02"]
# output_clusters=["0x0003","0x0019"]>
MODELS_INFO: [(IMAGIC, "1117-S")],
ENDPOINTS: {
1: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.IAS_ZONE,
INPUT_CLUSTERS: [
Basic.cluster_id,
PowerConfiguration.cluster_id,
Identify.cluster_id,
PollControl.cluster_id,
TemperatureMeasurement.cluster_id,
RelativeHumidity.cluster_id,
IasZone.cluster_id,
Diagnostic.cluster_id,
MANUFACTURER_SPECIFIC_PROFILE_ID,
MANUFACTURER_SPECIFIC_PROFILE_ID2,
],
OUTPUT_CLUSTERS: [Identify.cluster_id, Ota.cluster_id],
}
},
}
replacement = {
ENDPOINTS: {
1: {
INPUT_CLUSTERS: [
Basic,
PowerConfigurationCluster,
Identify,
PollControl,
TemperatureMeasurement,
RelativeHumidity,
IasZone,
Diagnostic,
MANUFACTURER_SPECIFIC_PROFILE_ID,
MANUFACTURER_SPECIFIC_PROFILE_ID2,
],
OUTPUT_CLUSTERS: [Identify, Ota],
}
}
} | zha-quirks | /zha_quirks-0.0.103-py3-none-any.whl/zhaquirks/imagic/gs1117s.py | gs1117s.py |
from __future__ import annotations
import logging
import math
from typing import Any, Iterable, Iterator
from zigpy import types as t
import zigpy.device
from zigpy.profiles import zha
from zigpy.quirks import CustomCluster, CustomDevice
from zigpy.zcl.clusters.general import (
AnalogInput,
Basic,
BinaryOutput,
DeviceTemperature,
OnOff,
PowerConfiguration,
)
from zigpy.zcl.clusters.homeautomation import ElectricalMeasurement
from zigpy.zcl.clusters.manufacturer_specific import ManufacturerSpecificCluster
from zigpy.zcl.clusters.measurement import (
IlluminanceMeasurement,
PressureMeasurement,
RelativeHumidity,
TemperatureMeasurement,
)
from zigpy.zcl.clusters.security import IasZone
from zigpy.zcl.clusters.smartenergy import Metering
import zigpy.zcl.foundation as foundation
import zigpy.zdo
from zigpy.zdo.types import NodeDescriptor
from zhaquirks import (
LocalDataCluster,
MotionOnEvent,
OccupancyWithReset,
QuickInitDevice,
)
from zhaquirks.const import (
ATTRIBUTE_ID,
ATTRIBUTE_NAME,
COMMAND_ATTRIBUTE_UPDATED,
COMMAND_TRIPLE,
UNKNOWN,
VALUE,
ZHA_SEND_EVENT,
)
BATTERY_LEVEL = "battery_level"
BATTERY_PERCENTAGE_REMAINING = 0x0021
BATTERY_PERCENTAGE_REMAINING_ATTRIBUTE = "battery_percentage"
BATTERY_SIZE = "battery_size"
BATTERY_SIZE_ATTR = 0x0031
BATTERY_QUANTITY_ATTR = 0x0033
BATTERY_VOLTAGE_MV = "battery_voltage_mV"
HUMIDITY_MEASUREMENT = "humidity_measurement"
LUMI = "LUMI"
MODEL = 5
MOTION_SENSITIVITY = "motion_sensitivity"
DETECTION_INTERVAL = "detection_interval"
MOTION_TYPE = 0x000D
OCCUPANCY_STATE = 0
PATH = "path"
POWER = "power"
CONSUMPTION = "consumption"
VOLTAGE = "voltage"
PRESSURE_MEASUREMENT = "pressure_measurement"
STATE = "state"
TEMPERATURE = "temperature"
TEMPERATURE_MEASUREMENT = "temperature_measurement"
TVOC_MEASUREMENT = "tvoc_measurement"
POWER_OUTAGE_COUNT = "power_outage_count"
PRESENCE_DETECTED = "presence_detected"
PRESENCE_EVENT = "presence_event"
MONITORING_MODE = "monitoring_mode"
APPROACH_DISTANCE = "approach_distance"
ILLUMINANCE_MEASUREMENT = "illuminance_measurement"
SMOKE = "smoke"
SMOKE_DENSITY = "smoke_density"
SELF_TEST = "self_test"
BUZZER_MANUAL_MUTE = "buzzer_manual_mute"
HEARTBEAT_INDICATOR = "heartbeat_indicator"
LINKAGE_ALARM = "linkage_alarm"
LINKAGE_ALARM_STATE = "linkage_alarm_state"
XIAOMI_AQARA_ATTRIBUTE = 0xFF01
XIAOMI_AQARA_ATTRIBUTE_E1 = 0x00F7
XIAOMI_ATTR_3 = "X-attrib-3"
XIAOMI_ATTR_4 = "X-attrib-4"
XIAOMI_ATTR_5 = "X-attrib-5"
XIAOMI_ATTR_6 = "X-attrib-6"
XIAOMI_MIJA_ATTRIBUTE = 0xFF02
XIAOMI_NODE_DESC = NodeDescriptor(
byte1=2,
byte2=64,
mac_capability_flags=128,
manufacturer_code=4151,
maximum_buffer_size=127,
maximum_incoming_transfer_size=100,
server_mask=0,
maximum_outgoing_transfer_size=100,
descriptor_capability_field=0,
)
_LOGGER = logging.getLogger(__name__)
class XiaomiCustomDevice(CustomDevice):
"""Custom device representing xiaomi devices."""
def __init__(self, *args, **kwargs):
"""Init."""
if not hasattr(self, BATTERY_SIZE):
self.battery_size = 10
super().__init__(*args, **kwargs)
class XiaomiQuickInitDevice(XiaomiCustomDevice, QuickInitDevice):
"""Xiaomi devices eligible for QuickInit."""
class XiaomiCluster(CustomCluster):
"""Xiaomi cluster implementation."""
def _iter_parse_attr_report(
self, data: bytes
) -> Iterator[tuple[foundation.Attribute, bytes]]:
"""Yield all interpretations of the first attribute in a Xiaomi report."""
# Peek at the attribute report
attr_id, data = t.uint16_t.deserialize(data)
attr_type, data = t.uint8_t.deserialize(data)
if (
attr_id
not in (
XIAOMI_AQARA_ATTRIBUTE,
XIAOMI_MIJA_ATTRIBUTE,
XIAOMI_AQARA_ATTRIBUTE_E1,
)
or attr_type != 0x42 # "Character String"
):
# Assume other attributes are reported correctly
data = attr_id.serialize() + attr_type.serialize() + data
attribute, data = foundation.Attribute.deserialize(data)
yield attribute, data
return
# Length of the "string" can be wrong
val_len, data = t.uint8_t.deserialize(data)
# Try every offset. Start with 0 to pass unbroken reports through.
for offset in (0, -1, 1):
fixed_len = val_len + offset
if len(data) < fixed_len:
continue
val, final_data = data[:fixed_len], data[fixed_len:]
attr_val = t.LVBytes(val)
attr_type = 0x41 # The data type should be "Octet String"
yield foundation.Attribute(
attrid=attr_id,
value=foundation.TypeValue(type=attr_type, value=attr_val),
), final_data
def _interpret_attr_reports(
self, data: bytes
) -> Iterable[tuple[foundation.Attribute]]:
"""Yield all valid interprations of a Xiaomi attribute report."""
if not data:
yield ()
return
try:
parsed = list(self._iter_parse_attr_report(data))
except (KeyError, ValueError):
return
for attr, remaining_data in parsed:
for remaining_attrs in self._interpret_attr_reports(remaining_data):
yield (attr,) + remaining_attrs
def deserialize(self, data):
"""Deserialize cluster data."""
hdr, data = foundation.ZCLHeader.deserialize(data)
# Only handle attribute reports differently
if (
hdr.frame_control.frame_type != foundation.FrameType.GLOBAL_COMMAND
or hdr.command_id != foundation.GeneralCommand.Report_Attributes
):
return super().deserialize(hdr.serialize() + data)
reports = list(self._interpret_attr_reports(data))
if not reports:
_LOGGER.warning("Failed to parse Xiaomi attribute report: %r", data)
return super().deserialize(hdr.serialize() + data)
elif len(reports) > 1:
_LOGGER.warning(
"Xiaomi attribute report has multiple valid interpretations: %r",
reports,
)
fixed_data = b"".join(attr.serialize() for attr in reports[0])
return super().deserialize(hdr.serialize() + fixed_data)
def _update_attribute(self, attrid, value):
if attrid in (XIAOMI_AQARA_ATTRIBUTE, XIAOMI_AQARA_ATTRIBUTE_E1):
attributes = self._parse_aqara_attributes(value)
super()._update_attribute(attrid, value)
if self.endpoint.device.model == "lumi.sensor_switch.aq2":
if value == b"\x04!\xa8C\n!\x00\x00":
self.listener_event(ZHA_SEND_EVENT, COMMAND_TRIPLE, [])
elif attrid == XIAOMI_MIJA_ATTRIBUTE:
attributes = self._parse_mija_attributes(value)
else:
super()._update_attribute(attrid, value)
if attrid == MODEL:
# 0x0005 = model attribute.
# Xiaomi sensors send the model attribute when their reset button is
# pressed quickly."""
if attrid in self.attributes:
attribute_name = self.attributes[attrid].name
else:
attribute_name = UNKNOWN
self.listener_event(
ZHA_SEND_EVENT,
COMMAND_ATTRIBUTE_UPDATED,
{
ATTRIBUTE_ID: attrid,
ATTRIBUTE_NAME: attribute_name,
VALUE: value,
},
)
return
_LOGGER.debug(
"%s - Xiaomi attribute report. attribute_id: [%s] value: [%s]",
self.endpoint.device.ieee,
attrid,
attributes,
)
if BATTERY_VOLTAGE_MV in attributes:
# many Xiaomi devices report this, but not all quirks implement the XiaomiPowerConfiguration cluster,
# so we might error out if the method doesn't exist
if hasattr(self.endpoint.power, "battery_reported") and callable(
self.endpoint.power.battery_reported
):
self.endpoint.power.battery_reported(attributes[BATTERY_VOLTAGE_MV])
else:
# log a debug message if the cluster is not implemented
_LOGGER.debug(
"%s - Xiaomi battery voltage attribute received but XiaomiPowerConfiguration not used",
self.endpoint.device.ieee,
)
if TEMPERATURE_MEASUREMENT in attributes:
self.endpoint.temperature.update_attribute(
TemperatureMeasurement.AttributeDefs.measured_value.id,
attributes[TEMPERATURE_MEASUREMENT],
)
if HUMIDITY_MEASUREMENT in attributes:
self.endpoint.humidity.update_attribute(
RelativeHumidity.AttributeDefs.measured_value.id,
attributes[HUMIDITY_MEASUREMENT],
)
if PRESSURE_MEASUREMENT in attributes:
self.endpoint.pressure.update_attribute(
PressureMeasurement.AttributeDefs.measured_value.id,
attributes[PRESSURE_MEASUREMENT] / 100,
)
if POWER in attributes:
self.endpoint.electrical_measurement.update_attribute(
ElectricalMeasurement.AttributeDefs.active_power.id,
round(attributes[POWER] * 10),
)
if CONSUMPTION in attributes:
zcl_consumption = round(attributes[CONSUMPTION] * 1000)
self.endpoint.electrical_measurement.update_attribute(
ElectricalMeasurement.AttributeDefs.total_active_power.id,
zcl_consumption,
)
self.endpoint.smartenergy_metering.update_attribute(
Metering.AttributeDefs.current_summ_delivered.id, zcl_consumption
)
if VOLTAGE in attributes:
self.endpoint.electrical_measurement.update_attribute(
ElectricalMeasurement.AttributeDefs.rms_voltage.id,
attributes[VOLTAGE] * 0.1,
)
if ILLUMINANCE_MEASUREMENT in attributes:
self.endpoint.illuminance.update_attribute(
IlluminanceMeasurement.AttributeDefs.measured_value.id,
attributes[ILLUMINANCE_MEASUREMENT],
)
if TVOC_MEASUREMENT in attributes:
self.endpoint.voc_level.update_attribute(
0x0000, attributes[TVOC_MEASUREMENT]
)
if TEMPERATURE in attributes:
if hasattr(self.endpoint, "device_temperature"):
self.endpoint.device_temperature.update_attribute(
DeviceTemperature.AttributeDefs.current_temperature.id,
attributes[TEMPERATURE] * 100,
)
if BATTERY_PERCENTAGE_REMAINING_ATTRIBUTE in attributes:
self.endpoint.power.battery_percent_reported(
attributes[BATTERY_PERCENTAGE_REMAINING_ATTRIBUTE]
)
if SMOKE in attributes:
self.endpoint.ias_zone.update_attribute(
IasZone.AttributeDefs.zone_status.id, attributes[SMOKE]
)
def _parse_aqara_attributes(self, value):
"""Parse non-standard attributes."""
attributes = {}
attribute_names = {
1: BATTERY_VOLTAGE_MV,
3: TEMPERATURE,
4: XIAOMI_ATTR_4,
5: XIAOMI_ATTR_5,
6: XIAOMI_ATTR_6,
10: PATH,
}
if self.endpoint.device.model in [
"lumi.sensor_ht",
"lumi.sens",
"lumi.weather",
"lumi.airmonitor.acn01",
"lumi.sensor_ht.agl02",
]:
# Temperature sensors send temperature/humidity/pressure updates through this
# cluster instead of the respective clusters
attribute_names.update(
{
100: TEMPERATURE_MEASUREMENT,
101: HUMIDITY_MEASUREMENT,
102: TVOC_MEASUREMENT
if self.endpoint.device.model == "lumi.airmonitor.acn01"
else PRESSURE_MEASUREMENT,
}
)
elif self.endpoint.device.model in [
"lumi.plug",
"lumi.plug.maus01",
"lumi.plug.maeu01",
"lumi.plug.mmeu01",
"lumi.relay.c2acn01",
"lumi.switch.n0agl1",
"lumi.switch.n0acn2",
]:
attribute_names.update({149: CONSUMPTION, 150: VOLTAGE, 152: POWER})
elif self.endpoint.device.model == "lumi.sensor_motion.aq2":
attribute_names.update({11: ILLUMINANCE_MEASUREMENT})
elif self.endpoint.device.model == "lumi.curtain.acn002":
attribute_names.update({101: BATTERY_PERCENTAGE_REMAINING_ATTRIBUTE})
elif self.endpoint.device.model in ["lumi.motion.agl02", "lumi.motion.ac02"]:
attribute_names.update({101: ILLUMINANCE_MEASUREMENT})
if self.endpoint.device.model == "lumi.motion.ac02":
attribute_names.update({105: DETECTION_INTERVAL})
attribute_names.update({106: MOTION_SENSITIVITY})
elif self.endpoint.device.model == "lumi.motion.agl04":
attribute_names.update({102: DETECTION_INTERVAL})
attribute_names.update({105: MOTION_SENSITIVITY})
attribute_names.update({258: DETECTION_INTERVAL})
attribute_names.update({268: MOTION_SENSITIVITY})
elif self.endpoint.device.model == "lumi.motion.ac01":
attribute_names.update({5: POWER_OUTAGE_COUNT})
attribute_names.update({101: PRESENCE_DETECTED})
attribute_names.update({102: PRESENCE_EVENT})
attribute_names.update({103: MONITORING_MODE})
attribute_names.update({105: APPROACH_DISTANCE})
attribute_names.update({268: MOTION_SENSITIVITY})
attribute_names.update({322: PRESENCE_DETECTED})
attribute_names.update({323: PRESENCE_EVENT})
attribute_names.update({324: MONITORING_MODE})
attribute_names.update({326: APPROACH_DISTANCE})
elif self.endpoint.device.model == "lumi.sensor_smoke.acn03":
attribute_names.update({160: SMOKE})
attribute_names.update({161: SMOKE_DENSITY})
attribute_names.update({162: SELF_TEST})
attribute_names.update({163: BUZZER_MANUAL_MUTE})
attribute_names.update({164: HEARTBEAT_INDICATOR})
attribute_names.update({165: LINKAGE_ALARM})
result = {}
# Some attribute reports end with a stray null byte
while value not in (b"", b"\x00"):
skey = int(value[0])
svalue, value = foundation.TypeValue.deserialize(value[1:])
result[skey] = svalue.value
for item, val in result.items():
key = (
attribute_names[item]
if item in attribute_names
else "0xff01-" + str(item)
)
attributes[key] = val
return attributes
def _parse_mija_attributes(self, value):
"""Parse non-standard attributes."""
attribute_names = (
STATE,
BATTERY_VOLTAGE_MV,
XIAOMI_ATTR_3,
XIAOMI_ATTR_4,
XIAOMI_ATTR_5,
XIAOMI_ATTR_6,
)
result = []
for attr_value in value:
result.append(attr_value.value)
attributes = dict(zip(attribute_names, result))
return attributes
class BasicCluster(XiaomiCluster, Basic):
"""Xiaomi basic cluster implementation."""
class XiaomiAqaraE1Cluster(XiaomiCluster, ManufacturerSpecificCluster):
"""Xiaomi mfg cluster implementation."""
cluster_id = 0xFCC0
class BinaryOutputInterlock(CustomCluster, BinaryOutput):
"""Xiaomi binaryoutput cluster with added interlock attribute."""
attributes = BinaryOutput.attributes.copy()
attributes[0xFF06] = ("interlock", t.Bool, True)
class XiaomiPowerConfiguration(PowerConfiguration, LocalDataCluster):
"""Xiaomi power configuration cluster implementation."""
BATTERY_VOLTAGE_ATTR = PowerConfiguration.AttributeDefs.battery_voltage.id
BATTERY_PERCENTAGE_REMAINING = (
PowerConfiguration.AttributeDefs.battery_percentage_remaining.id
)
MAX_VOLTS_MV = 3100
MIN_VOLTS_MV = 2820
def __init__(self, *args, **kwargs):
"""Init."""
super().__init__(*args, **kwargs)
self._CONSTANT_ATTRIBUTES = {
BATTERY_QUANTITY_ATTR: 1,
BATTERY_SIZE_ATTR: getattr(self.endpoint.device, BATTERY_SIZE, 0xFF),
}
self._slope = 200 / (self.MAX_VOLTS_MV - self.MIN_VOLTS_MV)
def battery_reported(self, voltage_mv: int) -> None:
"""Battery reported."""
self._update_attribute(self.BATTERY_VOLTAGE_ATTR, round(voltage_mv / 100, 1))
self._update_battery_percentage(voltage_mv)
def battery_percent_reported(self, battery_percent: int) -> None:
"""Battery reported as percentage."""
self._update_attribute(self.BATTERY_PERCENTAGE_REMAINING, battery_percent * 2)
def _update_battery_percentage(self, voltage_mv: int) -> None:
voltage_mv = max(voltage_mv, self.MIN_VOLTS_MV)
voltage_mv = min(voltage_mv, self.MAX_VOLTS_MV)
percent = round((voltage_mv - self.MIN_VOLTS_MV) * self._slope)
_LOGGER.debug(
"Voltage mV: [Min]:%s < [RAW]:%s < [Max]:%s, Battery Percent: %s",
self.MIN_VOLTS_MV,
voltage_mv,
self.MAX_VOLTS_MV,
percent / 2,
)
self._update_attribute(self.BATTERY_PERCENTAGE_REMAINING, percent)
class OccupancyCluster(OccupancyWithReset):
"""Occupancy cluster."""
class MotionCluster(LocalDataCluster, MotionOnEvent):
"""Motion cluster."""
_CONSTANT_ATTRIBUTES = {IasZone.AttributeDefs.zone_type.id: MOTION_TYPE}
reset_s: int = 70
class DeviceTemperatureCluster(LocalDataCluster, DeviceTemperature):
"""Device Temperature Cluster."""
class XiaomiMeteringCluster(LocalDataCluster, Metering):
"""Xiaomi Metering Cluster."""
class TemperatureMeasurementCluster(CustomCluster, TemperatureMeasurement):
"""Temperature cluster that filters out invalid temperature readings."""
def _update_attribute(self, attrid, value):
# drop values above and below documented range for this sensor
# value is in centi degrees
if attrid == self.AttributeDefs.measured_value.id and (-6000 <= value <= 6000):
super()._update_attribute(attrid, value)
class RelativeHumidityCluster(CustomCluster, RelativeHumidity):
"""Humidity cluster that filters out invalid humidity readings."""
def _update_attribute(self, attrid, value):
# drop values above and below documented range for this sensor
if attrid == self.AttributeDefs.measured_value.id and (0 <= value <= 9999):
super()._update_attribute(attrid, value)
class PressureMeasurementCluster(CustomCluster, PressureMeasurement):
"""Pressure cluster to receive reports that are sent to the basic cluster."""
def _update_attribute(self, attrid, value):
# drop unreasonable values
# value is in hectopascals
if attrid == self.AttributeDefs.measured_value.id and (0 <= value <= 1100):
super()._update_attribute(attrid, value)
class AnalogInputCluster(CustomCluster, AnalogInput):
"""Analog input cluster, only used to relay power consumption information to ElectricalMeasurementCluster.
The AnalogInput cluster responsible for reporting power consumption seems to be on endpoint 21 for newer devices
and either on endpoint 1 or 2 for older devices.
"""
def _update_attribute(self, attrid, value):
super()._update_attribute(attrid, value)
if (
attrid == self.AttributeDefs.present_value.id
and value is not None
and value >= 0
):
# ElectricalMeasurementCluster is assumed to be on endpoint 1
self.endpoint.device.endpoints[1].electrical_measurement.update_attribute(
ElectricalMeasurement.AttributeDefs.active_power.id,
round(value * 10),
)
class ElectricalMeasurementCluster(LocalDataCluster, ElectricalMeasurement):
"""Electrical measurement cluster to receive reports that are sent to the basic cluster."""
POWER_ID = ElectricalMeasurement.AttributeDefs.active_power.id
VOLTAGE_ID = ElectricalMeasurement.AttributeDefs.rms_voltage.id
CONSUMPTION_ID = ElectricalMeasurement.AttributeDefs.total_active_power.id
_CONSTANT_ATTRIBUTES = {
ElectricalMeasurement.AttributeDefs.power_multiplier.id: 1,
ElectricalMeasurement.AttributeDefs.power_divisor.id: 1,
ElectricalMeasurement.AttributeDefs.ac_power_multiplier.id: 1,
ElectricalMeasurement.AttributeDefs.ac_power_divisor.id: 10,
}
def __init__(self, *args, **kwargs):
"""Init."""
super().__init__(*args, **kwargs)
# put a default value so the sensors are created
if self.POWER_ID not in self._attr_cache:
self._update_attribute(self.POWER_ID, 0)
if self.VOLTAGE_ID not in self._attr_cache:
self._update_attribute(self.VOLTAGE_ID, 0)
if self.CONSUMPTION_ID not in self._attr_cache:
self._update_attribute(self.CONSUMPTION_ID, 0)
class MeteringCluster(LocalDataCluster, Metering):
"""Metering cluster to receive reports that are sent to the basic cluster."""
CURRENT_SUMM_DELIVERED_ID = Metering.AttributeDefs.current_summ_delivered.id
_CONSTANT_ATTRIBUTES = {
Metering.AttributeDefs.unit_of_measure.id: 0, # kWh
Metering.AttributeDefs.multiplier.id: 1,
Metering.AttributeDefs.divisor.id: 1000,
Metering.AttributeDefs.summation_formatting.id: 0b0_0100_011, # read from plug
Metering.AttributeDefs.metering_device_type.id: 0, # electric
}
def __init__(self, *args, **kwargs):
"""Init."""
super().__init__(*args, **kwargs)
# put a default value so the sensor is created
if self.CURRENT_SUMM_DELIVERED_ID not in self._attr_cache:
self._update_attribute(self.CURRENT_SUMM_DELIVERED_ID, 0)
class IlluminanceMeasurementCluster(CustomCluster, IlluminanceMeasurement):
"""Illuminance measurement cluster."""
def _update_attribute(self, attrid, value):
if attrid == self.AttributeDefs.measured_value.id and value > 0:
value = 10000 * math.log10(value) + 1
super()._update_attribute(attrid, value)
class OnOffCluster(OnOff, CustomCluster):
"""Aqara wall switch cluster."""
def command(
self,
command_id: foundation.GeneralCommand | int | t.uint8_t,
*args,
manufacturer: int | t.uint16_t | None = None,
expect_reply: bool = True,
tsn: int | t.uint8_t | None = None,
**kwargs: Any,
):
"""Command handler."""
src_ep = 1
dst_ep = self.endpoint.endpoint_id
device = self.endpoint.device
if tsn is None:
tsn = self._endpoint.device.application.get_sequence()
return device.request(
# device,
zha.PROFILE_ID,
OnOff.cluster_id,
src_ep,
dst_ep,
tsn,
bytes([src_ep, tsn, command_id]),
expect_reply=expect_reply,
)
def handle_quick_init(
sender: zigpy.device.Device,
profile: int,
cluster: int,
src_ep: int,
dst_ep: int,
message: bytes,
) -> bool | None:
"""Handle message from an uninitialized device which could be a xiaomi."""
if src_ep == 0:
return
hdr, data = foundation.ZCLHeader.deserialize(message)
sender.debug(
"""Received ZCL while uninitialized on endpoint id %s, cluster 0x%04x """
"""id, hdr: %s, payload: %s""",
src_ep,
cluster,
hdr,
data,
)
if hdr.frame_control.is_cluster:
return
if hdr.command_id not in foundation.COMMANDS:
sender.debug("Unknown ZCL global command: %s", hdr.command_id)
return
try:
params, data = foundation.COMMANDS[hdr.command_id].schema.deserialize(data)
except ValueError:
sender.debug("Failed to deserialize ZCL global command")
return
sender.debug("Uninitialized device command '%s' params: %s", hdr.command_id, params)
if (
hdr.command_id != foundation.GeneralCommand.Report_Attributes
or cluster != 0x0000
):
return
for attr_rec in params.attribute_reports:
# model_name
if attr_rec.attrid == 0x0005:
break
else:
return
model = attr_rec.value.value
if not model:
return
for quirk in zigpy.quirks.get_quirk_list(LUMI, model):
if not issubclass(quirk, XiaomiQuickInitDevice):
continue
sender.debug("Found '%s' quirk for '%s' model", quirk.__name__, model)
try:
sender = quirk.from_signature(sender, model)
except (AssertionError, KeyError) as ex:
_LOGGER.debug("Found quirk for quick init, but failed to init: %s", str(ex))
continue
break
else:
return
sender.cancel_initialization()
sender.application.device_initialized(sender)
sender.info(
"Was quickly initialized from '%s.%s' quirk", quirk.__module__, quirk.__name__
)
return True
zigpy.quirks.register_uninitialized_device_message_handler(handle_quick_init) | zha-quirks | /zha_quirks-0.0.103-py3-none-any.whl/zhaquirks/xiaomi/__init__.py | __init__.py |
from zigpy.profiles import zha
from zigpy.zcl.clusters.general import Basic, Ota
from zigpy.zcl.clusters.measurement import OccupancySensing
from zhaquirks import Bus
from zhaquirks.const import (
DEVICE_TYPE,
ENDPOINTS,
INPUT_CLUSTERS,
MODELS_INFO,
OUTPUT_CLUSTERS,
PROFILE_ID,
SKIP_CONFIGURATION,
)
from zhaquirks.xiaomi import (
LUMI,
BasicCluster,
IlluminanceMeasurementCluster,
MotionCluster,
OccupancyCluster,
XiaomiCustomDevice,
XiaomiPowerConfiguration,
)
XIAOMI_CLUSTER_ID = 0xFFFF
class MotionAQ2(XiaomiCustomDevice):
"""Custom device representing aqara body sensors."""
def __init__(self, *args, **kwargs):
"""Init."""
self.battery_size = 9
self.motion_bus = Bus()
super().__init__(*args, **kwargs)
signature = {
# <SimpleDescriptor endpoint=1 profile=260 device_type=260
# device_version=1
# input_clusters=[0, 65535, 1030, 1024]
# output_clusters=[0, 25]>
MODELS_INFO: [(LUMI, "lumi.sensor_motion.aq2")],
ENDPOINTS: {
1: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.DIMMER_SWITCH,
INPUT_CLUSTERS: [
Basic.cluster_id,
XIAOMI_CLUSTER_ID,
OccupancySensing.cluster_id,
IlluminanceMeasurementCluster.cluster_id,
],
OUTPUT_CLUSTERS: [Basic.cluster_id, Ota.cluster_id],
}
},
}
replacement = {
SKIP_CONFIGURATION: True,
ENDPOINTS: {
1: {
INPUT_CLUSTERS: [
BasicCluster,
XiaomiPowerConfiguration,
IlluminanceMeasurementCluster,
OccupancyCluster,
MotionCluster,
XIAOMI_CLUSTER_ID,
],
OUTPUT_CLUSTERS: [Basic.cluster_id, Ota.cluster_id],
}
},
} | zha-quirks | /zha_quirks-0.0.103-py3-none-any.whl/zhaquirks/xiaomi/aqara/motion_aq2b.py | motion_aq2b.py |
import logging
from zigpy.profiles import zha
from zigpy.zcl.clusters.general import (
AnalogInput,
Basic,
Groups,
Identify,
MultistateInput,
OnOff,
Ota,
Scenes,
)
from zhaquirks import CustomCluster
from zhaquirks.const import (
ATTR_ID,
COMMAND,
DEVICE_TYPE,
DOUBLE_PRESS,
ENDPOINTS,
INPUT_CLUSTERS,
LONG_PRESS,
MODELS_INFO,
NODE_DESCRIPTOR,
OUTPUT_CLUSTERS,
PRESS_TYPE,
PROFILE_ID,
SHORT_PRESS,
SKIP_CONFIGURATION,
VALUE,
ZHA_SEND_EVENT,
)
from zhaquirks.xiaomi import (
LUMI,
XIAOMI_NODE_DESC,
BasicCluster,
DeviceTemperatureCluster,
XiaomiPowerConfiguration,
XiaomiQuickInitDevice,
)
DOUBLE = "double"
HOLD = "long press"
PRESS_TYPES = {0: "long press", 1: "single", 2: "double"}
SINGLE = "single"
STATUS_TYPE_ATTR = 0x0055 # decimal = 85
XIAOMI_CLUSTER_ID = 0xFFFF
XIAOMI_DEVICE_TYPE = 0x5F01
XIAOMI_DEVICE_TYPE2 = 0x5F02
XIAOMI_DEVICE_TYPE3 = 0x5F03
_LOGGER = logging.getLogger(__name__)
class RemoteB186ACN01(XiaomiQuickInitDevice):
"""Aqara single key switch device."""
class MultistateInputCluster(CustomCluster, MultistateInput):
"""Multistate input cluster."""
cluster_id = MultistateInput.cluster_id
def __init__(self, *args, **kwargs):
"""Init."""
self._current_state = None
super().__init__(*args, **kwargs)
def _update_attribute(self, attrid, value):
super()._update_attribute(attrid, value)
if attrid == STATUS_TYPE_ATTR:
self._current_state = PRESS_TYPES.get(value)
event_args = {
PRESS_TYPE: self._current_state,
ATTR_ID: attrid,
VALUE: value,
}
self.listener_event(ZHA_SEND_EVENT, self._current_state, event_args)
# show something in the sensor in HA
super()._update_attribute(0, self._current_state)
signature = {
# <SimpleDescriptor endpoint=1 profile=260 device_type=24321
# device_version=1
# input_clusters=[0, 3, 25, 65535, 18]
# output_clusters=[0, 4, 3, 5, 25, 65535, 18]>
MODELS_INFO: [
(LUMI, "lumi.remote.b186acn01"),
(LUMI, "lumi.remote.b186acn02"),
(LUMI, "lumi.sensor_86sw1"),
],
NODE_DESCRIPTOR: XIAOMI_NODE_DESC,
ENDPOINTS: {
1: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: XIAOMI_DEVICE_TYPE,
INPUT_CLUSTERS: [
Basic.cluster_id,
Identify.cluster_id,
Ota.cluster_id,
XIAOMI_CLUSTER_ID,
MultistateInputCluster.cluster_id,
],
OUTPUT_CLUSTERS: [
Basic.cluster_id,
Identify.cluster_id,
Groups.cluster_id,
Scenes.cluster_id,
Ota.cluster_id,
XIAOMI_CLUSTER_ID,
MultistateInputCluster.cluster_id,
],
},
# <SimpleDescriptor endpoint=2 profile=260 device_type=24322
# device_version=1
# input_clusters=[3, 18]
# output_clusters=[4, 3, 5, 18]>
2: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: XIAOMI_DEVICE_TYPE2,
INPUT_CLUSTERS: [
Identify.cluster_id,
MultistateInputCluster.cluster_id,
],
OUTPUT_CLUSTERS: [
Identify.cluster_id,
Groups.cluster_id,
Scenes.cluster_id,
MultistateInputCluster.cluster_id,
],
},
# <SimpleDescriptor endpoint=3 profile=260 device_type=24323
# device_version=1
# input_clusters=[3, 12]
# output_clusters=[4, 3, 5, 12]>
3: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: XIAOMI_DEVICE_TYPE3,
INPUT_CLUSTERS: [Identify.cluster_id, AnalogInput.cluster_id],
OUTPUT_CLUSTERS: [
Identify.cluster_id,
Groups.cluster_id,
Scenes.cluster_id,
AnalogInput.cluster_id,
],
},
},
}
replacement = {
SKIP_CONFIGURATION: True,
ENDPOINTS: {
1: {
DEVICE_TYPE: zha.DeviceType.REMOTE_CONTROL,
INPUT_CLUSTERS: [
BasicCluster,
XiaomiPowerConfiguration,
DeviceTemperatureCluster,
Identify.cluster_id,
Ota.cluster_id,
XIAOMI_CLUSTER_ID,
MultistateInputCluster,
],
OUTPUT_CLUSTERS: [
Basic.cluster_id,
Identify.cluster_id,
Groups.cluster_id,
Scenes.cluster_id,
Ota.cluster_id,
XIAOMI_CLUSTER_ID,
MultistateInputCluster,
OnOff.cluster_id,
],
},
2: {
DEVICE_TYPE: zha.DeviceType.REMOTE_CONTROL,
INPUT_CLUSTERS: [Identify.cluster_id, MultistateInputCluster],
OUTPUT_CLUSTERS: [
Identify.cluster_id,
Groups.cluster_id,
Scenes.cluster_id,
MultistateInputCluster,
],
},
3: {
DEVICE_TYPE: zha.DeviceType.REMOTE_CONTROL,
INPUT_CLUSTERS: [Identify.cluster_id, MultistateInputCluster],
OUTPUT_CLUSTERS: [
Identify.cluster_id,
Groups.cluster_id,
Scenes.cluster_id,
AnalogInput.cluster_id,
MultistateInputCluster,
],
},
},
}
device_automation_triggers = {
(DOUBLE_PRESS, DOUBLE_PRESS): {COMMAND: DOUBLE},
(SHORT_PRESS, SHORT_PRESS): {COMMAND: SINGLE},
(LONG_PRESS, LONG_PRESS): {COMMAND: HOLD},
} | zha-quirks | /zha_quirks-0.0.103-py3-none-any.whl/zhaquirks/xiaomi/aqara/remote_b186acn01.py | remote_b186acn01.py |
import logging
from zigpy.profiles import zha
from zigpy.zcl.clusters.general import (
AnalogInput,
Basic,
BinaryInput,
BinaryOutput,
DeviceTemperature,
Groups,
Identify,
OnOff,
Ota,
PowerConfiguration,
Scenes,
Time,
)
from zigpy.zcl.clusters.homeautomation import ElectricalMeasurement
from zhaquirks.const import (
DEVICE_TYPE,
ENDPOINTS,
INPUT_CLUSTERS,
MODELS_INFO,
OUTPUT_CLUSTERS,
PROFILE_ID,
)
from zhaquirks.xiaomi import (
LUMI,
AnalogInputCluster,
BasicCluster,
ElectricalMeasurementCluster,
MeteringCluster,
XiaomiAqaraE1Cluster,
XiaomiCustomDevice,
)
_LOGGER = logging.getLogger(__name__)
class Plug(XiaomiCustomDevice):
"""lumi.plug.maus01 plug."""
signature = {
MODELS_INFO: [(LUMI, "lumi.plug.maus01"), (LUMI, "lumi.plug.mitw01")],
ENDPOINTS: {
# <SimpleDescriptor endpoint=1 profile=260 device_type=81
# device_version=1
# input_clusters=[0, 4, 3, 6, 16, 5, 10, 1, 2, 2820]
# output_clusters=[25, 10]>
1: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.SMART_PLUG,
INPUT_CLUSTERS: [
Basic.cluster_id,
PowerConfiguration.cluster_id,
DeviceTemperature.cluster_id,
Groups.cluster_id,
Identify.cluster_id,
OnOff.cluster_id,
Scenes.cluster_id,
BinaryOutput.cluster_id,
Time.cluster_id,
ElectricalMeasurement.cluster_id,
],
OUTPUT_CLUSTERS: [Ota.cluster_id, Time.cluster_id],
},
# <SimpleDescriptor endpoint=2 profile=260 device_type=9
# device_version=1
# input_clusters=[12]
# output_clusters=[12, 4]>
2: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.MAIN_POWER_OUTLET,
INPUT_CLUSTERS: [AnalogInput.cluster_id],
OUTPUT_CLUSTERS: [AnalogInput.cluster_id, Groups.cluster_id],
},
# <SimpleDescriptor endpoint=3 profile=260 device_type=83
# device_version=1
# input_clusters=[12]
# output_clusters=[12]>
3: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.METER_INTERFACE,
INPUT_CLUSTERS: [AnalogInput.cluster_id],
OUTPUT_CLUSTERS: [AnalogInput.cluster_id],
},
# <SimpleDescriptor endpoint=100 profile=260 device_type=263
# device_version=2
# input_clusters=[15]
# output_clusters=[15, 4]>
100: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.OCCUPANCY_SENSOR,
INPUT_CLUSTERS: [BinaryInput.cluster_id],
OUTPUT_CLUSTERS: [BinaryInput.cluster_id, Groups.cluster_id],
},
},
}
replacement = {
ENDPOINTS: {
1: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.SMART_PLUG,
INPUT_CLUSTERS: [
BasicCluster,
PowerConfiguration.cluster_id,
DeviceTemperature.cluster_id,
Groups.cluster_id,
Identify.cluster_id,
OnOff.cluster_id,
Scenes.cluster_id,
BinaryOutput.cluster_id,
Time.cluster_id,
ElectricalMeasurementCluster,
XiaomiAqaraE1Cluster,
MeteringCluster,
],
OUTPUT_CLUSTERS: [Ota.cluster_id, Time.cluster_id],
},
2: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.MAIN_POWER_OUTLET,
INPUT_CLUSTERS: [AnalogInputCluster],
OUTPUT_CLUSTERS: [AnalogInput.cluster_id, Groups.cluster_id],
},
3: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.METER_INTERFACE,
INPUT_CLUSTERS: [AnalogInput.cluster_id],
OUTPUT_CLUSTERS: [AnalogInput.cluster_id],
},
100: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.OCCUPANCY_SENSOR,
INPUT_CLUSTERS: [BinaryInput.cluster_id],
OUTPUT_CLUSTERS: [BinaryInput.cluster_id, Groups.cluster_id],
},
},
} | zha-quirks | /zha_quirks-0.0.103-py3-none-any.whl/zhaquirks/xiaomi/aqara/plug_maus01.py | plug_maus01.py |
import logging
from zigpy import types as t
from zigpy.profiles import zha
from zigpy.zcl.clusters.general import (
AnalogInput,
Basic,
BinaryOutput,
DeviceTemperature,
Groups,
Identify,
MultistateInput,
OnOff,
Ota,
Scenes,
Time,
)
from zhaquirks import EventableCluster
from zhaquirks.const import (
ARGS,
ATTRIBUTE_ID,
ATTRIBUTE_NAME,
BUTTON,
BUTTON_1,
BUTTON_2,
CLUSTER_ID,
COMMAND,
COMMAND_ATTRIBUTE_UPDATED,
COMMAND_DOUBLE,
COMMAND_HOLD,
COMMAND_RELEASE,
DEVICE_TYPE,
ENDPOINT_ID,
ENDPOINTS,
INPUT_CLUSTERS,
MODELS_INFO,
OUTPUT_CLUSTERS,
PROFILE_ID,
SKIP_CONFIGURATION,
VALUE,
)
from zhaquirks.xiaomi import (
LUMI,
BasicCluster,
OnOffCluster,
XiaomiCustomDevice,
XiaomiPowerConfiguration,
)
ATTRIBUTE_ON_OFF = "on_off"
DOUBLE = "double"
HOLD = "long press"
PRESS_TYPES = {0: "long press", 1: "single", 2: "double"}
SINGLE = "single"
STATUS_TYPE_ATTR = 0x0055 # decimal = 85
XIAOMI_CLUSTER_ID = 0xFFFF
XIAOMI_DEVICE_TYPE = 0x5F01
XIAOMI_DEVICE_TYPE2 = 0x5F02
XIAOMI_DEVICE_TYPE3 = 0x5F03
_LOGGER = logging.getLogger(__name__)
# click attr 0xF000
# single click 0x3FF1F00
# double click 0xCFF1F00
class BasicClusterDecoupled(BasicCluster):
"""Adds attributes for decoupled mode."""
# Known Options for 'decoupled_mode_<button>':
# * 254 (decoupled)
# * 18 (relay controlled)
attributes = BasicCluster.attributes.copy()
attributes.update(
{
0xFF22: ("decoupled_mode_left", t.uint8_t, True),
0xFF23: ("decoupled_mode_right", t.uint8_t, True),
}
)
class WallSwitchOnOffCluster(EventableCluster, OnOff):
"""WallSwitchOnOffCluster: fire events corresponding to press type."""
class CtrlNeutral(XiaomiCustomDevice):
"""Aqara single key switch device."""
signature = {
MODELS_INFO: [
(LUMI, "lumi.ctrl_neutral1"),
(LUMI, "lumi.switch.b1lacn02"),
],
ENDPOINTS: {
# <SimpleDescriptor endpoint=1 profile=260 device_type=6
# device_version=2
# input_clusters=[0, 3, 1, 2, 25, 10]
# output_clusters=[0, 10, 25]>
1: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.REMOTE_CONTROL,
INPUT_CLUSTERS: [
Basic.cluster_id,
Identify.cluster_id,
XiaomiPowerConfiguration.cluster_id,
DeviceTemperature.cluster_id,
Ota.cluster_id,
Time.cluster_id,
],
OUTPUT_CLUSTERS: [Basic.cluster_id, Time.cluster_id, Ota.cluster_id],
},
# <SimpleDescriptor endpoint=2 profile=260 device_type=256
# device_version=2
# input_clusters=[16, 6, 4, 5]
# output_clusters=[]>
2: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.ON_OFF_LIGHT,
INPUT_CLUSTERS: [
BinaryOutput.cluster_id,
OnOff.cluster_id,
Groups.cluster_id,
Scenes.cluster_id,
],
OUTPUT_CLUSTERS: [],
},
# <SimpleDescriptor endpoint=3 profile=260 device_type=256
# device_version=2
# input_clusters=[16, 6, 4, 5]
# output_clusters=[]
3: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.ON_OFF_LIGHT,
INPUT_CLUSTERS: [
BinaryOutput.cluster_id,
OnOff.cluster_id,
Groups.cluster_id,
Scenes.cluster_id,
],
OUTPUT_CLUSTERS: [],
},
# <SimpleDescriptor endpoint=4 profile=260 device_type=0
# device_version=2
# input_clusters=[18, 6]
# output_clusters=[]>
4: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.ON_OFF_SWITCH,
INPUT_CLUSTERS: [MultistateInput.cluster_id, OnOff.cluster_id],
OUTPUT_CLUSTERS: [],
},
# <SimpleDescriptor endpoint=5 profile=260 device_type=0
# device_version=2
# input_clusters=[18, 6]
# output_clusters=[]>
5: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.ON_OFF_SWITCH,
INPUT_CLUSTERS: [MultistateInput.cluster_id, OnOff.cluster_id],
OUTPUT_CLUSTERS: [],
},
# <SimpleDescriptor endpoint=6 profile=260 device_type=0
# device_version=2
# input_clusters=[18, 6]
# output_clusters=[]>
6: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.ON_OFF_SWITCH,
INPUT_CLUSTERS: [MultistateInput.cluster_id, OnOff.cluster_id],
OUTPUT_CLUSTERS: [],
},
# <SimpleDescriptor endpoint=8 profile=260 device_type=83
# device_version=2
# input_clusters=[12]
# output_clusters=[]>
8: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.METER_INTERFACE,
INPUT_CLUSTERS: [AnalogInput.cluster_id],
OUTPUT_CLUSTERS: [],
},
},
}
replacement = {
SKIP_CONFIGURATION: True,
ENDPOINTS: {
1: {
DEVICE_TYPE: zha.DeviceType.REMOTE_CONTROL,
INPUT_CLUSTERS: [
BasicClusterDecoupled,
Identify.cluster_id,
XiaomiPowerConfiguration.cluster_id,
DeviceTemperature.cluster_id,
Ota.cluster_id,
Time.cluster_id,
],
OUTPUT_CLUSTERS: [Basic.cluster_id, Time.cluster_id, Ota.cluster_id],
},
2: {
DEVICE_TYPE: zha.DeviceType.ON_OFF_SWITCH,
INPUT_CLUSTERS: [
BinaryOutput.cluster_id,
OnOffCluster,
Groups.cluster_id,
Scenes.cluster_id,
],
OUTPUT_CLUSTERS: [],
},
3: {
DEVICE_TYPE: zha.DeviceType.ON_OFF_SWITCH,
INPUT_CLUSTERS: [
BinaryOutput.cluster_id,
OnOffCluster,
Groups.cluster_id,
Scenes.cluster_id,
],
OUTPUT_CLUSTERS: [],
},
4: {
DEVICE_TYPE: zha.DeviceType.ON_OFF_SWITCH,
INPUT_CLUSTERS: [
MultistateInput.cluster_id,
WallSwitchOnOffCluster,
],
OUTPUT_CLUSTERS: [],
},
},
}
device_automation_triggers = {
(COMMAND_HOLD, BUTTON): {
ENDPOINT_ID: 4,
CLUSTER_ID: 6,
COMMAND: COMMAND_ATTRIBUTE_UPDATED,
ARGS: {ATTRIBUTE_ID: 0, ATTRIBUTE_NAME: ATTRIBUTE_ON_OFF, VALUE: 0},
},
(COMMAND_RELEASE, BUTTON): {
ENDPOINT_ID: 4,
CLUSTER_ID: 6,
COMMAND: COMMAND_ATTRIBUTE_UPDATED,
ARGS: {ATTRIBUTE_ID: 0, ATTRIBUTE_NAME: ATTRIBUTE_ON_OFF, VALUE: 1},
},
(COMMAND_DOUBLE, BUTTON): {
ENDPOINT_ID: 4,
CLUSTER_ID: 6,
COMMAND: COMMAND_ATTRIBUTE_UPDATED,
ARGS: {ATTRIBUTE_ID: 0, ATTRIBUTE_NAME: ATTRIBUTE_ON_OFF, VALUE: 2},
},
}
class CtrlNeutral_2G(XiaomiCustomDevice):
"""Aqara double key switch device."""
signature = {
MODELS_INFO: [
(LUMI, "lumi.ctrl_neutral2"),
(LUMI, "lumi.switch.b2lacn02"),
],
ENDPOINTS: {
# <SimpleDescriptor endpoint=1 profile=260 device_type=6
# device_version=2
# input_clusters=[0, 3, 1, 2, 25, 10]
# output_clusters=[0, 10, 25]>
1: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.REMOTE_CONTROL,
INPUT_CLUSTERS: [
Basic.cluster_id,
Identify.cluster_id,
XiaomiPowerConfiguration.cluster_id,
DeviceTemperature.cluster_id,
Ota.cluster_id,
Time.cluster_id,
],
OUTPUT_CLUSTERS: [Basic.cluster_id, Time.cluster_id, Ota.cluster_id],
},
# <SimpleDescriptor endpoint=2 profile=260 device_type=256
# device_version=2
# input_clusters=[16, 6, 4, 5]
# output_clusters=[]>
2: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.ON_OFF_LIGHT,
INPUT_CLUSTERS: [
BinaryOutput.cluster_id,
OnOff.cluster_id,
Groups.cluster_id,
Scenes.cluster_id,
],
OUTPUT_CLUSTERS: [],
},
# <SimpleDescriptor endpoint=3 profile=260 device_type=256
# device_version=2
# input_clusters=[16, 6, 4, 5]
# output_clusters=[]
3: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.ON_OFF_LIGHT,
INPUT_CLUSTERS: [
BinaryOutput.cluster_id,
OnOff.cluster_id,
Groups.cluster_id,
Scenes.cluster_id,
],
OUTPUT_CLUSTERS: [],
},
# <SimpleDescriptor endpoint=4 profile=260 device_type=0
# device_version=2
# input_clusters=[18, 6]
# output_clusters=[]>
4: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.ON_OFF_SWITCH,
INPUT_CLUSTERS: [MultistateInput.cluster_id, OnOff.cluster_id],
OUTPUT_CLUSTERS: [],
},
# <SimpleDescriptor endpoint=5 profile=260 device_type=0
# device_version=2
# input_clusters=[18, 6]
# output_clusters=[]>
5: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.ON_OFF_SWITCH,
INPUT_CLUSTERS: [MultistateInput.cluster_id, OnOff.cluster_id],
OUTPUT_CLUSTERS: [],
},
# <SimpleDescriptor endpoint=6 profile=260 device_type=0
# device_version=2
# input_clusters=[18, 6]
# output_clusters=[]>
6: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.ON_OFF_SWITCH,
INPUT_CLUSTERS: [MultistateInput.cluster_id, OnOff.cluster_id],
OUTPUT_CLUSTERS: [],
},
# <SimpleDescriptor endpoint=8 profile=260 device_type=83
# device_version=2
# input_clusters=[12]
# output_clusters=[]>
8: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.METER_INTERFACE,
INPUT_CLUSTERS: [AnalogInput.cluster_id],
OUTPUT_CLUSTERS: [],
},
},
}
replacement = {
SKIP_CONFIGURATION: True,
ENDPOINTS: {
1: {
DEVICE_TYPE: zha.DeviceType.REMOTE_CONTROL,
INPUT_CLUSTERS: [
BasicClusterDecoupled,
Identify.cluster_id,
XiaomiPowerConfiguration.cluster_id,
DeviceTemperature.cluster_id,
Ota.cluster_id,
Time.cluster_id,
],
OUTPUT_CLUSTERS: [Basic.cluster_id, Time.cluster_id, Ota.cluster_id],
},
2: {
DEVICE_TYPE: zha.DeviceType.ON_OFF_SWITCH,
INPUT_CLUSTERS: [
BinaryOutput.cluster_id,
OnOffCluster,
Groups.cluster_id,
Scenes.cluster_id,
],
OUTPUT_CLUSTERS: [],
},
3: {
DEVICE_TYPE: zha.DeviceType.ON_OFF_SWITCH,
INPUT_CLUSTERS: [
BinaryOutput.cluster_id,
OnOffCluster,
Groups.cluster_id,
Scenes.cluster_id,
],
OUTPUT_CLUSTERS: [],
},
4: {
DEVICE_TYPE: zha.DeviceType.ON_OFF_SWITCH,
INPUT_CLUSTERS: [
MultistateInput.cluster_id,
WallSwitchOnOffCluster,
],
OUTPUT_CLUSTERS: [],
},
5: {
DEVICE_TYPE: zha.DeviceType.ON_OFF_SWITCH,
INPUT_CLUSTERS: [
MultistateInput.cluster_id,
WallSwitchOnOffCluster,
],
OUTPUT_CLUSTERS: [],
},
},
}
device_automation_triggers = {
(COMMAND_HOLD, BUTTON_1): {
ENDPOINT_ID: 4,
CLUSTER_ID: 6,
COMMAND: COMMAND_ATTRIBUTE_UPDATED,
ARGS: {ATTRIBUTE_ID: 0, ATTRIBUTE_NAME: ATTRIBUTE_ON_OFF, VALUE: 0},
},
(COMMAND_RELEASE, BUTTON_1): {
ENDPOINT_ID: 4,
CLUSTER_ID: 6,
COMMAND: COMMAND_ATTRIBUTE_UPDATED,
ARGS: {ATTRIBUTE_ID: 0, ATTRIBUTE_NAME: ATTRIBUTE_ON_OFF, VALUE: 1},
},
(COMMAND_DOUBLE, BUTTON_1): {
ENDPOINT_ID: 4,
CLUSTER_ID: 6,
COMMAND: COMMAND_ATTRIBUTE_UPDATED,
ARGS: {ATTRIBUTE_ID: 0, ATTRIBUTE_NAME: ATTRIBUTE_ON_OFF, VALUE: 2},
},
(COMMAND_HOLD, BUTTON_2): {
ENDPOINT_ID: 5,
CLUSTER_ID: 6,
COMMAND: COMMAND_ATTRIBUTE_UPDATED,
ARGS: {ATTRIBUTE_ID: 0, ATTRIBUTE_NAME: ATTRIBUTE_ON_OFF, VALUE: 0},
},
(COMMAND_RELEASE, BUTTON_2): {
ENDPOINT_ID: 5,
CLUSTER_ID: 6,
COMMAND: COMMAND_ATTRIBUTE_UPDATED,
ARGS: {ATTRIBUTE_ID: 0, ATTRIBUTE_NAME: ATTRIBUTE_ON_OFF, VALUE: 1},
},
(COMMAND_DOUBLE, BUTTON_2): {
ENDPOINT_ID: 5,
CLUSTER_ID: 6,
COMMAND: COMMAND_ATTRIBUTE_UPDATED,
ARGS: {ATTRIBUTE_ID: 0, ATTRIBUTE_NAME: ATTRIBUTE_ON_OFF, VALUE: 2},
},
} | zha-quirks | /zha_quirks-0.0.103-py3-none-any.whl/zhaquirks/xiaomi/aqara/ctrl_neutral.py | ctrl_neutral.py |
from zigpy.profiles import zha
from zigpy.zcl.clusters.general import (
Basic,
Identify,
MultistateInput,
OnOff,
Ota,
PowerConfiguration,
)
from zhaquirks.const import (
ALT_DOUBLE_PRESS,
ALT_SHORT_PRESS,
BUTTON,
COMMAND,
COMMAND_OFF,
COMMAND_TOGGLE,
DEVICE_TYPE,
DOUBLE_PRESS,
ENDPOINTS,
INPUT_CLUSTERS,
LEFT,
LONG_PRESS,
MODELS_INFO,
OUTPUT_CLUSTERS,
PROFILE_ID,
RIGHT,
SHORT_PRESS,
TRIPLE_PRESS,
)
from zhaquirks.xiaomi import LUMI, BasicCluster, XiaomiCustomDevice
from zhaquirks.xiaomi.aqara.opple_remote import (
COMMAND_1_DOUBLE,
COMMAND_1_HOLD,
COMMAND_1_SINGLE,
COMMAND_1_TRIPLE,
COMMAND_2_DOUBLE,
COMMAND_2_HOLD,
COMMAND_2_SINGLE,
COMMAND_2_TRIPLE,
COMMAND_3_DOUBLE,
COMMAND_3_HOLD,
COMMAND_3_SINGLE,
COMMAND_3_TRIPLE,
MultistateInputCluster,
)
from zhaquirks.xiaomi.aqara.remote_h1 import (
AqaraRemoteManuSpecificCluster,
PowerConfigurationClusterH1Remote,
)
BOTH_BUTTONS = "both_buttons"
class RemoteE1SingleRocker1(XiaomiCustomDevice):
"""Aqara E1 Wireless Remote Double Rocker."""
signature = {
MODELS_INFO: [(LUMI, "lumi.remote.acn003")],
ENDPOINTS: {
1: {
# SizePrefixedSimpleDescriptor(
# endpoint=1, profile=260, device_type=0,
# input_clusters=["0x0000", "0x0001", "0x0003", "0x0012", "0xfcc0"],
# output_clusters=["0x0003", "0x0006", "0x0019"])
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.ON_OFF_SWITCH,
INPUT_CLUSTERS: [
Basic.cluster_id,
PowerConfiguration.cluster_id,
Identify.cluster_id,
MultistateInput.cluster_id,
AqaraRemoteManuSpecificCluster.cluster_id,
],
OUTPUT_CLUSTERS: [
Identify.cluster_id,
OnOff.cluster_id,
Ota.cluster_id,
],
},
},
}
replacement = {
ENDPOINTS: {
1: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.ON_OFF_SWITCH,
INPUT_CLUSTERS: [
BasicCluster,
Identify.cluster_id,
PowerConfigurationClusterH1Remote,
MultistateInputCluster,
AqaraRemoteManuSpecificCluster,
],
OUTPUT_CLUSTERS: [
Identify.cluster_id,
OnOff.cluster_id,
Ota.cluster_id,
],
},
}
}
device_automation_triggers = {
# triggers when operation_mode == event
# the button doesn't send an release event after hold
(SHORT_PRESS, LEFT): {COMMAND: COMMAND_1_SINGLE},
(DOUBLE_PRESS, LEFT): {COMMAND: COMMAND_1_DOUBLE},
(TRIPLE_PRESS, LEFT): {COMMAND: COMMAND_1_TRIPLE},
(LONG_PRESS, LEFT): {COMMAND: COMMAND_1_HOLD},
# triggers when operation_mode == command
(ALT_SHORT_PRESS, BUTTON): {COMMAND: COMMAND_TOGGLE},
(ALT_DOUBLE_PRESS, BUTTON): {COMMAND: COMMAND_OFF},
}
class RemoteE1DoubleRocker1(XiaomiCustomDevice):
"""Aqara E1 Wireless Remote Double Rocker."""
signature = {
MODELS_INFO: [(LUMI, "lumi.remote.acn004")],
ENDPOINTS: {
1: {
# SizePrefixedSimpleDescriptor(
# endpoint=1, profile=260, device_type=0,
# input_clusters=["0x0000", "0x0001", "0x0003", "0x0012", "0xfcc0"],
# output_clusters=["0x0003", "0x0006", "0x0019"])
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.ON_OFF_SWITCH,
INPUT_CLUSTERS: [
Basic.cluster_id,
PowerConfiguration.cluster_id,
Identify.cluster_id,
MultistateInput.cluster_id,
AqaraRemoteManuSpecificCluster.cluster_id,
],
OUTPUT_CLUSTERS: [
Identify.cluster_id,
OnOff.cluster_id,
Ota.cluster_id,
],
},
2: {
# SizePrefixedSimpleDescriptor(
# endpoint=2, profile=260, device_type=0,
# input_clusters=["0x0012"], output_clusters=["0x0006"])
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.ON_OFF_SWITCH,
INPUT_CLUSTERS: [MultistateInput.cluster_id],
OUTPUT_CLUSTERS: [OnOff.cluster_id],
},
3: {
# SizePrefixedSimpleDescriptor(
# endpoint=3, profile=260, device_type=0,
# input_clusters=["0x0012"], output_clusters=["0x0006"])
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.ON_OFF_SWITCH,
INPUT_CLUSTERS: [MultistateInput.cluster_id],
OUTPUT_CLUSTERS: [OnOff.cluster_id],
},
},
}
replacement = {
ENDPOINTS: {
1: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.ON_OFF_SWITCH,
INPUT_CLUSTERS: [
BasicCluster,
Identify.cluster_id,
PowerConfigurationClusterH1Remote,
MultistateInputCluster,
AqaraRemoteManuSpecificCluster,
],
OUTPUT_CLUSTERS: [
Identify.cluster_id,
OnOff.cluster_id,
Ota.cluster_id,
],
},
2: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.ON_OFF_SWITCH,
INPUT_CLUSTERS: [
MultistateInputCluster,
],
OUTPUT_CLUSTERS: [
OnOff.cluster_id,
],
},
3: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.ON_OFF_SWITCH,
INPUT_CLUSTERS: [
MultistateInputCluster,
],
OUTPUT_CLUSTERS: [
OnOff.cluster_id,
],
},
}
}
device_automation_triggers = {
# triggers when operation_mode == event
# the button doesn't send an release event after hold
(SHORT_PRESS, LEFT): {COMMAND: COMMAND_1_SINGLE},
(DOUBLE_PRESS, LEFT): {COMMAND: COMMAND_1_DOUBLE},
(TRIPLE_PRESS, LEFT): {COMMAND: COMMAND_1_TRIPLE},
(LONG_PRESS, LEFT): {COMMAND: COMMAND_1_HOLD},
(SHORT_PRESS, RIGHT): {COMMAND: COMMAND_2_SINGLE},
(DOUBLE_PRESS, RIGHT): {COMMAND: COMMAND_2_DOUBLE},
(TRIPLE_PRESS, RIGHT): {COMMAND: COMMAND_2_TRIPLE},
(LONG_PRESS, RIGHT): {COMMAND: COMMAND_2_HOLD},
(SHORT_PRESS, BOTH_BUTTONS): {COMMAND: COMMAND_3_SINGLE},
(DOUBLE_PRESS, BOTH_BUTTONS): {COMMAND: COMMAND_3_DOUBLE},
(TRIPLE_PRESS, BOTH_BUTTONS): {COMMAND: COMMAND_3_TRIPLE},
(LONG_PRESS, BOTH_BUTTONS): {COMMAND: COMMAND_3_HOLD},
# triggers when operation_mode == command
# known issue: it seems impossible to know which button being pressed
# when operation_mode == command
(ALT_SHORT_PRESS, BUTTON): {COMMAND: COMMAND_TOGGLE},
(ALT_DOUBLE_PRESS, BUTTON): {COMMAND: COMMAND_OFF},
} | zha-quirks | /zha_quirks-0.0.103-py3-none-any.whl/zhaquirks/xiaomi/aqara/remote_e1.py | remote_e1.py |
from typing import Any
from zigpy.profiles import zha
from zigpy.quirks import CustomDevice
import zigpy.types as types
from zigpy.zcl.clusters.general import Basic, Identify, Ota, PowerConfiguration
from zigpy.zcl.clusters.security import IasZone
from zigpy.zdo.types import NodeDescriptor
from zhaquirks import LocalDataCluster
from zhaquirks.const import (
DEVICE_TYPE,
ENDPOINTS,
INPUT_CLUSTERS,
MODELS_INFO,
NODE_DESCRIPTOR,
OUTPUT_CLUSTERS,
PROFILE_ID,
ZONE_STATUS,
)
from zhaquirks.xiaomi import LUMI, XiaomiAqaraE1Cluster, XiaomiPowerConfiguration
BUZZER_MANUAL_MUTE = 0x0126
SELF_TEST = 0x0127
SMOKE = 0x013A
SMOKE_DENSITY = 0x013B
HEARTBEAT_INDICATOR = 0x013C
BUZZER_MANUAL_ALARM = 0x013D
BUZZER = 0x013E
LINKAGE_ALARM = 0x014B
LINKAGE_ALARM_STATE = 0x014C
SMOKE_DENSITY_DBM = 0x1403 # fake attribute for smoke density in dB/m
SMOKE_DENSITY_DBM_MAP = {
0: 0,
1: 0.085,
2: 0.088,
3: 0.093,
4: 0.095,
5: 0.100,
6: 0.105,
7: 0.110,
8: 0.115,
9: 0.120,
10: 0.125,
}
class OppleCluster(XiaomiAqaraE1Cluster):
"""Opple cluster."""
ep_attribute = "opple_cluster"
attributes = {
BUZZER_MANUAL_MUTE: ("buzzer_manual_mute", types.uint8_t, True),
SELF_TEST: ("self_test", types.Bool, True),
SMOKE: ("smoke", types.uint8_t, True),
SMOKE_DENSITY: ("smoke_density", types.uint8_t, True),
HEARTBEAT_INDICATOR: ("heartbeat_indicator", types.uint8_t, True),
BUZZER_MANUAL_ALARM: ("buzzer_manual_alarm", types.uint8_t, True),
BUZZER: ("buzzer", types.uint32_t, True),
LINKAGE_ALARM: ("linkage_alarm", types.uint8_t, True),
LINKAGE_ALARM_STATE: ("linkage_alarm_state", types.uint8_t, True),
SMOKE_DENSITY_DBM: ("smoke_density_dbm", types.Single, True),
}
def _update_attribute(self, attrid: int, value: Any) -> None:
"""Pass attribute update to another cluster if necessary."""
super()._update_attribute(attrid, value)
if attrid == SMOKE:
self.endpoint.ias_zone.update_attribute(ZONE_STATUS, value)
elif attrid == SMOKE_DENSITY:
self.update_attribute(SMOKE_DENSITY_DBM, SMOKE_DENSITY_DBM_MAP[value])
class LocalIasZone(LocalDataCluster, IasZone):
"""Local IAS Zone cluster."""
_CONSTANT_ATTRIBUTES = {
IasZone.attributes_by_name["zone_type"].id: IasZone.ZoneType.Fire_Sensor
}
class LumiSensorSmokeAcn03(CustomDevice):
"""lumi.sensor_smoke.acn03 smoke sensor."""
signature = {
MODELS_INFO: [(LUMI, "lumi.sensor_smoke.acn03")],
ENDPOINTS: {
1: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.IAS_ZONE,
INPUT_CLUSTERS: [
Basic.cluster_id,
PowerConfiguration.cluster_id,
Identify.cluster_id,
IasZone.cluster_id,
],
OUTPUT_CLUSTERS: [
Ota.cluster_id,
],
}
},
}
replacement = {
NODE_DESCRIPTOR: NodeDescriptor(
0x02, 0x40, 0x80, 0x115F, 0x7F, 0x0064, 0x2C00, 0x0064, 0x00
),
ENDPOINTS: {
1: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.IAS_ZONE,
INPUT_CLUSTERS: [
Basic.cluster_id,
XiaomiPowerConfiguration,
Identify.cluster_id,
LocalIasZone,
OppleCluster,
],
OUTPUT_CLUSTERS: [
Ota.cluster_id,
],
}
},
} | zha-quirks | /zha_quirks-0.0.103-py3-none-any.whl/zhaquirks/xiaomi/aqara/smoke.py | smoke.py |
import logging
from zigpy.profiles import zha
from zigpy.zcl.clusters.general import Groups, Identify
from zigpy.zcl.clusters.measurement import PressureMeasurement
from zhaquirks.const import (
DEVICE_TYPE,
ENDPOINTS,
INPUT_CLUSTERS,
MODELS_INFO,
NODE_DESCRIPTOR,
OUTPUT_CLUSTERS,
PROFILE_ID,
SKIP_CONFIGURATION,
)
from zhaquirks.xiaomi import (
LUMI,
XIAOMI_NODE_DESC,
BasicCluster,
PressureMeasurementCluster,
RelativeHumidityCluster,
TemperatureMeasurementCluster,
XiaomiPowerConfiguration,
XiaomiQuickInitDevice,
)
TEMPERATURE_HUMIDITY_DEVICE_TYPE = 0x5F01
XIAOMI_CLUSTER_ID = 0xFFFF
_LOGGER = logging.getLogger(__name__)
class Weather(XiaomiQuickInitDevice):
"""Xiaomi weather sensor device."""
signature = {
# <SimpleDescriptor endpoint=1 profile=260 device_type=24321
# device_version=1
# input_clusters=[0, 3, 65535, 1026, 1027, 1029]
# output_clusters=[0, 4, 65535]>
MODELS_INFO: [(LUMI, "lumi.weather")],
NODE_DESCRIPTOR: XIAOMI_NODE_DESC,
ENDPOINTS: {
1: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: TEMPERATURE_HUMIDITY_DEVICE_TYPE,
INPUT_CLUSTERS: [
BasicCluster.cluster_id,
Identify.cluster_id,
XIAOMI_CLUSTER_ID,
TemperatureMeasurementCluster.cluster_id,
PressureMeasurement.cluster_id,
RelativeHumidityCluster.cluster_id,
],
OUTPUT_CLUSTERS: [
BasicCluster.cluster_id,
Groups.cluster_id,
XIAOMI_CLUSTER_ID,
],
}
},
}
replacement = {
SKIP_CONFIGURATION: True,
ENDPOINTS: {
1: {
INPUT_CLUSTERS: [
BasicCluster,
XiaomiPowerConfiguration,
Identify.cluster_id,
TemperatureMeasurementCluster,
PressureMeasurementCluster,
RelativeHumidityCluster,
XIAOMI_CLUSTER_ID,
],
OUTPUT_CLUSTERS: [
BasicCluster.cluster_id,
Groups.cluster_id,
XIAOMI_CLUSTER_ID,
],
}
},
}
class Weather2(Weather):
"""New Xiaomi weather sensor device."""
signature = {
# <SimpleDescriptor endpoint=1 profile=260 device_type=24321
# device_version=1
# input_clusters=[0, 3, 65535, 1026, 1027, 1029]
# output_clusters=[0, 4, 65535]>
MODELS_INFO: [(LUMI, "lumi.weather")],
NODE_DESCRIPTOR: XIAOMI_NODE_DESC,
ENDPOINTS: {
1: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.TEMPERATURE_SENSOR,
INPUT_CLUSTERS: [
BasicCluster.cluster_id,
Identify.cluster_id,
TemperatureMeasurementCluster.cluster_id,
PressureMeasurement.cluster_id,
RelativeHumidityCluster.cluster_id,
XIAOMI_CLUSTER_ID,
],
OUTPUT_CLUSTERS: [
BasicCluster.cluster_id,
Groups.cluster_id,
XIAOMI_CLUSTER_ID,
],
}
},
} | zha-quirks | /zha_quirks-0.0.103-py3-none-any.whl/zhaquirks/xiaomi/aqara/weather.py | weather.py |
from __future__ import annotations
from typing import Any
from zigpy import types as t
from zigpy.profiles import zgp, zha
from zigpy.zcl import foundation
from zigpy.zcl.clusters.closures import WindowCovering
from zigpy.zcl.clusters.general import (
Alarms,
AnalogOutput,
Basic,
DeviceTemperature,
GreenPowerProxy,
Groups,
Identify,
MultistateOutput,
OnOff,
Ota,
Scenes,
Time,
)
from zigpy.zcl.clusters.manufacturer_specific import ManufacturerSpecificCluster
from zhaquirks import CustomCluster
from zhaquirks.const import (
DEVICE_TYPE,
ENDPOINTS,
INPUT_CLUSTERS,
MODELS_INFO,
OUTPUT_CLUSTERS,
PROFILE_ID,
)
from zhaquirks.xiaomi import (
LUMI,
BasicCluster,
XiaomiCluster,
XiaomiCustomDevice,
XiaomiPowerConfiguration,
)
PRESENT_VALUE = 0x0055
CURRENT_POSITION_LIFT_PERCENTAGE = 0x0008
GO_TO_LIFT_PERCENTAGE = 0x0005
DOWN_CLOSE = 0x0001
UP_OPEN = 0x0000
STOP = 0x0002
class XiaomiAqaraRollerE1(XiaomiCluster, ManufacturerSpecificCluster):
"""Xiaomi mfg cluster implementation specific for E1 Roller."""
cluster_id = 0xFCC0
attributes = XiaomiCluster.attributes.copy()
attributes.update(
{
0x0400: ("reverse_direction", t.Bool, True),
0x0402: ("positions_stored", t.Bool, True),
0x0407: ("store_position", t.uint8_t, True),
0x0408: ("speed", t.uint8_t, True),
0x0409: ("charging", t.uint8_t, True),
0x00F7: ("aqara_attributes", t.LVBytes, True),
}
)
class AnalogOutputRollerE1(CustomCluster, AnalogOutput):
"""Analog output cluster, only used to relay current_value to WindowCovering."""
cluster_id = AnalogOutput.cluster_id
def __init__(self, *args: Any, **kwargs: Any) -> None:
"""Init."""
super().__init__(*args, **kwargs)
self._update_attribute(0x0041, float(0x064)) # max_present_value
self._update_attribute(0x0045, 0.0) # min_present_value
self._update_attribute(0x0051, 0) # out_of_service
self._update_attribute(0x006A, 1.0) # resolution
self._update_attribute(0x006F, 0x00) # status_flags
def _update_attribute(self, attrid: int, value: Any) -> None:
super()._update_attribute(attrid, value)
if attrid == PRESENT_VALUE:
self.endpoint.window_covering._update_attribute(
CURRENT_POSITION_LIFT_PERCENTAGE, (100 - value)
)
class WindowCoveringRollerE1(CustomCluster, WindowCovering):
"""Window covering cluster to receive commands that are sent to the AnalogOutput's present_value to move the motor."""
cluster_id = WindowCovering.cluster_id
def __init__(self, *args: Any, **kwargs: Any) -> None:
"""Init."""
super().__init__(*args, **kwargs)
async def command(
self,
command_id: foundation.GeneralCommand | int | t.uint8_t,
*args: Any,
manufacturer: int | t.uint16_t | None = None,
expect_reply: bool = True,
tsn: int | t.uint8_t | None = None,
**kwargs: Any,
) -> Any:
"""Overwrite the commands to make it work for both firmware 1425 and 1427.
We either overwrite analog_output's current_value or multistate_output's current
value to make the roller work.
"""
if command_id == UP_OPEN:
(res,) = await self.endpoint.multistate_output.write_attributes(
{"present_value": 1}
)
return foundation.GENERAL_COMMANDS[
foundation.GeneralCommand.Default_Response
].schema(command_id=command_id, status=res[0].status)
if command_id == DOWN_CLOSE:
(res,) = await self.endpoint.multistate_output.write_attributes(
{"present_value": 0}
)
return foundation.GENERAL_COMMANDS[
foundation.GeneralCommand.Default_Response
].schema(command_id=command_id, status=res[0].status)
if command_id == GO_TO_LIFT_PERCENTAGE:
(res,) = await self.endpoint.analog_output.write_attributes(
{"present_value": (100 - args[0])}
)
return foundation.GENERAL_COMMANDS[
foundation.GeneralCommand.Default_Response
].schema(command_id=command_id, status=res[0].status)
if command_id == STOP:
(res,) = await self.endpoint.multistate_output.write_attributes(
{"present_value": 2}
)
return foundation.GENERAL_COMMANDS[
foundation.GeneralCommand.Default_Response
].schema(command_id=command_id, status=res[0].status)
class MultistateOutputRollerE1(CustomCluster, MultistateOutput):
"""Multistate Output cluster which overwrites present_value.
Otherwise, it gives errors of wrong datatype when using it in the commands.
"""
attributes = MultistateOutput.attributes.copy()
attributes.update(
{
0x0055: ("present_value", t.uint16_t),
}
)
class PowerConfigurationRollerE1(XiaomiPowerConfiguration):
"""Power cluster which ignores Xiaomi voltage reports."""
def _update_battery_percentage(self, voltage_mv: int) -> None:
"""Ignore Xiaomi voltage reports, so they're not used to calculate battery percentage."""
# This device sends battery percentage reports which are handled using a XiaomiCluster and
# the inherited XiaomiPowerConfiguration cluster.
# This device might also send Xiaomi battery reports, so we only want to use those for the voltage attribute,
# but not for the battery percentage. XiaomiPowerConfiguration.battery_reported() still updates the voltage.
class RollerE1AQ(XiaomiCustomDevice):
"""Aqara Roller Shade Driver E1 device."""
signature = {
MODELS_INFO: [(LUMI, "lumi.curtain.acn002")],
ENDPOINTS: {
# <SizePrefixedSimpleDescriptor endpoint=1 profile=260 device_type=256
# device_version=1
# input_clusters=[0, 2, 3, 4, 5, 6, 9, 64704, 13, 19, 258]
# output_clusters=[10, 25]>
1: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.ON_OFF_LIGHT,
INPUT_CLUSTERS: [
Alarms.cluster_id,
AnalogOutput.cluster_id,
Basic.cluster_id,
DeviceTemperature.cluster_id,
Groups.cluster_id,
Identify.cluster_id,
XiaomiAqaraRollerE1.cluster_id,
MultistateOutput.cluster_id,
OnOff.cluster_id,
Scenes.cluster_id,
WindowCovering.cluster_id,
],
OUTPUT_CLUSTERS: [
Ota.cluster_id,
Time.cluster_id,
],
},
# <SizePrefixedSimpleDescriptor endpoint=242 profile=41440 device_type=97
# device_version=0,
# input_clusters=[]
# output_clusters=[33]>
242: {
PROFILE_ID: zgp.PROFILE_ID,
DEVICE_TYPE: zgp.DeviceType.PROXY_BASIC,
INPUT_CLUSTERS: [],
OUTPUT_CLUSTERS: [
GreenPowerProxy.cluster_id,
],
},
},
}
replacement = {
ENDPOINTS: {
1: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.WINDOW_COVERING_DEVICE,
INPUT_CLUSTERS: [
Alarms.cluster_id,
AnalogOutputRollerE1,
BasicCluster,
DeviceTemperature.cluster_id,
Groups.cluster_id,
Identify.cluster_id,
XiaomiAqaraRollerE1,
MultistateOutputRollerE1,
Scenes.cluster_id,
WindowCoveringRollerE1,
PowerConfigurationRollerE1,
],
OUTPUT_CLUSTERS: [
Ota.cluster_id,
Time.cluster_id,
],
},
242: {
PROFILE_ID: zgp.PROFILE_ID,
DEVICE_TYPE: zgp.DeviceType.PROXY_BASIC,
INPUT_CLUSTERS: [],
OUTPUT_CLUSTERS: [
GreenPowerProxy.cluster_id,
],
},
},
}
class RollerE1AQ_2(RollerE1AQ):
"""Aqara Roller Shade Driver E1 (version 2) device."""
signature = {
MODELS_INFO: [(LUMI, "lumi.curtain.acn002")],
ENDPOINTS: {
# <SizePrefixedSimpleDescriptor endpoint=1 profile=260 device_type=256
# device_version=1
# input_clusters=[0, 2, 3, 4, 5, 6, 9, 13, 19, 258]
# output_clusters=[10, 25]>
1: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.ON_OFF_LIGHT,
INPUT_CLUSTERS: [
Alarms.cluster_id,
AnalogOutput.cluster_id,
Basic.cluster_id,
DeviceTemperature.cluster_id,
Groups.cluster_id,
Identify.cluster_id,
MultistateOutput.cluster_id,
OnOff.cluster_id,
Scenes.cluster_id,
WindowCovering.cluster_id,
],
OUTPUT_CLUSTERS: [
Ota.cluster_id,
Time.cluster_id,
],
},
# <SizePrefixedSimpleDescriptor endpoint=242 profile=41440 device_type=97
# device_version=0,
# input_clusters=[]
# output_clusters=[33]>
242: {
PROFILE_ID: zgp.PROFILE_ID,
DEVICE_TYPE: zgp.DeviceType.PROXY_BASIC,
INPUT_CLUSTERS: [],
OUTPUT_CLUSTERS: [
GreenPowerProxy.cluster_id,
],
},
},
}
class RollerE1AQ_3(RollerE1AQ):
"""Aqara Roller Shade Driver E1 (version 3) device."""
signature = {
MODELS_INFO: [(LUMI, "lumi.curtain.acn002")],
ENDPOINTS: {
# <SizePrefixedSimpleDescriptor endpoint=1 profile=260 device_type=514
# device_version=1
# input_clusters=[0, 2, 3, 4, 5, 6, 9, 13, 19, 258]
# output_clusters=[10, 25]>
1: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.WINDOW_COVERING_DEVICE,
INPUT_CLUSTERS: [
Alarms.cluster_id,
AnalogOutput.cluster_id,
Basic.cluster_id,
DeviceTemperature.cluster_id,
Groups.cluster_id,
Identify.cluster_id,
MultistateOutput.cluster_id,
OnOff.cluster_id,
Scenes.cluster_id,
WindowCovering.cluster_id,
],
OUTPUT_CLUSTERS: [
Ota.cluster_id,
Time.cluster_id,
],
},
# <SizePrefixedSimpleDescriptor endpoint=242 profile=41440 device_type=97
# device_version=0,
# input_clusters=[]
# output_clusters=[33]>
242: {
PROFILE_ID: zgp.PROFILE_ID,
DEVICE_TYPE: zgp.DeviceType.PROXY_BASIC,
INPUT_CLUSTERS: [],
OUTPUT_CLUSTERS: [
GreenPowerProxy.cluster_id,
],
},
},
} | zha-quirks | /zha_quirks-0.0.103-py3-none-any.whl/zhaquirks/xiaomi/aqara/roller_curtain_e1.py | roller_curtain_e1.py |
from __future__ import annotations
import logging
from typing import Any
from zigpy.profiles import zha
from zigpy.quirks import CustomDevice
import zigpy.types as types
from zigpy.zcl.clusters.general import Basic, Identify, Ota, PowerConfiguration
from zigpy.zcl.clusters.measurement import IlluminanceMeasurement, OccupancySensing
from zhaquirks import Bus, LocalDataCluster
from zhaquirks.const import (
DEVICE_TYPE,
ENDPOINTS,
INPUT_CLUSTERS,
MODELS_INFO,
OUTPUT_CLUSTERS,
PROFILE_ID,
)
from zhaquirks.xiaomi import (
IlluminanceMeasurementCluster,
MotionCluster,
OccupancyCluster,
XiaomiAqaraE1Cluster,
XiaomiPowerConfiguration,
)
MOTION_ATTRIBUTE = 274
DETECTION_INTERVAL = 0x0102
MOTION_SENSITIVITY = 0x010C
TRIGGER_INDICATOR = 0x0152
_LOGGER = logging.getLogger(__name__)
class OppleCluster(XiaomiAqaraE1Cluster):
"""Opple cluster."""
ep_attribute = "opple_cluster"
attributes = {
DETECTION_INTERVAL: ("detection_interval", types.uint8_t, True),
MOTION_SENSITIVITY: ("motion_sensitivity", types.uint8_t, True),
TRIGGER_INDICATOR: ("trigger_indicator", types.uint8_t, True),
}
def _update_attribute(self, attrid: int, value: Any) -> None:
super()._update_attribute(attrid, value)
if attrid == MOTION_ATTRIBUTE:
value = value - 65536
self.endpoint.illuminance.update_attribute(
IlluminanceMeasurement.AttributeDefs.measured_value.id, value
)
self.endpoint.occupancy.update_attribute(
OccupancySensing.AttributeDefs.occupancy.id,
OccupancySensing.Occupancy.Occupied,
)
async def write_attributes(
self, attributes: dict[str | int, Any], manufacturer: int | None = None
) -> list:
"""Write attributes to device with internal 'attributes' validation."""
result = await super().write_attributes(attributes, manufacturer)
interval = attributes.get(
"detection_interval", attributes.get(DETECTION_INTERVAL)
)
_LOGGER.debug("detection interval: %s", interval)
if interval is not None:
self.endpoint.ias_zone.reset_s = int(interval)
return result
class LocalIlluminanceMeasurementCluster(
LocalDataCluster, IlluminanceMeasurementCluster
):
"""Local illuminance measurement cluster."""
def __init__(self, *args, **kwargs):
"""Init."""
super().__init__(*args, **kwargs)
if self.AttributeDefs.measured_value.id not in self._attr_cache:
# put a default value so the sensor is created
self._update_attribute(self.AttributeDefs.measured_value.id, 0)
def _update_attribute(self, attrid, value):
if attrid == self.AttributeDefs.measured_value.id and (
value < 0 or value > 0xFFDC
):
self.debug(
"Received invalid illuminance value: %s - setting illuminance to 0",
value,
)
value = 0
super()._update_attribute(attrid, value)
class LocalOccupancyCluster(LocalDataCluster, OccupancyCluster):
"""Local occupancy cluster."""
class LocalMotionCluster(MotionCluster):
"""Local motion cluster."""
reset_s: int = 30
class LumiMotionAC02(CustomDevice):
"""Lumi lumi.motion.ac02 (RTCGQ14LM) custom device implementation."""
def __init__(self, *args, **kwargs):
"""Init."""
self.battery_size = 11
self.battery_quantity = 2
self.motion_bus = Bus()
super().__init__(*args, **kwargs)
signature = {
MODELS_INFO: [("LUMI", "lumi.motion.ac02")],
ENDPOINTS: {
1: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.OCCUPANCY_SENSOR,
INPUT_CLUSTERS: [
Basic.cluster_id,
PowerConfiguration.cluster_id,
Identify.cluster_id,
OppleCluster.cluster_id,
],
OUTPUT_CLUSTERS: [
Identify.cluster_id,
Ota.cluster_id,
OppleCluster.cluster_id,
],
}
},
}
replacement = {
ENDPOINTS: {
1: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.OCCUPANCY_SENSOR,
INPUT_CLUSTERS: [
Basic.cluster_id,
XiaomiPowerConfiguration,
Identify.cluster_id,
LocalOccupancyCluster,
LocalMotionCluster,
LocalIlluminanceMeasurementCluster,
OppleCluster,
],
OUTPUT_CLUSTERS: [
Identify.cluster_id,
Ota.cluster_id,
OppleCluster,
],
}
}
} | zha-quirks | /zha_quirks-0.0.103-py3-none-any.whl/zhaquirks/xiaomi/aqara/motion_ac02.py | motion_ac02.py |
import logging
import math
from zigpy.profiles import zha
from zigpy.quirks import CustomCluster
import zigpy.types as types
from zigpy.zcl.clusters.closures import DoorLock
from zigpy.zcl.clusters.general import (
Basic,
Groups,
Identify,
MultistateInput,
Ota,
Scenes,
)
from zigpy.zcl.clusters.security import IasZone
from zhaquirks import Bus, LocalDataCluster, MotionOnEvent
from zhaquirks.const import (
CLUSTER_ID,
COMMAND,
COMMAND_TILT,
DEVICE_TYPE,
ENDPOINT_ID,
ENDPOINTS,
INPUT_CLUSTERS,
MODELS_INFO,
MOTION_EVENT,
NODE_DESCRIPTOR,
OUTPUT_CLUSTERS,
PROFILE_ID,
SKIP_CONFIGURATION,
UNKNOWN,
ZHA_SEND_EVENT,
ZONE_TYPE,
)
from zhaquirks.xiaomi import (
LUMI,
XIAOMI_NODE_DESC,
BasicCluster,
DeviceTemperatureCluster,
XiaomiPowerConfiguration,
XiaomiQuickInitDevice,
)
DROP_VALUE = 3
ORIENTATION_ATTR = 0x0508 # decimal = 1288
RECENT_ACTIVITY_LEVEL_ATTR = 0x0505 # decimal = 1285
ROTATION_DEGREES_ATTR = 0x0503 # decimal = 1283
SEND_EVENT = "send_event"
STATIONARY_VALUE = 0
STATUS_TYPE_ATTR = 0x0055 # decimal = 85
TILT_VALUE = 2
TILTED = "device_tilted"
VIBE_DEVICE_TYPE = 0x5F02 # decimal = 24322
VIBE_VALUE = 1
MEASUREMENT_TYPE = {
STATIONARY_VALUE: "Stationary",
VIBE_VALUE: "Vibration",
TILT_VALUE: "Tilt",
DROP_VALUE: "Drop",
}
_LOGGER = logging.getLogger(__name__)
class VibrationAQ1(XiaomiQuickInitDevice):
"""Xiaomi aqara smart motion sensor device."""
manufacturer_id_override = 0x115F
def __init__(self, *args, **kwargs):
"""Init."""
self.motion_bus = Bus()
super().__init__(*args, **kwargs)
class VibrationBasicCluster(BasicCluster):
"""Vibration cluster."""
attributes = BasicCluster.attributes.copy()
attributes[0xFF0D] = ("sensitivity", types.uint8_t, True)
class MultistateInputCluster(CustomCluster, MultistateInput):
"""Multistate input cluster."""
cluster_id = DoorLock.cluster_id
def __init__(self, *args, **kwargs):
"""Init."""
self._current_state = {}
super().__init__(*args, **kwargs)
def _update_attribute(self, attrid, value):
super()._update_attribute(attrid, value)
if attrid == STATUS_TYPE_ATTR:
self._current_state[STATUS_TYPE_ATTR] = MEASUREMENT_TYPE.get(
value, UNKNOWN
)
if value == VIBE_VALUE:
self.endpoint.device.motion_bus.listener_event(MOTION_EVENT)
elif value == DROP_VALUE:
self.endpoint.device.motion_bus.listener_event(
SEND_EVENT, self._current_state[STATUS_TYPE_ATTR], {}
)
elif attrid == ORIENTATION_ATTR:
x = value & 0xFFFF
y = (value >> 16) & 0xFFFF
z = (value >> 32) & 0xFFFF
X = 0.0 + x
Y = 0.0 + y
Z = 0.0 + z
angleX = round(math.atan(X / math.sqrt(Z * Z + Y * Y)) * 180 / math.pi)
angleY = round(math.atan(Y / math.sqrt(X * X + Z * Z)) * 180 / math.pi)
angleZ = round(math.atan(Z / math.sqrt(X * X + Y * Y)) * 180 / math.pi)
self.endpoint.device.motion_bus.listener_event(
SEND_EVENT,
"current_orientation",
{
"rawValueX": x,
"rawValueY": y,
"rawValueZ": z,
"X": angleX,
"Y": angleY,
"Z": angleZ,
},
)
elif attrid == ROTATION_DEGREES_ATTR:
self.endpoint.device.motion_bus.listener_event(
SEND_EVENT,
self._current_state[STATUS_TYPE_ATTR],
{"degrees": value},
)
elif attrid == RECENT_ACTIVITY_LEVEL_ATTR:
# these seem to be sent every minute when vibration is active
strength = value >> 8
strength = ((strength & 0xFF) << 8) | ((strength >> 8) & 0xFF)
self.endpoint.device.motion_bus.listener_event(
SEND_EVENT,
"vibration_strength",
{"strength": strength},
)
class MotionCluster(LocalDataCluster, MotionOnEvent):
"""Aqara Vibration Sensor."""
_CONSTANT_ATTRIBUTES = {ZONE_TYPE: IasZone.ZoneType.Vibration_Movement_Sensor}
reset_s = 70
def send_event(self, event, *args):
"""Send event."""
self.listener_event(ZHA_SEND_EVENT, event, *args)
signature = {
MODELS_INFO: [(LUMI, "lumi.vibration.aq1")],
NODE_DESCRIPTOR: XIAOMI_NODE_DESC,
ENDPOINTS: {
1: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.DOOR_LOCK,
INPUT_CLUSTERS: [
Basic.cluster_id,
Identify.cluster_id,
Ota.cluster_id,
DoorLock.cluster_id,
],
OUTPUT_CLUSTERS: [
Basic.cluster_id,
Identify.cluster_id,
Groups.cluster_id,
Scenes.cluster_id,
Ota.cluster_id,
DoorLock.cluster_id,
],
},
2: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: VIBE_DEVICE_TYPE,
INPUT_CLUSTERS: [Identify.cluster_id, MultistateInput.cluster_id],
OUTPUT_CLUSTERS: [
Identify.cluster_id,
Groups.cluster_id,
Scenes.cluster_id,
MultistateInput.cluster_id,
],
},
},
}
replacement = {
SKIP_CONFIGURATION: True,
ENDPOINTS: {
1: {
DEVICE_TYPE: zha.DeviceType.DOOR_LOCK,
INPUT_CLUSTERS: [
VibrationBasicCluster,
XiaomiPowerConfiguration,
DeviceTemperatureCluster,
Identify.cluster_id,
MotionCluster,
Ota.cluster_id,
MultistateInputCluster,
],
OUTPUT_CLUSTERS: [
VibrationBasicCluster,
Identify.cluster_id,
Groups.cluster_id,
Scenes.cluster_id,
Ota.cluster_id,
],
},
2: {
DEVICE_TYPE: VIBE_DEVICE_TYPE,
INPUT_CLUSTERS: [Identify.cluster_id],
OUTPUT_CLUSTERS: [
Identify.cluster_id,
Groups.cluster_id,
Scenes.cluster_id,
MultistateInput.cluster_id,
],
},
},
}
device_automation_triggers = {
(TILTED, TILTED): {COMMAND: COMMAND_TILT, CLUSTER_ID: 1280, ENDPOINT_ID: 1}
} | zha-quirks | /zha_quirks-0.0.103-py3-none-any.whl/zhaquirks/xiaomi/aqara/vibration_aq1.py | vibration_aq1.py |
import logging
import zigpy
from zigpy.profiles import zgp, zha
import zigpy.types as types
from zigpy.zcl.clusters.general import (
Alarms,
AnalogInput,
Basic,
DeviceTemperature,
GreenPowerProxy,
Groups,
Identify,
OnOff,
Ota,
Scenes,
Time,
)
from zigpy.zcl.clusters.homeautomation import ElectricalMeasurement
from zigpy.zcl.clusters.smartenergy import Metering
from zhaquirks.const import (
DEVICE_TYPE,
ENDPOINTS,
INPUT_CLUSTERS,
MODELS_INFO,
OUTPUT_CLUSTERS,
PROFILE_ID,
)
from zhaquirks.xiaomi import (
LUMI,
AnalogInputCluster,
BasicCluster,
ElectricalMeasurementCluster,
MeteringCluster,
XiaomiAqaraE1Cluster,
XiaomiCustomDevice,
)
_LOGGER = logging.getLogger(__name__)
OPPLE_MFG_CODE = 0x115F
async def remove_from_ep(dev: zigpy.device.Device) -> None:
"""Remove devices that are in group 0 by default, so IKEA devices don't control them.
This is only needed for newer firmware versions. Only a downgrade will fully fix this but this should improve it.
See https://github.com/zigpy/zha-device-handlers/pull/1656#issuecomment-1244750465 for details.
"""
endpoint = dev.endpoints.get(1)
if endpoint is not None:
dev.debug("Removing endpoint 1 from group 0")
await endpoint.remove_from_group(0)
dev.debug("Removed endpoint 1 from group 0")
class OppleCluster(XiaomiAqaraE1Cluster):
"""Opple cluster."""
ep_attribute = "opple_cluster"
attributes = {
0x0009: ("mode", types.uint8_t, True),
0x0201: ("power_outage_memory", types.Bool, True),
0x0207: ("consumer_connected", types.Bool, True),
}
# This only exists on older firmware versions. Newer versions always have the behavior as if this was set to true
attr_config = {0x0009: 0x01}
async def bind(self):
"""Bind cluster."""
result = await super().bind()
# Request seems to time out, but still writes the attribute successfully
self.create_catching_task(
self.write_attributes(self.attr_config, manufacturer=OPPLE_MFG_CODE)
)
await remove_from_ep(self.endpoint.device)
return result
class PlugMMEU01(XiaomiCustomDevice):
"""lumi.plug.mmeu01 plug."""
signature = {
MODELS_INFO: [
(LUMI, "lumi.plug.mmeu01"),
],
ENDPOINTS: {
# <SimpleDescriptor endpoint=1 profile=260 device_type=81
# device_version=1
# input_clusters=[0, 2, 3, 4, 5, 6, 9, 1794, 2820]
# output_clusters=[10, 25]>
1: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.SMART_PLUG,
INPUT_CLUSTERS: [
Basic.cluster_id,
DeviceTemperature.cluster_id,
Identify.cluster_id,
Groups.cluster_id,
Scenes.cluster_id,
OnOff.cluster_id,
Alarms.cluster_id,
Metering.cluster_id,
ElectricalMeasurement.cluster_id,
],
OUTPUT_CLUSTERS: [Time.cluster_id, Ota.cluster_id],
},
# <SimpleDescriptor endpoint=242 profile=41440 device_type=97
# device_version=0
# input_clusters=[]
# output_clusters=[33]>
242: {
PROFILE_ID: zgp.PROFILE_ID,
DEVICE_TYPE: zgp.DeviceType.PROXY_BASIC,
OUTPUT_CLUSTERS: [GreenPowerProxy.cluster_id],
},
},
}
replacement = {
ENDPOINTS: {
1: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.SMART_PLUG,
INPUT_CLUSTERS: [
BasicCluster,
DeviceTemperature.cluster_id,
Identify.cluster_id,
Groups.cluster_id,
Scenes.cluster_id,
OnOff.cluster_id,
Alarms.cluster_id,
MeteringCluster,
ElectricalMeasurementCluster,
OppleCluster,
],
OUTPUT_CLUSTERS: [Time.cluster_id, Ota.cluster_id],
},
21: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.SMART_PLUG,
INPUT_CLUSTERS: [AnalogInputCluster],
},
242: {
PROFILE_ID: zgp.PROFILE_ID,
DEVICE_TYPE: zgp.DeviceType.PROXY_BASIC,
OUTPUT_CLUSTERS: [GreenPowerProxy.cluster_id],
},
},
}
class PlugMMEU01Alt1(PlugMMEU01):
"""lumi.plug.mmeu01 plug with alternative signature."""
signature = {
MODELS_INFO: PlugMMEU01.signature[MODELS_INFO],
ENDPOINTS: {
# <SimpleDescriptor endpoint=1 profile=260 device_type=81
# device_version=1
# input_clusters=[0, 2, 3, 4, 5, 6, 64704]
# output_clusters=[10, 25]>
1: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.SMART_PLUG,
INPUT_CLUSTERS: [
Basic.cluster_id,
DeviceTemperature.cluster_id,
Identify.cluster_id,
Groups.cluster_id,
Scenes.cluster_id,
OnOff.cluster_id,
OppleCluster.cluster_id,
],
OUTPUT_CLUSTERS: [Time.cluster_id, Ota.cluster_id],
},
# <SimpleDescriptor endpoint=21 profile=260 device_type=81
# device_version=1
# input_clusters=[12]
# output_clusters=[]>
21: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.SMART_PLUG,
INPUT_CLUSTERS: [AnalogInput.cluster_id],
},
# <SimpleDescriptor endpoint=31 profile=260 device_type=81
# device_version=1
# input_clusters=[12]
# output_clusters=[]>
31: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.SMART_PLUG,
INPUT_CLUSTERS: [AnalogInput.cluster_id],
},
# <SimpleDescriptor endpoint=242 profile=41440 device_type=97
# device_version=0
# input_clusters=[]
# output_clusters=[33]>
242: {
PROFILE_ID: zgp.PROFILE_ID,
DEVICE_TYPE: zgp.DeviceType.PROXY_BASIC,
OUTPUT_CLUSTERS: [GreenPowerProxy.cluster_id],
},
},
}
replacement = PlugMMEU01.replacement
class PlugMMEU01Alt2(PlugMMEU01):
"""lumi.plug.mmeu01 plug with alternative signature."""
signature = {
MODELS_INFO: PlugMMEU01.signature[MODELS_INFO],
ENDPOINTS: {
# <SimpleDescriptor endpoint=1 profile=260 device_type=81
# device_version=1
# input_clusters=[0, 2, 3, 4, 5, 6, 64704]
# output_clusters=[10, 25]>
1: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.SMART_PLUG,
INPUT_CLUSTERS: [
Basic.cluster_id,
DeviceTemperature.cluster_id,
Identify.cluster_id,
Groups.cluster_id,
Scenes.cluster_id,
OnOff.cluster_id,
OppleCluster.cluster_id,
],
OUTPUT_CLUSTERS: [Time.cluster_id, Ota.cluster_id],
},
# <SimpleDescriptor endpoint=242 profile=41440 device_type=97
# device_version=0
# input_clusters=[]
# output_clusters=[33]>
242: {
PROFILE_ID: zgp.PROFILE_ID,
DEVICE_TYPE: zgp.DeviceType.PROXY_BASIC,
OUTPUT_CLUSTERS: [GreenPowerProxy.cluster_id],
},
},
}
replacement = PlugMMEU01.replacement
class PlugMMEU01Alt3(PlugMMEU01):
"""lumi.plug.mmeu01 plug with alternative signature."""
signature = {
MODELS_INFO: PlugMMEU01.signature[MODELS_INFO],
ENDPOINTS: {
# <SimpleDescriptor endpoint=1 profile=260 device_type=81
# device_version=1
# input_clusters=[0, 2, 3, 4, 5, 6, 64704]
# output_clusters=[10, 25]>
1: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.SMART_PLUG,
INPUT_CLUSTERS: [
Basic.cluster_id,
DeviceTemperature.cluster_id,
Identify.cluster_id,
Groups.cluster_id,
Scenes.cluster_id,
OnOff.cluster_id,
OppleCluster.cluster_id,
],
OUTPUT_CLUSTERS: [Time.cluster_id, Ota.cluster_id],
},
# <SimpleDescriptor endpoint=21 profile=260 device_type=81
# device_version=1
# input_clusters=[12]
# output_clusters=[]>
21: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.SMART_PLUG,
INPUT_CLUSTERS: [AnalogInput.cluster_id],
},
# <SimpleDescriptor endpoint=22 profile=260 device_type=81
# device_version=1
# input_clusters=[12]
# output_clusters=[]>
22: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.SMART_PLUG,
INPUT_CLUSTERS: [AnalogInput.cluster_id],
},
# <SimpleDescriptor endpoint=242 profile=41440 device_type=97
# device_version=0
# input_clusters=[]
# output_clusters=[33]>
242: {
PROFILE_ID: zgp.PROFILE_ID,
DEVICE_TYPE: zgp.DeviceType.PROXY_BASIC,
OUTPUT_CLUSTERS: [GreenPowerProxy.cluster_id],
},
},
}
replacement = PlugMMEU01.replacement
class PlugMAEU01(PlugMMEU01):
"""lumi.plug.maeu01 plug."""
signature = {
MODELS_INFO: [
(LUMI, "lumi.plug.maeu01"),
],
ENDPOINTS: PlugMMEU01.signature[ENDPOINTS],
}
replacement = PlugMMEU01.replacement
class PlugMAEU01Alt1(PlugMAEU01):
"""lumi.plug.maeu01 plug with alternative signature."""
signature = {
MODELS_INFO: PlugMAEU01.signature[MODELS_INFO],
ENDPOINTS: PlugMMEU01Alt1.signature[ENDPOINTS],
}
replacement = PlugMAEU01.replacement
class PlugMAEU01Alt2(PlugMAEU01):
"""lumi.plug.maeu01 plug with alternative signature."""
signature = {
MODELS_INFO: PlugMAEU01.signature[MODELS_INFO],
ENDPOINTS: PlugMMEU01Alt2.signature[ENDPOINTS],
}
replacement = PlugMAEU01.replacement
class PlugMAEU01Alt3(PlugMAEU01):
"""lumi.plug.maeu01 plug with alternative signature."""
signature = {
MODELS_INFO: PlugMAEU01.signature[MODELS_INFO],
ENDPOINTS: PlugMMEU01Alt3.signature[ENDPOINTS],
}
replacement = PlugMAEU01.replacement | zha-quirks | /zha_quirks-0.0.103-py3-none-any.whl/zhaquirks/xiaomi/aqara/plug_eu.py | plug_eu.py |
from zigpy.profiles import zgp, zha
from zigpy.quirks import CustomDevice
from zigpy.zcl.clusters.general import (
Alarms,
Basic,
GreenPowerProxy,
Groups,
Identify,
OnOff,
Ota,
Scenes,
Time,
)
from zhaquirks.const import (
ARGS,
ATTR_ID,
BUTTON,
CLUSTER_ID,
COMMAND,
COMMAND_DOUBLE,
COMMAND_HOLD,
COMMAND_SINGLE,
DEVICE_TYPE,
DOUBLE_PRESS,
ENDPOINT_ID,
ENDPOINTS,
INPUT_CLUSTERS,
LONG_PRESS,
MODELS_INFO,
OUTPUT_CLUSTERS,
PRESS_TYPE,
PROFILE_ID,
SHORT_PRESS,
VALUE,
)
from zhaquirks.xiaomi import (
LUMI,
BasicCluster,
DeviceTemperatureCluster,
OnOffCluster,
XiaomiMeteringCluster,
)
from zhaquirks.xiaomi.aqara.opple_remote import MultistateInputCluster
from zhaquirks.xiaomi.aqara.opple_switch import OppleSwitchCluster
XIAOMI_COMMAND_SINGLE = "41_single"
XIAOMI_COMMAND_DOUBLE = "41_double"
XIAOMI_COMMAND_HOLD = "1_hold"
class AqaraH1SingleRockerBase(CustomDevice):
"""Device automation triggers for the Aqara H1 Single Rocker Switches"""
device_automation_triggers = {
(SHORT_PRESS, BUTTON): {
ENDPOINT_ID: 41,
CLUSTER_ID: 18,
COMMAND: XIAOMI_COMMAND_SINGLE,
ARGS: {ATTR_ID: 0x0055, PRESS_TYPE: COMMAND_SINGLE, VALUE: 1},
},
(DOUBLE_PRESS, BUTTON): {
ENDPOINT_ID: 41,
CLUSTER_ID: 18,
COMMAND: XIAOMI_COMMAND_DOUBLE,
ARGS: {ATTR_ID: 0x0055, PRESS_TYPE: COMMAND_DOUBLE, VALUE: 2},
},
(LONG_PRESS, BUTTON): {
ENDPOINT_ID: 1,
CLUSTER_ID: 64704,
COMMAND: XIAOMI_COMMAND_HOLD,
ARGS: {ATTR_ID: 0x00FC, PRESS_TYPE: COMMAND_HOLD, VALUE: 0},
},
}
class AqaraH1SingleRockerSwitchWithNeutral(AqaraH1SingleRockerBase):
"""Aqara H1 Single Rocker Switch (with neutral)."""
signature = {
MODELS_INFO: [(LUMI, "lumi.switch.n1aeu1")],
ENDPOINTS: {
# input_clusters=[0, 2, 3, 4, 5, 6, 18, 64704], output_clusters=[10, 25]
1: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.ON_OFF_LIGHT,
INPUT_CLUSTERS: [
Basic.cluster_id, # 0
DeviceTemperatureCluster.cluster_id, # 2
Identify.cluster_id, # 3
Groups.cluster_id, # 4
Scenes.cluster_id, # 5
OnOff.cluster_id, # 6
Alarms.cluster_id, # 9
XiaomiMeteringCluster.cluster_id, # 0x0702
0x0B04,
],
OUTPUT_CLUSTERS: [
Time.cluster_id, # 0x000a
Ota.cluster_id, # 0x0019
],
},
242: {
PROFILE_ID: zgp.PROFILE_ID,
DEVICE_TYPE: zgp.DeviceType.PROXY_BASIC,
INPUT_CLUSTERS: [],
OUTPUT_CLUSTERS: [
GreenPowerProxy.cluster_id, # 0x0021
],
},
},
}
replacement = {
ENDPOINTS: {
1: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.ON_OFF_SWITCH,
INPUT_CLUSTERS: [
BasicCluster, # 0
DeviceTemperatureCluster.cluster_id, # 2
Identify.cluster_id, # 3
Groups.cluster_id, # 4
Scenes.cluster_id, # 5
OnOffCluster, # 6
Alarms.cluster_id, # 9
MultistateInputCluster, # 18
XiaomiMeteringCluster.cluster_id, # 0x0702
OppleSwitchCluster, # 0xFCC0 / 64704
0x0B04,
],
OUTPUT_CLUSTERS: [
Time.cluster_id,
Ota.cluster_id,
],
},
41: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.ON_OFF_SWITCH,
INPUT_CLUSTERS: [
MultistateInputCluster, # 18
],
OUTPUT_CLUSTERS: [],
},
242: {
PROFILE_ID: zgp.PROFILE_ID,
DEVICE_TYPE: zgp.DeviceType.PROXY_BASIC,
INPUT_CLUSTERS: [],
OUTPUT_CLUSTERS: [GreenPowerProxy.cluster_id],
},
},
}
class AqaraH1SingleRockerSwitchNoNeutral(AqaraH1SingleRockerBase):
"""Aqara H1 Single Rocker Switch (no neutral)."""
signature = {
MODELS_INFO: [(LUMI, "lumi.switch.l1aeu1")],
ENDPOINTS: {
# input_clusters=[0, 2, 3, 4, 5, 6, 9], output_clusters=[10, 25]
1: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.ON_OFF_LIGHT,
INPUT_CLUSTERS: [
Basic.cluster_id, # 0
DeviceTemperatureCluster.cluster_id, # 2
Identify.cluster_id, # 3
Groups.cluster_id, # 4
Scenes.cluster_id, # 5
OnOff.cluster_id, # 6
Alarms.cluster_id, # 9
],
OUTPUT_CLUSTERS: [
Time.cluster_id, # 0x000a
Ota.cluster_id, # 0x0019
],
},
242: {
PROFILE_ID: zgp.PROFILE_ID,
DEVICE_TYPE: zgp.DeviceType.PROXY_BASIC,
INPUT_CLUSTERS: [],
OUTPUT_CLUSTERS: [
GreenPowerProxy.cluster_id, # 0x0021
],
},
},
}
replacement = {
ENDPOINTS: {
1: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.ON_OFF_SWITCH,
INPUT_CLUSTERS: [
BasicCluster, # 0
DeviceTemperatureCluster.cluster_id, # 2
Identify.cluster_id, # 3
Groups.cluster_id, # 4
Scenes.cluster_id, # 5
OnOffCluster, # 6
Alarms.cluster_id, # 9
MultistateInputCluster, # 18
OppleSwitchCluster, # 0xFCC0 / 64704
],
OUTPUT_CLUSTERS: [
Time.cluster_id,
Ota.cluster_id,
],
},
41: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.ON_OFF_SWITCH,
INPUT_CLUSTERS: [
MultistateInputCluster, # 18
],
OUTPUT_CLUSTERS: [],
},
242: {
PROFILE_ID: zgp.PROFILE_ID,
DEVICE_TYPE: zgp.DeviceType.PROXY_BASIC,
INPUT_CLUSTERS: [],
OUTPUT_CLUSTERS: [GreenPowerProxy.cluster_id],
},
},
} | zha-quirks | /zha_quirks-0.0.103-py3-none-any.whl/zhaquirks/xiaomi/aqara/switch_h1.py | switch_h1.py |
import logging
from zigpy.profiles import zha
from zigpy.zcl.clusters.closures import WindowCovering
from zigpy.zcl.clusters.general import (
AnalogOutput,
Groups,
Identify,
LevelControl,
MultistateOutput,
OnOff,
Ota,
PowerConfiguration,
Scenes,
Time,
)
from zigpy.zcl.clusters.lighting import Color
from zigpy.zcl.clusters.measurement import (
OccupancySensing,
PressureMeasurement,
RelativeHumidity,
TemperatureMeasurement,
)
from zhaquirks import CustomCluster
from zhaquirks.const import (
DEVICE_TYPE,
ENDPOINTS,
INPUT_CLUSTERS,
MODELS_INFO,
OUTPUT_CLUSTERS,
PROFILE_ID,
)
from zhaquirks.xiaomi import LUMI, BasicCluster, XiaomiCustomDevice
_LOGGER = logging.getLogger(__name__)
class LightAqcn02(XiaomiCustomDevice):
"""Custom device for ZNLDP12LM."""
class ColorCluster(CustomCluster, Color):
"""Color Cluster."""
_CONSTANT_ATTRIBUTES = {0x400A: 0x0010, 0x400B: 153, 0x400C: 370}
signature = {
# endpoint=1 profile=260 device_type=258 device_version=1 input_clusters=[0, 4, 3, 5, 10, 258, 13, 19, 6, 1, 1030, 8, 768, 1027, 1029, 1026] output_clusters=[25, 10, 13, 258, 19, 6, 1, 1030, 8, 768]>
MODELS_INFO: [(LUMI, "lumi.light.aqcn02")],
ENDPOINTS: {
1: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.COLOR_DIMMABLE_LIGHT,
INPUT_CLUSTERS: [
BasicCluster.cluster_id,
PowerConfiguration.cluster_id,
Identify.cluster_id,
Groups.cluster_id,
Scenes.cluster_id,
OnOff.cluster_id,
LevelControl.cluster_id,
Time.cluster_id,
AnalogOutput.cluster_id,
MultistateOutput.cluster_id,
WindowCovering.cluster_id,
Color.cluster_id,
TemperatureMeasurement.cluster_id,
PressureMeasurement.cluster_id,
RelativeHumidity.cluster_id,
OccupancySensing.cluster_id,
],
OUTPUT_CLUSTERS: [
PowerConfiguration.cluster_id,
OnOff.cluster_id,
LevelControl.cluster_id,
Time.cluster_id,
AnalogOutput.cluster_id,
MultistateOutput.cluster_id,
Ota.cluster_id,
WindowCovering.cluster_id,
ColorCluster.cluster_id,
OccupancySensing.cluster_id,
],
}
},
}
replacement = {
ENDPOINTS: {
1: {
DEVICE_TYPE: zha.DeviceType.COLOR_DIMMABLE_LIGHT,
INPUT_CLUSTERS: [
BasicCluster, # 0
Groups.cluster_id, # 4
Identify.cluster_id, # 3
Scenes.cluster_id, # 5
OnOff.cluster_id, # 6
PowerConfiguration.cluster_id, # 1
LevelControl.cluster_id, # 8
ColorCluster, # 768
],
OUTPUT_CLUSTERS: [
Time.cluster_id, # 10
Ota.cluster_id, # 19
OccupancySensing.cluster_id, # 1030
],
}
}
} | zha-quirks | /zha_quirks-0.0.103-py3-none-any.whl/zhaquirks/xiaomi/aqara/light_aqcn2.py | light_aqcn2.py |
import logging
from zigpy.profiles import zha
from zigpy.zcl.clusters.general import (
AnalogInput,
Basic,
BinaryOutput,
DeviceTemperature,
Groups,
Identify,
OnOff,
Ota,
PowerConfiguration,
Scenes,
Time,
)
from zigpy.zcl.clusters.homeautomation import ElectricalMeasurement
from zhaquirks.const import (
DEVICE_TYPE,
ENDPOINTS,
INPUT_CLUSTERS,
MODELS_INFO,
OUTPUT_CLUSTERS,
PROFILE_ID,
SKIP_CONFIGURATION,
)
from zhaquirks.xiaomi import (
LUMI,
AnalogInputCluster,
BasicCluster,
BinaryOutputInterlock,
ElectricalMeasurementCluster,
XiaomiCustomDevice,
)
_LOGGER = logging.getLogger(__name__)
class Relay(XiaomiCustomDevice):
"""lumi.relay.c2acn01 relay."""
signature = {
MODELS_INFO: [(LUMI, "lumi.relay.c2acn01")],
ENDPOINTS: {
# <SimpleDescriptor endpoint=1 profile=260 device_type=257
# device_version=2
# input_clusters=[0, 3, 4, 5, 1, 2, 10, 6, 16, 2820, 12]
# output_clusters=[25, 10]>
1: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.DIMMABLE_LIGHT,
INPUT_CLUSTERS: [
Basic.cluster_id,
PowerConfiguration.cluster_id,
DeviceTemperature.cluster_id,
Groups.cluster_id,
Identify.cluster_id,
OnOff.cluster_id,
Scenes.cluster_id,
BinaryOutput.cluster_id,
Time.cluster_id,
ElectricalMeasurement.cluster_id,
AnalogInput.cluster_id,
],
OUTPUT_CLUSTERS: [Ota.cluster_id, Time.cluster_id],
},
# <SimpleDescriptor endpoint=2 profile=260 device_type=257
# device_version=2
# input_clusters=[6, 16, 4, 5]
# output_clusters=[]>
2: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.DIMMABLE_LIGHT,
INPUT_CLUSTERS: [
OnOff.cluster_id,
BinaryOutput.cluster_id,
Groups.cluster_id,
Scenes.cluster_id,
],
OUTPUT_CLUSTERS: [],
},
},
}
replacement = {
SKIP_CONFIGURATION: True,
ENDPOINTS: {
1: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.DIMMABLE_LIGHT,
INPUT_CLUSTERS: [
BasicCluster,
PowerConfiguration.cluster_id,
DeviceTemperature.cluster_id,
Groups.cluster_id,
Identify.cluster_id,
OnOff.cluster_id,
Scenes.cluster_id,
BinaryOutputInterlock,
Time.cluster_id,
ElectricalMeasurementCluster,
AnalogInputCluster,
],
OUTPUT_CLUSTERS: [Ota.cluster_id, Time.cluster_id],
},
2: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.DIMMABLE_LIGHT,
INPUT_CLUSTERS: [
OnOff.cluster_id,
BinaryOutputInterlock,
Groups.cluster_id,
Scenes.cluster_id,
],
OUTPUT_CLUSTERS: [],
},
},
} | zha-quirks | /zha_quirks-0.0.103-py3-none-any.whl/zhaquirks/xiaomi/aqara/relay_c2acn01.py | relay_c2acn01.py |
import logging
from zigpy.profiles import zha
from zigpy.zcl.clusters.general import (
AnalogInput,
Basic,
Groups,
Identify,
MultistateInput,
OnOff,
Ota,
Scenes,
)
from zhaquirks import CustomCluster
from zhaquirks.const import (
ATTR_ID,
BUTTON,
BUTTON_1,
BUTTON_2,
COMMAND,
DEVICE_TYPE,
DOUBLE_PRESS,
ENDPOINT_ID,
ENDPOINTS,
INPUT_CLUSTERS,
LONG_PRESS,
MODELS_INFO,
OUTPUT_CLUSTERS,
PRESS_TYPE,
PROFILE_ID,
SHORT_PRESS,
SKIP_CONFIGURATION,
VALUE,
ZHA_SEND_EVENT,
)
from zhaquirks.xiaomi import (
LUMI,
BasicCluster,
DeviceTemperatureCluster,
XiaomiCustomDevice,
XiaomiPowerConfiguration,
)
BOTH_BUTTONS = "both_buttons"
BOTH_DOUBLE = "both_double"
BOTH_HOLD = "both_long press"
BOTH_SINGLE = "both_single"
ENDPOINT_MAP = {1: "left", 2: "right", 3: "both"}
LEFT_DOUBLE = "left_double"
LEFT_HOLD = "left_long press"
LEFT_SINGLE = "left_single"
PRESS_TYPES = {0: "long press", 1: "single", 2: "double"}
RIGHT_DOUBLE = "right_double"
RIGHT_HOLD = "right_long press"
RIGHT_SINGLE = "right_single"
STATUS_TYPE_ATTR = 0x0055 # decimal = 85
XIAOMI_CLUSTER_ID = 0xFFFF
XIAOMI_DEVICE_TYPE = 0x5F01
XIAOMI_DEVICE_TYPE2 = 0x5F02
XIAOMI_DEVICE_TYPE3 = 0x5F03
_LOGGER = logging.getLogger(__name__)
class RemoteB286ACN01(XiaomiCustomDevice):
"""Aqara double key switch device."""
class MultistateInputCluster(CustomCluster, MultistateInput):
"""Multistate input cluster."""
cluster_id = MultistateInput.cluster_id
def __init__(self, *args, **kwargs):
"""Init."""
self._current_state = None
super().__init__(*args, **kwargs)
def _update_attribute(self, attrid, value):
super()._update_attribute(attrid, value)
if attrid == STATUS_TYPE_ATTR:
self._current_state = PRESS_TYPES.get(value)
button = ENDPOINT_MAP.get(self.endpoint.endpoint_id)
event_args = {
BUTTON: button,
PRESS_TYPE: self._current_state,
ATTR_ID: attrid,
VALUE: value,
}
action = f"{button}_{self._current_state}"
self.listener_event(ZHA_SEND_EVENT, action, event_args)
# show something in the sensor in HA
super()._update_attribute(0, action)
signature = {
# <SimpleDescriptor endpoint=1 profile=260 device_type=24321
# device_version=1
# input_clusters=[0, 3, 25, 65535, 18]
# output_clusters=[0, 4, 3, 5, 25, 65535, 18]>
MODELS_INFO: [
(LUMI, "lumi.remote.b286acn01"),
(LUMI, "lumi.remote.b286acn02"),
(LUMI, "lumi.sensor_86sw2"),
],
ENDPOINTS: {
1: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: XIAOMI_DEVICE_TYPE,
INPUT_CLUSTERS: [
Basic.cluster_id,
Identify.cluster_id,
Ota.cluster_id,
XIAOMI_CLUSTER_ID,
MultistateInputCluster.cluster_id,
],
OUTPUT_CLUSTERS: [
Basic.cluster_id,
Identify.cluster_id,
Groups.cluster_id,
Scenes.cluster_id,
Ota.cluster_id,
XIAOMI_CLUSTER_ID,
MultistateInputCluster.cluster_id,
],
},
# <SimpleDescriptor endpoint=2 profile=260 device_type=24322
# device_version=1
# input_clusters=[3, 18]
# output_clusters=[4, 3, 5, 18]>
2: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: XIAOMI_DEVICE_TYPE2,
INPUT_CLUSTERS: [
Identify.cluster_id,
MultistateInputCluster.cluster_id,
],
OUTPUT_CLUSTERS: [
Identify.cluster_id,
Groups.cluster_id,
Scenes.cluster_id,
MultistateInputCluster.cluster_id,
],
},
# <SimpleDescriptor endpoint=3 profile=260 device_type=24323
# device_version=1
# input_clusters=[3, 12]
# output_clusters=[4, 3, 5, 12]>
3: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: XIAOMI_DEVICE_TYPE3,
INPUT_CLUSTERS: [Identify.cluster_id, AnalogInput.cluster_id],
OUTPUT_CLUSTERS: [
Identify.cluster_id,
Groups.cluster_id,
Scenes.cluster_id,
AnalogInput.cluster_id,
],
},
},
}
replacement = {
SKIP_CONFIGURATION: True,
ENDPOINTS: {
1: {
DEVICE_TYPE: zha.DeviceType.REMOTE_CONTROL,
INPUT_CLUSTERS: [
BasicCluster,
XiaomiPowerConfiguration,
DeviceTemperatureCluster,
Identify.cluster_id,
Ota.cluster_id,
XIAOMI_CLUSTER_ID,
MultistateInputCluster,
],
OUTPUT_CLUSTERS: [
Basic.cluster_id,
Identify.cluster_id,
Groups.cluster_id,
Scenes.cluster_id,
Ota.cluster_id,
XIAOMI_CLUSTER_ID,
MultistateInputCluster,
OnOff.cluster_id,
],
},
2: {
DEVICE_TYPE: zha.DeviceType.REMOTE_CONTROL,
INPUT_CLUSTERS: [Identify.cluster_id, MultistateInputCluster],
OUTPUT_CLUSTERS: [
Identify.cluster_id,
Groups.cluster_id,
Scenes.cluster_id,
MultistateInputCluster,
OnOff.cluster_id,
],
},
3: {
DEVICE_TYPE: zha.DeviceType.REMOTE_CONTROL,
INPUT_CLUSTERS: [Identify.cluster_id, MultistateInputCluster],
OUTPUT_CLUSTERS: [
Identify.cluster_id,
Groups.cluster_id,
Scenes.cluster_id,
AnalogInput.cluster_id,
MultistateInputCluster,
OnOff.cluster_id,
],
},
},
}
device_automation_triggers = {
(DOUBLE_PRESS, BUTTON_1): {COMMAND: LEFT_DOUBLE, ENDPOINT_ID: 1},
(SHORT_PRESS, BUTTON_1): {COMMAND: LEFT_SINGLE, ENDPOINT_ID: 1},
(LONG_PRESS, BUTTON_1): {COMMAND: LEFT_HOLD, ENDPOINT_ID: 1},
(DOUBLE_PRESS, BUTTON_2): {COMMAND: RIGHT_DOUBLE, ENDPOINT_ID: 2},
(SHORT_PRESS, BUTTON_2): {COMMAND: RIGHT_SINGLE, ENDPOINT_ID: 2},
(LONG_PRESS, BUTTON_2): {COMMAND: RIGHT_HOLD, ENDPOINT_ID: 2},
(DOUBLE_PRESS, BOTH_BUTTONS): {COMMAND: BOTH_DOUBLE, ENDPOINT_ID: 3},
(SHORT_PRESS, BOTH_BUTTONS): {COMMAND: BOTH_SINGLE, ENDPOINT_ID: 3},
(LONG_PRESS, BOTH_BUTTONS): {COMMAND: BOTH_HOLD, ENDPOINT_ID: 3},
} | zha-quirks | /zha_quirks-0.0.103-py3-none-any.whl/zhaquirks/xiaomi/aqara/remote_b286acn01.py | remote_b286acn01.py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.