Add LocalDataCluster._DEFAULT_VALUES#4771
Draft
TheJulianJES wants to merge 2 commits intozigpy:devfrom
Draft
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## dev #4771 +/- ##
==========================================
- Coverage 92.32% 92.29% -0.03%
==========================================
Files 371 371
Lines 12190 12191 +1
==========================================
- Hits 11254 11252 -2
- Misses 936 939 +3 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
4 tasks
TheJulianJES
commented
Feb 19, 2026
Comment on lines
702
to
708
| # Previously, this cluster was wrongly setting the total_active_power attribute, | ||
| # which was not added to HA. | ||
| # Since it is now added to HA and the incorrect value could be set, we need to | ||
| # reset it. | ||
| self._update_attribute( | ||
| ElectricalMeasurement.AttributeDefs.total_active_power.id, None | ||
| ) |
Collaborator
Author
There was a problem hiding this comment.
We'll need to look into this as well (to clear an attribute). Or maybe have an _UNSUPPORTED_ATTRIBUTES constant in LocalDataCluster and/or CustomCluster as well? It would also help for some Tuya quirks...
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Proposed change
This adds a
_DEFAULT_VALUESdict toLocalDataCluster, similar to_CONSTANT_ATTRIBUTES.This allows quirks using
LocalDataClusterto set default values that can be overridden, unlike_CONSTANT_ATTRIBUTES.TODO: Tests
Additional information
There are multiple issues with the current pattern of checking
attrid not in self._attr_cacheand then usingupdate_attribute:update_attributecall essentially did nothing. Appdb loading: https://github.com/zigpy/zigpy/blob/70d15a5dde9adc28c230261d4ac32b7309075415/zigpy/appdb.py#L701-L724Cluster.__init__usingupdate_attribute.There's an issue though: The Aqara feeder implementation also uses default values, but it's not a
LocalDataCluster. That should be converted and/or we should consider moving this into zigpy'sCustomCluster, where the_CONSTANT_ATTRIBUTESalso (partly) live already.In the future, we can also look at making
_CONSTANT_ATTRIBUTES,_VALID_ATTRIBUTES, and_DEFAULT_VALUES(only) compatible withZCLAttributeDefand/or name, instead of just IDs.I'd do that in a separate PR though and keep the implementations consistent for now.
Checklist
pre-commitchecks pass / the code has been formatted using Black