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

Fix Nimly smart lock mains-powered capability #3457

Merged
merged 1 commit into from
Oct 26, 2024
Merged

Conversation

uvNikita
Copy link
Contributor

Proposed change

Add nimly smart lock quirk
Clears the mains powered mac capability flag since lock is battery powered.

Note that after quirk is applied, ZHA reports that my lock has 20% remaining battery, but when I query PowerConfiguration/battery_percentage_remaining attribute it reports 41%.
Not sure where ZHA gets 20% from.

See picture below:

Additional information

Tested on NimlyPro model.

Ref
#3095
#2354

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

Clears the mains powered mac capability flag since lock is battery
powered.
Copy link

codecov bot commented Oct 25, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 89.41%. Comparing base (de3643c) to head (fa05ca4).
Report is 6 commits behind head on dev.

Additional details and impacted files
@@           Coverage Diff           @@
##              dev    #3457   +/-   ##
=======================================
  Coverage   89.40%   89.41%           
=======================================
  Files         309      311    +2     
  Lines       10014    10020    +6     
=======================================
+ Hits         8953     8959    +6     
  Misses       1061     1061           

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

@uvNikita
Copy link
Contributor Author

I didn't add tests since I'm not sure how to test quirks v2, e.g. assert_signature_matches_quirk. Also not sure how to test node descriptor and power source specifically.

So it would be great with some direction on this if tests are required :)

@TheJulianJES
Copy link
Collaborator

Tests aren't really required for this. All good.

@TheJulianJES
Copy link
Collaborator

TheJulianJES commented Oct 26, 2024

when I query PowerConfiguration/battery_percentage_remaining attribute it reports 41%.
Not sure where ZHA gets 20% from.

battery_percentage_remaining goes from 0 to 200. 200 means 100%. ZHA remaps it.
Some manufacturers also miss that and use 100 for 100%, which is wrong. There's a doubling power configuration cluster which doubles that attribute value before it reaches ZHA. We can also use that if the manufacturer made the same mistake.

Copy link
Collaborator

@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.

Thanks!

@TheJulianJES TheJulianJES changed the title Add Nimly smart lock quirk Fix Nimly smart lock mains-powered capability Oct 26, 2024
@TheJulianJES TheJulianJES merged commit 263e68c into zigpy:dev Oct 26, 2024
9 checks passed
@uvNikita uvNikita deleted the nimly branch October 26, 2024 20:39
@uvNikita
Copy link
Contributor Author

Thanks for the review and the explanation about battery levels. I'll try to replace the battery and see if it will report the correct value. If not, I'll open another PR 🙂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants