-
Notifications
You must be signed in to change notification settings - Fork 720
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 quirk for Sonoff ZBMINIR2 #3428
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
069a408
Add quirk for Sonoff ZBMINIR2
d779286
Rename attributes and cluster
TheJulianJES 8b43a59
Change entity names to match HA-style
TheJulianJES 6ce7cc6
Fix typo changing`pluse` to `pulse`
TheJulianJES 17aa39e
Also change cluster name in `.replaces(cluster)`
TheJulianJES 61906d2
Add translation keys to quirks v2 entities
TheJulianJES d2483b8
Fix missing commas
TheJulianJES 24bc6c7
Change enum capitalization
TheJulianJES 82b7d05
Merge branch 'dev' into dev
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,88 @@ | ||
"""Sonoff ZBMINIR2 - Zigbee Switch.""" | ||
|
||
from zigpy import types | ||
from zigpy.quirks import CustomCluster | ||
from zigpy.quirks.v2 import QuirkBuilder | ||
import zigpy.types as t | ||
from zigpy.zcl import foundation | ||
from zigpy.zcl.foundation import BaseAttributeDefs, ZCLAttributeDef | ||
|
||
|
||
class SonoffCluster(CustomCluster): | ||
"""Custom Sonoff cluster.""" | ||
|
||
cluster_id = 0xFC11 | ||
|
||
class AttributeDefs(BaseAttributeDefs): | ||
"""Attribute definitions.""" | ||
|
||
external_trigger_mode = ZCLAttributeDef( | ||
id=0x0016, | ||
type=t.uint8_t, | ||
) | ||
detach_relay = ZCLAttributeDef( | ||
id=0x0017, | ||
type=t.Bool, | ||
) | ||
turbo_mode = ZCLAttributeDef( | ||
id=0x0012, | ||
type=t.int16s, | ||
) | ||
|
||
async def _read_attributes( | ||
self, | ||
attribute_ids: list[t.uint16_t], | ||
*args, | ||
manufacturer: int | t.uint16_t | None = None, | ||
**kwargs, | ||
): | ||
"""Read attributes ZCL foundation command.""" | ||
return await super()._read_attributes( | ||
attribute_ids, | ||
*args, | ||
manufacturer=foundation.ZCLHeader.NO_MANUFACTURER_ID, | ||
**kwargs, | ||
) | ||
|
||
@property | ||
def _is_manuf_specific(self): | ||
return False | ||
|
||
|
||
class SonoffExternalSwitchTriggerType(types.enum8): | ||
"""extern switch trigger type.""" | ||
|
||
Edge_trigger = 0x00 | ||
Pulse_trigger = 0x01 | ||
Normally_off_follow_trigger = 0x02 | ||
Normally_on_follow_trigger = 0x82 | ||
|
||
|
||
( | ||
QuirkBuilder("SONOFF", "ZBMINIR2") | ||
.replaces(SonoffCluster) | ||
.enum( | ||
SonoffCluster.AttributeDefs.external_trigger_mode.name, | ||
SonoffExternalSwitchTriggerType, | ||
SonoffCluster.cluster_id, | ||
translation_key="external_trigger_mode", | ||
fallback_name="External trigger mode", | ||
TheJulianJES marked this conversation as resolved.
Show resolved
Hide resolved
|
||
) | ||
.switch( | ||
SonoffCluster.AttributeDefs.turbo_mode.name, | ||
SonoffCluster.cluster_id, | ||
off_value=9, | ||
on_value=20, | ||
translation_key="turbo_mode", | ||
fallback_name="Turbo mode", | ||
TheJulianJES marked this conversation as resolved.
Show resolved
Hide resolved
|
||
) | ||
.switch( | ||
SonoffCluster.AttributeDefs.detach_relay.name, | ||
SonoffCluster.cluster_id, | ||
off_value=0, | ||
on_value=1, | ||
translation_key="detach_relay", | ||
fallback_name="Detach relay", | ||
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.
Hmm, in the future, we should have a better solution for this, so we don't need to duplicate it across all quirks.
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.
It's possible that zigpy/zigpy#1505 can clean this up?