-
Notifications
You must be signed in to change notification settings - Fork 831
Add Sonoff SNZB-03P motion sensor #3979
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
Open
panther7
wants to merge
1
commit into
zigpy:dev
Choose a base branch
from
panther7:3188
base: dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+61
−0
Open
Changes from all commits
Commits
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 hidden or 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,61 @@ | ||
"""Sonoff SNZB-03P - Zigbee motion sensor.""" | ||
|
||
from zigpy.quirks import CustomCluster | ||
from zigpy.quirks.v2 import EntityPlatform, EntityType, NumberDeviceClass, QuirkBuilder | ||
from zigpy.quirks.v2.homeassistant import UnitOfTime | ||
import zigpy.types as t | ||
from zigpy.zcl.clusters.measurement import OccupancySensing | ||
from zigpy.zcl.clusters.security import IasZone | ||
from zigpy.zcl.foundation import BaseAttributeDefs, ZCLAttributeDef, ZCLHeader | ||
|
||
|
||
class LastIlluminationState(t.enum8): | ||
"""Last measureed state of illumination enum.""" | ||
|
||
Dark = 0x00 | ||
Light = 0x01 | ||
|
||
|
||
class SonoffIlluminationCluster(CustomCluster): | ||
"""Custom Sonoff illumination cluster.""" | ||
|
||
cluster_id = 0xFC11 | ||
manufacturer_id_override: t.uint16_t = ZCLHeader.NO_MANUFACTURER_ID | ||
|
||
class AttributeDefs(BaseAttributeDefs): | ||
"""Attribute definitions.""" | ||
|
||
last_illumination_state = ZCLAttributeDef( | ||
id=0x2001, | ||
type=LastIlluminationState, | ||
access="rp", | ||
is_manufacturer_specific=True, | ||
) | ||
|
||
|
||
( | ||
QuirkBuilder("eWeLink", "SNZB-03P") | ||
.replaces(SonoffIlluminationCluster) | ||
.removes(IasZone.cluster_id) # IasZone cluster 0x0500: remove motion detection | ||
.number( | ||
OccupancySensing.AttributeDefs.ultrasonic_o_to_u_delay.name, | ||
panther7 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
OccupancySensing.cluster_id, | ||
min_value=5, | ||
max_value=60, | ||
step=1, | ||
unit=UnitOfTime.SECONDS, | ||
device_class=NumberDeviceClass.DURATION, | ||
translation_key="motion_timeout", | ||
fallback_name="Presence detection timeout", | ||
) | ||
.enum( | ||
SonoffIlluminationCluster.AttributeDefs.last_illumination_state.name, | ||
LastIlluminationState, | ||
SonoffIlluminationCluster.cluster_id, | ||
entity_platform=EntityPlatform.SENSOR, | ||
entity_type=EntityType.STANDARD, | ||
translation_key="last_illumination_state", | ||
fallback_name="Last illumination state", | ||
) | ||
.add_to_registry() | ||
) |
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.