Skip to content

Commit

Permalink
Merge branch 'release/0.0.93'
Browse files Browse the repository at this point in the history
  • Loading branch information
dmulcahey committed Feb 22, 2023
2 parents b9bf8f6 + 00d128e commit cab324b
Show file tree
Hide file tree
Showing 30 changed files with 703 additions and 790 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ repos:
- pydocstyle==6.1.1

- repo: https://github.com/PyCQA/isort
rev: 5.10.1
rev: 5.12.0
hooks:
- id: isort

Expand Down
2 changes: 1 addition & 1 deletion requirements_test_all.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ pytest-sugar
pytest-timeout
pytest-asyncio
pytest>=7.1.3
zigpy>=0.52
zigpy>=0.53
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from setuptools import find_packages, setup

VERSION = "0.0.92"
VERSION = "0.0.93"


setup(
Expand All @@ -20,6 +20,6 @@
keywords="zha quirks homeassistant hass",
packages=find_packages(exclude=["tests"]),
python_requires=">=3.8",
install_requires=["zigpy>=0.52"],
install_requires=["zigpy>=0.53"],
tests_require=["pytest"],
)
12 changes: 6 additions & 6 deletions tests/test_tuya.py
Original file line number Diff line number Diff line change
Expand Up @@ -276,12 +276,12 @@ def test_ts0121_signature(assert_signature_matches_quirk):

async def test_tuya_data_conversion():
"""Test tuya conversion from Data to ztype and reverse."""
assert Data([4, 0, 0, 1, 39]).to_value(t.uint32_t) == 295
assert Data([4, 0, 0, 0, 220]).to_value(t.uint32_t) == 220
assert Data([4, 255, 255, 255, 236]).to_value(t.int32s) == -20
assert Data.from_value(t.uint32_t(295)) == [4, 0, 0, 1, 39]
assert Data.from_value(t.uint32_t(220)) == [4, 0, 0, 0, 220]
assert Data.from_value(t.int32s(-20)) == [4, 255, 255, 255, 236]
assert t.uint32_t(Data([4, 0, 0, 1, 39])) == 295
assert t.uint32_t(Data([4, 0, 0, 0, 220])) == 220
assert t.int32s(Data([4, 255, 255, 255, 236])) == -20
assert Data(t.uint32_t(295)) == [4, 0, 0, 1, 39]
assert Data(t.uint32_t(220)) == [4, 0, 0, 0, 220]
assert Data(t.int32s(-20)) == [4, 255, 255, 255, 236]


class TuyaTestManufCluster(TuyaManufClusterAttributes):
Expand Down
17 changes: 15 additions & 2 deletions tests/test_tuya_clusters.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
TUYA_GET_DATA,
TUYA_SET_DATA_RESPONSE,
TUYA_SET_TIME,
BigEndianInt16,
TuyaCommand,
TuyaData,
TuyaDatapointData,
Expand All @@ -33,7 +32,7 @@ def test_tuya_data_raw():

class Test(t.Struct):
test_bool: t.Bool
test_uint16_t_be: BigEndianInt16
test_uint16_t_be: t.uint16_t_be

data = b"\x00\x00\x03\x01\x02\x46"
extra = b"extra data"
Expand Down Expand Up @@ -66,6 +65,20 @@ def test_tuya_data_value():
assert r.raw == b"\x00\x00\x02\x46"


def test_tuya_negative_value():
"""Test tuya negative "Value" datatype."""

data = b"\x02\x00\x04\xff\xff\xff\xf8"
extra = b"extra data"

r, rest = TuyaData.deserialize(data + extra)
assert rest == extra

assert r.dp_type == 2
assert r.raw == b"\xff\xff\xff\xf8"
assert r.payload == -8


def test_tuya_data_bool():
"""Test tuya Bool datatype."""

Expand Down
4 changes: 2 additions & 2 deletions tests/test_xbee.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ async def test_receive_serial_data(zigpy_device_from_quirk):
67,
None,
b"2\x00\x02\x01\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfeTP",
b"\x01TP\x00\x18",
b"\x01TP\x00\x00\x18",
"tp_command_response",
24,
),
Expand All @@ -208,7 +208,7 @@ async def test_receive_serial_data(zigpy_device_from_quirk):
67,
None,
b"2\x00\x02\x01\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfeTP",
b"\x01TP\x00\xfc",
b"\x01TP\x00\xff\xfc",
"tp_command_response",
-4,
),
Expand Down
81 changes: 68 additions & 13 deletions zhaquirks/heiman/smoke.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
"""Smoke Sensor."""

import zigpy.profiles.zha
from zigpy.profiles import zha
from zigpy.quirks import CustomDevice
from zigpy.zcl.clusters.general import Alarms, Basic, Identify, Ota, PowerConfiguration
from zigpy.zcl.clusters.homeautomation import Diagnostic
from zigpy.zcl.clusters.security import IasWd, IasZone
import zigpy.zdo.types

