Skip to content

Commit

Permalink
Merge branch 'dev' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
Caius-Bonus authored Sep 29, 2023
2 parents bce3c3c + 74b9f04 commit 4442b2b
Show file tree
Hide file tree
Showing 7 changed files with 244 additions and 3 deletions.
18 changes: 18 additions & 0 deletions tests/test_xbee.py
Original file line number Diff line number Diff line change
Expand Up @@ -641,3 +641,21 @@ def mock_at_response(*args, **kwargs):
assert 33.33333 < analog_listeners[0].attribute_updates[0][1] < 33.33334
assert 66.66666 < analog_listeners[2].attribute_updates[0][1] < 66.66667
assert analog_listeners[4].attribute_updates[0] == (0x0055, 3.305)


@mock.patch("zigpy.zdo.ZDO.handle_ieee_addr_req")
async def test_zdo(handle_mgmt_lqi_resp, zigpy_device_from_quirk):
"""Test receiving ZDO data from XBee device."""

xbee3_device = zigpy_device_from_quirk(XBee3Sensor)

# Receive ZDOCmd.IEEE_addr_req
xbee3_device.handle_message(0, 0x0001, 0, 0, b"\x07\x34\x12\x00\x00")

assert handle_mgmt_lqi_resp.call_count == 1
assert len(handle_mgmt_lqi_resp.call_args_list[0][0]) == 4
assert handle_mgmt_lqi_resp.call_args_list[0][0][0].tsn == 0x07
assert handle_mgmt_lqi_resp.call_args_list[0][0][0].command_id == 0x0001
assert handle_mgmt_lqi_resp.call_args_list[0][0][1] == 0x1234
assert handle_mgmt_lqi_resp.call_args_list[0][0][2] == 0
assert handle_mgmt_lqi_resp.call_args_list[0][0][3] == 0
72 changes: 71 additions & 1 deletion zhaquirks/ikea/tradfriplug.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
from zhaquirks.ikea import IKEA, IKEA_CLUSTER_ID


class TradfriPlug(CustomDevice):
class TradfriPlug1(CustomDevice):
"""Tradfri Plug."""

signature = {
Expand Down Expand Up @@ -94,3 +94,73 @@ class TradfriPlug(CustomDevice):
}
}
}


class TradfriPlug2(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, 4096] output_clusters=[5, 25, 32, 4096]>
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,
LightLink.cluster_id,
],
OUTPUT_CLUSTERS: [
Scenes.cluster_id,
Ota.cluster_id,
PollControl.cluster_id,
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,
LightLink.cluster_id,
],
OUTPUT_CLUSTERS: [
Scenes.cluster_id,
Ota.cluster_id,
PollControl.cluster_id,
LightLink.cluster_id,
],
},
242: {
PROFILE_ID: zgp.PROFILE_ID,
DEVICE_TYPE: zgp.DeviceType.PROXY_BASIC,
INPUT_CLUSTERS: [GreenPowerProxy.cluster_id],
OUTPUT_CLUSTERS: [GreenPowerProxy.cluster_id],
},
},
}
14 changes: 12 additions & 2 deletions zhaquirks/tuya/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
TUYA_CLUSTER_ID = 0xEF00
TUYA_CLUSTER_E000_ID = 0xE000
TUYA_CLUSTER_E001_ID = 0xE001
TUYA_CLUSTER_1888_ID = 0x1888
# ---------------------------------------------------------
# Tuya Cluster Commands
# ---------------------------------------------------------
Expand Down Expand Up @@ -1105,9 +1106,9 @@ class TuyaZBElectricalMeasurement(CustomCluster, ElectricalMeasurement):
class TuyaZBE000Cluster(CustomCluster):
"""Tuya manufacturer specific cluster 57344."""

name = "Tuya Manufacturer Specific"
name = "Tuya Manufacturer Specific 0"
cluster_id = TUYA_CLUSTER_E000_ID
ep_attribute = "tuya_is_pita_0"
ep_attribute = "tuya_manufacturer_specific_57344"


# Tuya Zigbee Cluster 0xE001 Implementation
Expand All @@ -1128,6 +1129,15 @@ class TuyaZBExternalSwitchTypeCluster(CustomCluster):
attributes = {0xD030: ("external_switch_type", ExternalSwitchType)}


# Tuya Zigbee Cluster 0x1888 Implementation
class TuyaZB1888Cluster(CustomCluster):
"""Tuya manufacturer specific cluster 6280."""

name = "Tuya Manufacturer Specific 1"
cluster_id = TUYA_CLUSTER_1888_ID
ep_attribute = "tuya_manufacturer_specific_6280"


