-
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 initial Sonoff smart water valve quirk #3346
Merged
Merged
Changes from 4 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
c670179
Add Sonoff SWV quirk
fgsch a102926
Merge branch 'dev' into add-swv
TheJulianJES 6f2d01d
Add translation key and fallback name
TheJulianJES e65c834
Apply pre-commit auto fixes
pre-commit-ci[bot] 21b4001
Remove enum sensor for initial PR
TheJulianJES b75c3bd
Merge branch 'dev' into add-swv
TheJulianJES b2f7eec
Apply pre-commit auto fixes
pre-commit-ci[bot] 0438e95
Try skipping formatting for v2 quirk def
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,49 @@ | ||
"""Sonoff SWV - Zigbee smart water valve.""" | ||
|
||
from zigpy.quirks import CustomCluster | ||
from zigpy.quirks.v2 import EntityPlatform, EntityType, QuirkBuilder | ||
import zigpy.types as t | ||
from zigpy.zcl.foundation import BaseAttributeDefs, ZCLAttributeDef | ||
|
||
|
||
class ValveState(t.enum8): | ||
"""Water valve state.""" | ||
|
||
Normal = 0 | ||
Water_Shortage = 1 | ||
Water_Leakage = 2 | ||
Water_Shortage_And_Leakage = 3 | ||
|
||
|
||
class EwelinkCluster(CustomCluster): | ||
"""Ewelink specific cluster.""" | ||
|
||
cluster_id = 0xFC11 | ||
|
||
class AttributeDefs(BaseAttributeDefs): | ||
"""Attribute definitions.""" | ||
|
||
water_valve_state = ZCLAttributeDef( | ||
id=0x500C, | ||
type=ValveState, | ||
) | ||
|
||
@property | ||
def _is_manuf_specific(self): | ||
return False | ||
|
||
|
||
( | ||
QuirkBuilder("SONOFF", "SWV") | ||
.replaces(EwelinkCluster) | ||
.enum( | ||
EwelinkCluster.AttributeDefs.water_valve_state.name, | ||
ValveState, | ||
EwelinkCluster.cluster_id, | ||
entity_platform=EntityPlatform.SENSOR, | ||
entity_type=EntityType.DIAGNOSTIC, | ||
TheJulianJES marked this conversation as resolved.
Show resolved
Hide resolved
|
||
translation_key="water_valve_state", | ||
fallback_name="Water valve state", | ||
) | ||
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.
Would two separate binary sensors make more sense for this? (instead of an enum sensor)
We can't really parse it this via v2 quirks (yet), so just wondering.
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 would vote for 2 binary sensors. This would make it more convenient for triggers and alerts.
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.
zigpy/zha#305 and zigpy/zha#303 would be required for this.
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.
@TheJulianJES what about the approach in #3340 to have 2 binary sensors?
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 would work, but we're creating "fake" attributes there, which isn't optimal.
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.
@TheJulianJES While the work is being decided, can we get this without the enum so at least people can fiddle with the attributes directly using e.g. zha toolkit?
Or you reckon zigpy/zha#305 and zigpy/zha#303 would be handled relatively soon?
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.
Let's temporarily remove the quirks v2 enum sensor then. We should be able to get the quirk in the HA Core 2024.12 beta for tomorrow then.
Not sure on the timeline of the "attribute converters" yet. I hope we can get to it soon, but no promises.
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.
Awesome, thank you!