Expand Down Expand Up @@ -30,8 +31,8 @@ class HeimanSmokYDLV10(CustomDevice):
MODELS_INFO: [(HEIMAN, "SMOK_YDLV10")],
ENDPOINTS: {
1: {
PROFILE_ID: zigpy.profiles.zha.PROFILE_ID,
DEVICE_TYPE: zigpy.profiles.zha.DeviceType.IAS_ZONE,
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.IAS_ZONE,
INPUT_CLUSTERS: [
Basic.cluster_id,
PowerConfiguration.cluster_id,
Expand All @@ -53,8 +54,8 @@ class HeimanSmokYDLV10(CustomDevice):
),
ENDPOINTS: {
1: {
PROFILE_ID: zigpy.profiles.zha.PROFILE_ID,
DEVICE_TYPE: zigpy.profiles.zha.DeviceType.IAS_ZONE,
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.IAS_ZONE,
INPUT_CLUSTERS: [
Basic.cluster_id,
PowerConfiguration.cluster_id,
Expand Down Expand Up @@ -89,8 +90,8 @@ class HeimanSmokCO_V15(CustomDevice):
# "in_clusters": ["0x0000","0x0001","0x0003","0x0009","0x0500"],
# "out_clusters": ["0x0019"]
1: {
PROFILE_ID: zigpy.profiles.zha.PROFILE_ID,
DEVICE_TYPE: zigpy.profiles.zha.DeviceType.IAS_ZONE,
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.IAS_ZONE,
INPUT_CLUSTERS: [
Basic.cluster_id,
PowerConfiguration.cluster_id,
Expand All @@ -111,8 +112,8 @@ class HeimanSmokCO_V15(CustomDevice):
),
ENDPOINTS: {
1: {
PROFILE_ID: zigpy.profiles.zha.PROFILE_ID,
DEVICE_TYPE: zigpy.profiles.zha.DeviceType.IAS_ZONE,
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.IAS_ZONE,
INPUT_CLUSTERS: [
Basic.cluster_id,
PowerConfiguration.cluster_id,
Expand All @@ -139,8 +140,8 @@ class HeimanSmokCO_CTPG(CustomDevice):
# "device_type": "0x0402",
# "in_clusters": ["0x0000","0x0001","0x0003","0x0009","0x0500"]
# "out_clusters": ["0x0019"]
PROFILE_ID: zigpy.profiles.zha.PROFILE_ID,
DEVICE_TYPE: zigpy.profiles.zha.DeviceType.IAS_ZONE,
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.IAS_ZONE,
INPUT_CLUSTERS: [
Basic.cluster_id,
PowerConfiguration.cluster_id,
Expand Down Expand Up @@ -173,8 +174,8 @@ class HeimanSmokCO_CTPG(CustomDevice):
),
ENDPOINTS: {
1: {
PROFILE_ID: zigpy.profiles.zha.PROFILE_ID,
DEVICE_TYPE: zigpy.profiles.zha.DeviceType.IAS_ZONE,
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.IAS_ZONE,
INPUT_CLUSTERS: [
Basic.cluster_id,
PowerConfiguration.cluster_id,
Expand All @@ -188,3 +189,57 @@ class HeimanSmokCO_CTPG(CustomDevice):
},
},
}


class HeimanSmokeN30(CustomDevice):
"""SmokeN30 quirk."""

# NodeDescriptor(
# logical_type=<LogicalType.EndDevice: 2>, complex_descriptor_available=0, user_descriptor_available=0, reserved=0, aps_flags=0,
# frequency_band=<FrequencyBand.Freq2400MHz: 8>, mac_capability_flags=<MACCapabilityFlags.AllocateAddress: 128>,
# manufacturer_code=4619, maximum_buffer_size=127, maximum_incoming_transfer_size=100, server_mask=11264, maximum_outgoing_transfer_size=100,
# descriptor_capability_field=<DescriptorCapability.NONE: 0>,
# *allocate_address=True, *is_alternate_pan_coordinator=False, *is_coordinator=False, *is_end_device=True, *is_full_function_device=False,
# *is_mains_powered=False, *is_receiver_on_when_idle=False, *is_router=False, *is_security_capable=False)
signature = {
MODELS_INFO: [("HEIMAN", "SmokeSensor-N-3.0")],
ENDPOINTS: {
# "profile_id": 260,"device_type": "0x0402",
# "in_clusters": ["0x0000","0x0001","0x0003","0x0500","0x0502","0x0b05"],
# "out_clusters": ["0x0019"]
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,
IasWd.cluster_id,
Diagnostic.cluster_id,
],
OUTPUT_CLUSTERS: [
Ota.cluster_id,
],
},
},
}

replacement = {
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,
Diagnostic.cluster_id,
],
OUTPUT_CLUSTERS: [
Ota.cluster_id,
],
},
},
}
Loading

0 comments on commit cab324b

Please sign in to comment.