# Tuya Window Cover Implementation
class TuyaManufacturerWindowCover(TuyaManufCluster):
"""Manufacturer Specific Cluster for cover device."""
Expand Down
73 changes: 73 additions & 0 deletions zhaquirks/tuya/ts011f_plug.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
Time,
)
from zigpy.zcl.clusters.homeautomation import ElectricalMeasurement
from zigpy.zcl.clusters.lightlink import LightLink
from zigpy.zcl.clusters.measurement import TemperatureMeasurement
from zigpy.zcl.clusters.smartenergy import Metering

Expand All @@ -27,6 +28,7 @@
)
from zhaquirks.tuya import (
TuyaNewManufCluster,
TuyaZB1888Cluster,
TuyaZBE000Cluster,
TuyaZBElectricalMeasurement,
TuyaZBExternalSwitchTypeCluster,
Expand Down Expand Up @@ -1074,6 +1076,77 @@ class Plug_v2(EnchantedDevice):
}


class Plug_v3(EnchantedDevice):
"""Tuya TS011F plug. One plug is _Tz3000_0Zfrhq4I."""

signature = {
MODEL: "TS011F",
ENDPOINTS: {
1: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.SMART_PLUG,
INPUT_CLUSTERS: [
Basic.cluster_id,
Identify.cluster_id,
Groups.cluster_id,
Scenes.cluster_id,
OnOff.cluster_id,
Time.cluster_id,
Metering.cluster_id,
ElectricalMeasurement.cluster_id,
LightLink.cluster_id,
TuyaZB1888Cluster.cluster_id,
TuyaZBE000Cluster.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.SMART_PLUG,
INPUT_CLUSTERS: [
Basic.cluster_id,
Identify.cluster_id,
Groups.cluster_id,
Scenes.cluster_id,
TuyaZBOnOffAttributeCluster,
Time.cluster_id,
TuyaZBMeteringClusterWithUnit,
TuyaZBElectricalMeasurement,
LightLink.cluster_id,
TuyaZB1888Cluster,
TuyaZBE000Cluster,
],
OUTPUT_CLUSTERS: [
Ota.cluster_id,
],
},
242: {
PROFILE_ID: zgp.PROFILE_ID,
DEVICE_TYPE: zgp.DeviceType.PROXY_BASIC,
INPUT_CLUSTERS: [],
OUTPUT_CLUSTERS: [
GreenPowerProxy.cluster_id,
],
},
},
}


class Plug_2AC_var03(CustomDevice):
"""Tuya 2 socket wall outlet with child lock and power-restore state support."""

Expand Down
1 change: 1 addition & 0 deletions zhaquirks/tuya/ts0601_cover.py
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,7 @@ class TuyaMoesCover0601(TuyaWindowCover):
("_TZE200_7eue9vhc", "TS0601"),
("_TZE200_bv1jcqqu", "TS0601"),
("_TZE200_nw1r9hp6", "TS0601"),
("_TZE200_gaj531w3", "TS0601"),
],
ENDPOINTS: {
1: {
Expand Down
2 changes: 2 additions & 0 deletions zhaquirks/xbee/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -629,6 +629,8 @@ def remote_at(self, command, *args, **kwargs):

def deserialize(self, endpoint_id, cluster_id, data):
"""Deserialize."""
if endpoint_id == 0:
return super().deserialize(endpoint_id, cluster_id, data)
tsn = self._application.get_sequence()
command_id = 0x0000
hdr = foundation.ZCLHeader.cluster(tsn, command_id)
Expand Down
67 changes: 67 additions & 0 deletions zhaquirks/xiaomi/aqara/water_agl02.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
"""Quirk for Aqara T1 water leak sensor lumi.flood.agl02."""

from zigpy.profiles import zha
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.const import (
DEVICE_TYPE,
ENDPOINTS,
INPUT_CLUSTERS,
MODELS_INFO,
NODE_DESCRIPTOR,
OUTPUT_CLUSTERS,
PROFILE_ID,
)
from zhaquirks.xiaomi import (
BasicCluster,
XiaomiAqaraE1Cluster,
XiaomiCustomDevice,
XiaomiPowerConfiguration,
)


class WaterT1(XiaomiCustomDevice):
"""Aqara T1 water leak sensor quirk."""

signature = {
MODELS_INFO: [("LUMI", "lumi.flood.agl02")],
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: [
BasicCluster,
XiaomiPowerConfiguration,
Identify.cluster_id,
IasZone.cluster_id,
XiaomiAqaraE1Cluster,
],
OUTPUT_CLUSTERS: [
Ota.cluster_id,
],
},
},
}

0 comments on commit 4442b2b

Please sign in to comment.