Skip to content

Commit

Permalink
Convert Sinope files to new style AttributeDefs (#3342)
Browse files Browse the repository at this point in the history
  • Loading branch information
claudegel authored Sep 24, 2024
1 parent faabb74 commit e749877
Show file tree
Hide file tree
Showing 3 changed files with 574 additions and 342 deletions.
68 changes: 45 additions & 23 deletions zhaquirks/sinope/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,12 @@
Supported devices are WL4200, WL4200S and LM4110-ZB
"""

from typing import Final

import zigpy.profiles.zha as zha_p
from zigpy.quirks import CustomCluster, CustomDevice
import zigpy.types as t
from zigpy.zcl import foundation
from zigpy.zcl.clusters.general import (
AnalogInput,
Basic,
Expand All @@ -30,39 +33,58 @@
from zhaquirks.sinope import SINOPE, SINOPE_MANUFACTURER_CLUSTER_ID


class LeakStatus(t.enum8):
"""Leak_status values."""

Dry = 0x00
Leak = 0x01


class SinopeManufacturerCluster(CustomCluster):
"""SinopeManufacturerCluster manufacturer cluster."""

cluster_id = SINOPE_MANUFACTURER_CLUSTER_ID
name = "Sinopé Manufacturer specific"
ep_attribute = "sinope_manufacturer_specific"
attributes = {
0x0003: ("firmware_number", t.uint16_t, True),
0x0004: ("firmware_version", t.CharacterString, True),
0x0032: ("min_temperature_limit", t.int16s, True),
0x0033: ("max_temperature_limit", t.int16s, True),
0x0034: ("device_status", t.bitmap8, True),
0x0036: ("battery_type", t.uint16_t, True),
0x0200: ("status", t.bitmap32, True),
0xFFFD: ("cluster_revision", t.uint16_t, True),
}
cluster_id: Final[t.uint16_t] = SINOPE_MANUFACTURER_CLUSTER_ID
name: Final = "SinopeManufacturerCluster"
ep_attribute: Final = "sinope_manufacturer_specific"

class AttributeDefs(foundation.BaseAttributeDefs):
"""Sinope Manufacturer Cluster Attributes."""

firmware_number: Final = foundation.ZCLAttributeDef(
id=0x0003, type=t.uint16_t, access="r", is_manufacturer_specific=True
)
firmware_version: Final = foundation.ZCLAttributeDef(
id=0x0004, type=t.CharacterString, access="r", is_manufacturer_specific=True
)
min_temperature_limit: Final = foundation.ZCLAttributeDef(
id=0x0032, type=t.int16s, access="rw", is_manufacturer_specific=True
)
max_temperature_limit: Final = foundation.ZCLAttributeDef(
id=0x0033, type=t.int16s, access="rw", is_manufacturer_specific=True
)
device_status: Final = foundation.ZCLAttributeDef(
id=0x0034, type=t.bitmap8, access="rp", is_manufacturer_specific=True
)
battery_type: Final = foundation.ZCLAttributeDef(
id=0x0036, type=t.uint16_t, access="rw", is_manufacturer_specific=True
)
status: Final = foundation.ZCLAttributeDef(
id=0x0200, type=t.bitmap32, access="rp", is_manufacturer_specific=True
)
cluster_revision: Final = foundation.ZCL_CLUSTER_REVISION_ATTR


class SinopeTechnologiesIasZoneCluster(CustomCluster, IasZone):
"""SinopeTechnologiesIasZoneCluster custom cluster."""

class LeakStatus(t.enum8):
"""Leak_status values."""
LeakStatus: Final = LeakStatus

Dry = 0x00
Leak = 0x01
class AttributeDefs(IasZone.AttributeDefs):
"""Sinope Manufacturer IasZone Cluster Attributes."""

attributes = IasZone.attributes.copy()
attributes.update(
{
0x0030: ("leak_status", LeakStatus, True),
}
)
leak_status: Final = foundation.ZCLAttributeDef(
id=0x0030, type=LeakStatus, access="rw", is_manufacturer_specific=True
)


class SinopeTechnologiesSensor(CustomDevice):
Expand Down
Loading

0 comments on commit e749877

Please sign in to comment.