Skip to content
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

Improve IKEA battery percentage firmware detection #2998

Merged

Conversation

TheJulianJES
Copy link
Collaborator

Proposed change

This improves the detection mechanism for IKEA firmware.

Previously, it detected versions that started with 24 or higher as new. Everything else was treated as old and doubled.
This was fine mostly. However, one IKEA remote already uses 2.4.x firmware which no longer requires doubling.
So this PR now checks the first two parts of the sw_build_id (split by .) for the firmware version.
Possible upcoming formattings of that string are treated as new too (so no doubling).

Basically, the doubling is now not applied if the firmware is 2.4.x or newer.

Additional information

Fixes #2977

Checklist

  • The changes are tested and work correctly
  • pre-commit checks pass / the code has been formatted using Black
  • Tests have been added to verify that the new code works

@TheJulianJES TheJulianJES added the bugfix This PR fixes a bug label Feb 23, 2024
Copy link

codecov bot commented Feb 23, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 87.85%. Comparing base (2a39c07) to head (344e8bc).

Additional details and impacted files
@@           Coverage Diff           @@
##              dev    #2998   +/-   ##
=======================================
  Coverage   87.85%   87.85%           
=======================================
  Files         301      301           
  Lines        9212     9217    +5     
=======================================
+ Hits         8093     8098    +5     
  Misses       1119     1119           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@TheJulianJES TheJulianJES merged commit fc1e55f into zigpy:dev Feb 23, 2024
14 checks passed
def _is_firmware_old(self):
"""Checks if firmware is old or unknown."""
def _is_firmware_new(self):
"""Checks if new firmware is installed that does not require battery doubling."""
# get sw_build_id from attribute cache if available
sw_build_id = self.endpoint.basic.get(Basic.AttributeDefs.sw_build_id.id, None)
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
sw_build_id = self.endpoint.basic.get(Basic.AttributeDefs.sw_build_id.id, None)
sw_build_id = self.endpoint.basic.get(Basic.AttributeDefs.sw_build_id.id)

For a future PR: None is already the default for zigpy clusters, so we can remove that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugfix This PR fixes a bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ZHA battery doubling on some IKEA devices still present
1 participant