-
Notifications
You must be signed in to change notification settings - Fork 741
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 Philips Hue contact sensor quirk #3432
Merged
Merged
Changes from 10 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
31d5a8c
SOC001 device handler
mguaylam 901ad59
Apply pre-commit auto fixes
pre-commit-ci[bot] b993177
Merge branch 'zigpy:dev' into soc001
mguaylam a12a3e0
Convert attributes to new-style zigpy AttributeDefs.
mguaylam 5cd4857
Remove the cluster id in the replace method as it's already specified…
mguaylam e101ca0
Replace the On/Off cluster by a custom one.
mguaylam 4755292
Add fallback_name and EntityType (depends on https://github.com/zigpy…
mguaylam 6a017d6
Apply pre-commit auto fixes
pre-commit-ci[bot] d513116
Remove old remove method.
mguaylam a1c0cdd
Merge branch 'dev' into soc001
TheJulianJES 99203ef
Only implement the tamper attribute for now.
mguaylam b4fdac7
Apply pre-commit auto fixes
pre-commit-ci[bot] 1d737cd
Explicitly add `translation_key`
TheJulianJES e1e01d3
Merge branch 'dev' into soc001
TheJulianJES File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
"""Signify SOC001 device.""" | ||
|
||
from zigpy import types | ||
from zigpy.quirks import CustomCluster | ||
from zigpy.quirks.v2 import ( | ||
BinarySensorDeviceClass, | ||
ClusterType, | ||
EntityType, | ||
QuirkBuilder, | ||
) | ||
from zigpy.zcl.foundation import BaseAttributeDefs, ZCLAttributeDef | ||
|
||
|
||
class OnOff(CustomCluster): | ||
"""Custom On/Off cluster to still allow binding.""" | ||
|
||
cluster_id = 6 # 0x0006 | ||
name = "On/Off cluster" | ||
ep_attribute = "on_off_cluster" | ||
|
||
class AttributeDefs(BaseAttributeDefs): | ||
"""Attribute definitions.""" | ||
|
||
on_off = ZCLAttributeDef( | ||
id=0x0000, | ||
type=types.Bool, | ||
is_manufacturer_specific=False, | ||
) | ||
|
||
|
||
class PhilipsContactCluster(CustomCluster): | ||
"""Philips manufacturer specific cluster for contact sensor.""" | ||
|
||
cluster_id = 64518 # 0xfc06 | ||
name = "Philips contact cluster" | ||
ep_attribute = "philips_contact_cluster" | ||
|
||
class AttributeDefs(BaseAttributeDefs): | ||
"""Attribute definitions.""" | ||
|
||
contact = ZCLAttributeDef( | ||
id=0x0100, | ||
type=types.enum8, | ||
is_manufacturer_specific=True, | ||
) | ||
last_contact_change = ZCLAttributeDef( | ||
id=0x0101, | ||
type=types.uint32_t, | ||
is_manufacturer_specific=True, | ||
) | ||
tamper = ZCLAttributeDef( | ||
id=0x0102, | ||
type=types.enum8, | ||
is_manufacturer_specific=True, | ||
) | ||
last_tamper_change = ZCLAttributeDef( | ||
id=0x0103, | ||
type=types.uint32_t, | ||
is_manufacturer_specific=True, | ||
) | ||
|
||
|
||
( | ||
# <SimpleDescriptor endpoint=2 profile=260 device_type=1026 | ||
# device_version=0 | ||
# input_clusters=[0, 1, 3, 64518] | ||
# output_clusters=[0, 3, 6, 25]> | ||
QuirkBuilder("Signify Netherlands B.V.", "SOC001") | ||
.replaces( | ||
replacement_cluster_class=OnOff, | ||
cluster_id=6, # 0x0006 | ||
cluster_type=ClusterType.Client, | ||
endpoint_id=2, | ||
) | ||
.replaces(PhilipsContactCluster, endpoint_id=2) | ||
.binary_sensor( | ||
"contact", | ||
PhilipsContactCluster.cluster_id, | ||
endpoint_id=2, | ||
device_class=BinarySensorDeviceClass.OPENING, | ||
fallback_name="Contact", | ||
entity_type=EntityType.STANDARD, | ||
) | ||
.binary_sensor( | ||
"tamper", | ||
PhilipsContactCluster.cluster_id, | ||
endpoint_id=2, | ||
device_class=BinarySensorDeviceClass.TAMPER, | ||
fallback_name="Tamper", | ||
entity_type=EntityType.DIAGNOSTIC, | ||
TheJulianJES marked this conversation as resolved.
Show resolved
Hide resolved
|
||
) | ||
.add_to_registry() | ||
) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we should/can do this. We're replacing a ZCL cluster and are also changing the
ep_attribute
here.IIRC there are places where ZHA expects the
ep_attribute
to be unchanged for a standard ZCL cluster.Not subclassing
OnOff
(and itsAttributeDefs
) is also not good.