Allow accessing legacy cache attributes via cluster.get#1774
Allow accessing legacy cache attributes via cluster.get#1774
cluster.get#1774Conversation
| if key in self._legacy_cache: | ||
| return self._legacy_cache[key].value | ||
| raise | ||
| if not isinstance(key, int): |
There was a problem hiding this comment.
There is a bit of inconsistency with one existing unit test but I don't think we ever allowed persisting "legacy" attributes with string names, right?
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## dev #1774 +/- ##
==========================================
- Coverage 99.52% 99.52% -0.01%
==========================================
Files 63 63
Lines 12709 12705 -4
==========================================
- Hits 12649 12645 -4
Misses 60 60 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
I do kind of wonder: What (useful) values actually land in the So, I wonder if we should just try to keep this..? Because if we re-introduce this, even with TheJulianJES/zigpy@tjj/manufacturer_update_fix...TheJulianJES:zigpy:tjj/manufacturer_update_fix_with_mfr_attr_fix_zcl_cache (which fixes the issue of mf-specific reports with ZCL IDs landing in ZCL cache, instead of only in legacy cache), we'll then have ZHA entities use But I guess we can rethink this at a later point. The involuntary beta testing by everyone was nice to see we may not rely on this at all though. I think this should be fine, for now. I'll give it a proper look in a minute. |
|
My original idea for the legacy cache was based on the (as it turns out, mostly false) assumption that quirks frequently used patterns like It turns out practically all quirks these days actually register their virtual attributes normally and thus "bypass" the legacy cache. They use the attribute system properly, just not with attributes that really exist. I guess next release we can try to introduce some better logging for truly "legacy" attribute access patterns and then deprecate it entirely? This would really simplify the attribute cache. |
|
If nothing is really broken without this PR, let's leave things as is then. |
|
Yeah, I think the additional logging for everything that still ends up in the legacy cache now, and an eventual key/value migration sound sensible. But with #1769, I can't think of anything "really used" that would still end up in the legacy cache now.
I mean, I'm not 100% sure, but all quirks I can think of do use "fake attribute definitions" then, most on So I guess we can skip this PR for now? |
The recent attribute cache consolidation/rewrite introduced a regression: undefined attributes no longer could be accessed via
cluster.get.This PR fixes the behavior and aligns
.get()with other methods that acceptint | str | ZCLAttributeDefand updates it to correctly interface with the underlying attribute cache for the cluster.