-
Notifications
You must be signed in to change notification settings - Fork 41
Keep the device firmware version in sync #427
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
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 #427 +/- ##
==========================================
+ Coverage 96.65% 96.66% +0.01%
==========================================
Files 61 61
Lines 9922 9939 +17
==========================================
+ Hits 9590 9608 +18
+ Misses 332 331 -1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
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.
There's also a merge conflict now.
# Sync the device's firmware version with the first platform entity | ||
for (platform, _unique_id), entity in self.platform_entities.items(): | ||
if platform != Platform.UPDATE: | ||
continue |
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.
Seems a bit weird to go from entity level back up to device level for this info. We create a small (unnecessary?) dependence here.
Alternative might be for the device.firmware_version
to return the cached current_file_version
attribute (like the update entity currently does) and also have the device subscribe to current_file_version
attribute changes (instead of the update entity doing that).
Then, you would have the update entity use device.firmware_version
and have it subscribe to the DeviceUpdatedEvent
events.
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.
Good point. I was thinking of this from the opposite direction: the update entity can be overriden per-device and then provide a formatted firmware version (without the ZHA device needing to be patched). It would avoid having the device scan through clusters to determine the correct firmware version.
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 update entity can be overriden per-device and then provide a formatted firmware version (without the ZHA device needing to be patched)
Does the base ZHA device need to know the "friendly version" though? For HA, we generally use the update entity for that, right? Except for the little firmware version string in the device card/registry...
But yeah, I'm fine with this as well, so feel free to merge as-is if you want.
At some point during the library migration, devices stopped showing their installed firmware in the frontend. This PR restores this behavior in the library using entities and events, allowing for a relatively simple re-implementation of the feature in Core.
At some point, I would like to split the exposed firmware version into two values: a numeric value for comparison and a string value for display. We could then retain the generic
0xabcd1234
format for generic devices but then allow quirks to create firmware version formatters.