Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Sonoff SNZB-04P device support with custom clusters #3665

Open
wants to merge 3 commits into
base: dev
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 64 additions & 0 deletions zhaquirks/sonoff/snzb04p.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
"""Sonoff SNZB-04 device."""

from zigpy import types
from zigpy.quirks import CustomCluster
from zigpy.quirks.v2 import (
BinarySensorDeviceClass,
ClusterType,
EntityType,
QuirkBuilder,
)
from zigpy.zcl.clusters.general import OnOff
from zigpy.zcl.foundation import BaseAttributeDefs, ZCLAttributeDef


class SonoffOnOffCluster(CustomCluster, OnOff):
"""Sonoff OnOff cluster for contact sensor."""

"""Prevents the creation of the on_off entity since it is not functional."""

cluster_id = 6 # 0x0006
name = "Sonoff OnOff cluster"
ep_attribute = "sonoff_onoff_cluster"
SKIP_CONFIGURATION = True


class SonoffContactCluster(CustomCluster):
"""Sonoff manufacturer specific cluster for contact sensor."""

cluster_id = 64529 # 0xfc11
name = "Sonoff contact cluster"
ep_attribute = "sonoff_contact_cluster"

class AttributeDefs(BaseAttributeDefs):
"""Attribute definitions."""

tamper = ZCLAttributeDef(
id=0x2000,
type=types.Bool,
is_manufacturer_specific=True,
)


(
# <SimpleDescriptor endpoint=1 profile=260 device_type=1026
# device_version=0
# input_clusters=[0, 1, 3, 32, 1280, 64529, 64567]
# output_clusters=[3, 6, 25]>
QuirkBuilder("eWeLink", "SNZB-04P")
.replaces(
SonoffOnOffCluster,
cluster_type=ClusterType.Client,
endpoint_id=1,
)
.replaces(SonoffContactCluster, endpoint_id=1)
.binary_sensor(
"tamper",
SonoffContactCluster.cluster_id,
endpoint_id=1,
device_class=BinarySensorDeviceClass.TAMPER,
entity_type=EntityType.DIAGNOSTIC,
fallback_name="Tamper",
)
.add_to_registry()
)
Loading