10000 Keep the device firmware version in sync by puddly · Pull Request #427 · zigpy/zha · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

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

Open
wants to merge 3 commits into
base: dev
Choose a base branch
from

Conversation

puddly
Copy link
Contributor
@puddly puddly commented Apr 23, 2025

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.

image

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.

Copy link
codecov bot commented Apr 23, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 96.66%. Comparing base (1b6b5df) to head (0e240d9).

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Contributor
@TheJulianJES TheJulianJES left a 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.

Comment on lines +890 to +893
# 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
Copy link
Contributor

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.

Copy link
Contributor Author

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.

Copy link
Contributor

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.

@puddly puddly added this to ZHA Apr 28, 2025
@puddly puddly moved this to Backlog in ZHA Apr 28, 2025
@puddly puddly moved this from Backlog to In progress in ZHA Apr 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: In progress
Development

Successfully merging this pull request may close these issues.

2 participants
0