-
Notifications
You must be signed in to change notification settings - Fork 748
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 support for QUAD-ZIG-SW from smarthjemmet.dk #3400
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## dev #3400 +/- ##
==========================================
+ Coverage 90.91% 90.92% +0.01%
==========================================
Files 325 326 +1
Lines 10566 10584 +18
==========================================
+ Hits 9606 9624 +18
Misses 960 960 ☔ View full report in Codecov by Sentry. |
All should be fixed now. Sorry for all the commits. |
@TheJulianJES I see that a new release was created yesterday, and mine was not included. Any idea why? The only checks failing are code coverage, which shouldn't prevent it from being merged. Was really hoping to get this quirk implemented in the next release, as I'm guessing I have to wait a few more weeks now. |
There's a few things on this PR that I'd likely change. I just haven't found the time to properly review this PR and comment all small change suggestions. I still plan to do that, of course, but there are also other PRs. |
Follows the style of other quirks where there's proper quirk defined in a `CustomDevice` class that's inherited from in other quirks that just change the `signature`, but keep the `replacement` and device triggers.
Ok, so I've pushed multiple commits now. The "refactor" commit changes the structure of the (so-called v1) quirk to have a The last commit (as of now) "Replace with v2 quirk" completely replaces the
Please test if that v2 quirk works as expected. With the v1 quirk before, the If the replacement .removes(MultistateInput.cluster_id, cluster_type=ClusterType.Client, endpoint_id=1) # remove output cluster
.adds(CustomMultistateInputCluster, endpoint_id=1) # default cluster_type is server, so it'll add an input cluster |
The test here is no longer really needed for the v2 quirk. There's no real point in testing if all the correct clusters are included. Ideally, we would send messages from the device and see if they are converted to "ZHA events" as expected in a test.
zhaquirks/smarthjemmet/quadzigsw.py
Outdated
async def bind(self): | ||
"""Prevent bind.""" | ||
return zigpy.zcl.foundation.Status.SUCCESS | ||
|
||
async def unbind(self): | ||
"""Prevent unbind.""" | ||
return zigpy.zcl.foundation.Status.SUCCESS | ||
|
||
async def _configure_reporting(self, *args, **kwargs): | ||
"""Prevent remote configure reporting.""" | ||
return ( | ||
zigpy.zcl.foundation.ConfigureReportingResponse.deserialize(b"\x00")[0], | ||
) |
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.
Unrelated to converting the whole quirk to a v2 quirk:
Are these necessary? We already set SKIP_CONFIGURATION = True
.
@TheJulianJES Hi and thanks for your effort. Unfortunately it's not working. When I am talking about V1 and V2 in terms of firmware, it's because I have one physical device with two different firmware versions. The signature of the devices are completely different, which is why I need to be able to support both signatures on the same device. V1 of the firmware came out back in 2023, and now I've updated it in late 2024. Does that make sense? For all I care, Quirk V1 or Quirk V2 doesn't matter to me. Quirk V2 looks better with the QuirkBuilder - definitely, but unfortunately it's not working as intended in this case. Regards to your "It was also missing on endpoint 1 in the replacement. I don't think that was intentional" it actually was. The physical device has 5 buttons, but only 4 of them should work as MultistateInput. The last is used for resetting the device, which is done on a firmware level. |
And for good measure, here's the old firmware (firmware V1 from 2023)'s device signature:
and here is the new firmware V2 (from late 2024) device signature:
|
@TheJulianJES Help is not really wanted. What I originally had worked perfectly. Only thing not passing is the code coverage. Is that a requirement to get it merged? |
"Help wanted" just means this needs to be looked again. A v2 quirk should work. |
Okay I see. Is it for you to look at "at some point" as a reminder? Or someone else? My question really is, do I need to take action? |
I'll take another look again at this soon. In the mean time, you can try to see if you can make the v2 quirk work if you want.
On which HA version did you test the v2 quirk? Did you test it by replacing the whole quirks library or just inserting the one quirks file as a "custom quirk" (using the ZHA config option) (recommended for testing this). |
@TheJulianJES I am doing the custom quirk with the ZHA config option. It was matched to the signature of one of the devices I tested (the old V1 firmware), but no events were shown when I pressed the buttons. Also, I appreciate the help. Let me know if there is anything I can do. |
zhaquirks/smarthjemmet/quadzigsw.py
Outdated
event_args = {VALUE: value} | ||
self.listener_event(ZHA_SEND_EVENT, action, event_args) | ||
|
||
super()._update_attribute(0, action) |
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.
If the changes work, please also try and see what these additional changes to this line do:
- replacing 0 with
MultistateInput.AttributeDefs.present_value.id
in this line (sensor entity in HA?) - completely removing this line
I believe this was copied from other quirks where it doesn't actually work, as there is no attribute with id=0
on this cluster.
Works like a charm … great work so far even though it’s only a custom quirk. I hope you guys get it integrated into the standard ZHA soon |
Please also test the v2 quirk now. It was updated a few days ago. |
@mortenmoulder can confirm your quirk works with just a model name change for MULTI-ZIG-SW as well! Great job. I'll try to find time to test out @TheJulianJES changes later. |
Any news here on the current version in this PR? |
See my previous comment. Works like a charm with ZHA if you install it as a quirk. |
It would also be ideal to know if the updated v2 quirk version works correctly now. Then, we'd be able to finally merge this (after I add some tests). |
@mortenmoulder would this quirk also work for MULTI-ZIG-SW? |
trying to get the latest version of this quirk to work with MULTI-ZIG-SW it doesnt work, and i get the following in the HA logs:
this is on HA 2024.12.2 |
okay - some more feedback. the current quirk (latest version on this PR) does not actually for me on the sister device MULTI-ZIG-SW, but it is recognised if i add two lines. The first is line 28
and its usage on line 58/59
meaning it will show up as "MULTI-ZIG-SW by smarthjemmet.dk" and show Nothing happens when pushing any of the buttons though. |
with this patch the quadzigsw.py quirk works for me on a MULTI_ZIG_SW: --- quadzigsw-orig.py 2025-02-01 06:26:31.211611131 +0100
+++ quadzigsw.py 2025-02-01 06:27:26.903118134 +0100
@@ -25,6 +25,7 @@
MANUFACTURER = "smarthjemmet.dk"
MODEL_ID = "QUAD-ZIG-SW"
+MODEL_ALT_ID = "MULTI-ZIG-SW"
ACTION_TYPE = {
0: COMMAND_RELEASE,
@@ -43,20 +44,19 @@
class CustomMultistateInputCluster(CustomCluster, MultistateInput):
- """Multistate input cluster."""
+ """CustomMultistate input cluster."""
def _update_attribute(self, attrid, value):
super()._update_attribute(attrid, value)
if attrid == MultistateInput.AttributeDefs.present_value.id:
- if action := ACTION_TYPE.get(value) is not None:
+ if (action := ACTION_TYPE.get(value)) is not None:
event_args = {VALUE: value}
self.listener_event(ZHA_SEND_EVENT, action, event_args)
- super()._update_attribute(0, action)
-
(
QuirkBuilder(MANUFACTURER, MODEL_ID)
+ .applies_to(MANUFACTURER, MODEL_ALT_ID)
.skip_configuration()
.replaces(CR2032PowerConfigurationCluster)
.removes(MultistateInput.cluster_id, cluster_type=ClusterType.Client, endpoint_id=2) |
@bangert Thanks! The issue with the walrus operator was an oversight on my part. I'll merge these changes and add tests for this device soon, then we can finally merge this quirk. |
@TheJulianJES i have re-tested the latest version on a MULTI-ZIG-SW v1 firmware: it still works. @mortenmoulder @OptionHenrik could you test with QUAD-ZIG-SW and/or v2 firmware? |
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.
Thanks!
Proposed change
Add support for smarthjemmet.dk's QUAD-ZIG-SW device.
Additional information
Works with V1 and V2 firmware.
Checklist
pre-commit
checks pass / the code has been formatted using Black