-
Notifications
You must be signed in to change notification settings - Fork 31
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
Support configuration of entity reporting for V2 quirks #254
base: dev
Are you sure you want to change the base?
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## dev #254 +/- ##
=======================================
Coverage 96.50% 96.50%
=======================================
Files 61 61
Lines 9431 9439 +8
=======================================
+ Hits 9101 9109 +8
Misses 330 330 ☔ View full report in Codecov by Sentry. |
needs a rebase |
208b149
to
cb75788
Compare
@dmulcahey I've just force pushed a rebase. The tests will continue to fail however, as this patch has dependeny on the zigpy PR, so this will require a further rebase once that merges. |
My bad.. sorry for the unnecessary ping!! |
cb75788
to
b9267d7
Compare
I've just rebased against zigpy dependency update. All tests should now be passing. |
|
||
cluster_handler.__dict__[zha_const.REPORT_CONFIG] = reporting_config | ||
|
||
endpoint.claim_cluster_handlers([cluster_handler]) |
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.
Just noting (for myself) that claiming a cluster handler is what also makes ZHA configure and bind the cluster.
), | ||
) | ||
|
||
cluster_handler.__dict__[zha_const.REPORT_CONFIG] = reporting_config |
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.
The attributes are also added to ZCL_INIT_ATTRS
above this new code block.
If I'm looking at this correctly, we'll have them in both REPORT_CONFIG
and ZCL_INIT_ATTRS
and then have duplicates in uncached
?
zha/zha/zigbee/cluster_handlers/__init__.py
Lines 458 to 460 in 11cf9ba
cached = [a for a, cached in self.ZCL_INIT_ATTRS.items() if cached] | |
uncached = [a for a, cached in self.ZCL_INIT_ATTRS.items() if not cached] | |
uncached.extend([cfg["attr"] for cfg in self.REPORT_CONFIG]) |
We might want to move the new block before the ZCL_INIT_ATTRS
block and then check in the ZCL_INIT_ATTRS
block that they're not already in REPORT_CONFIG
OR just remove them from ZCL_INIT_ATTRS
in this line?
Hi. Thanks for coming up with a proper solution for the problem of the Ikea VINDSTYRKA sensor's VOC index not being updated. I want to say that this patch, together with my quirk (ikruglov/zha-device-handlers@c49d8e1), works well. I now have a properly updating VOC Index without workarounds, such as manually reading values. I'd be happy to submit the PR for the quirk, but I thought you may already have one. So, I'll keep it to myself, meanwhile. Thanks again. |
Note: this requires zigpy export for exposing this via V2 quirk API.
If both ZCL_INIT_ATTRS and REPORT_CONFIG contain the same attribute, with the current cluster logic, you end up in a situation where said attribute is marked as both cacheable and uncacheable at the same time, leading to it being configured twice. As they are designed to be mutually exclusive of each other, let's add the logic to remove attributes from ZCL_INIT_ATTRS if they are already present in REPORT_CONFIG. REPORT_CONFIG will take precedence over ZCL_INIT_ATTRS.
b9267d7
to
69f6242
Compare
Many thanks for reviewing this and catching the cacheablity issue - and apologies for my delay in getting back to you on this PR. I've gone ahead and with the "just remove them from ZCL_INIT_ATTRS in this line" option, as arguably this is really a latent issue that is already possible to expose via old cluster API. I think the intention is for REPORT_CONFIG and ZCL_INIT_ATTRS to be mutually exclusive of each other anyway. @ikruglov no worries. It certainly would be good to get that quirk in soon as I know it has been around in code review in various forms for a very long time now. Please do go ahead and submit your PR (I wasn't planning to myself). |
Proposed change
This change hooks up the V2 Quirk
report_config
option to the cluster handler created for V2 quirks. It also 'claims' the cluster, which is required for reporting and binding hooks to work upon configuration of the cluster and previously wasn't being done for V2 Quirk clusters.Additional information
Please refer to zigpy/zigpy#1490 for more information on the motivation behind this patch. This patch will need to be merged after that has been merged and zigpy dependency has been bumped.