fix: use effective device_class for battery entity lookup#570
fix: use effective device_class for battery entity lookup#570tykeal merged 2 commits intoFutureTense:mainfrom
Conversation
The battery entity lookup introduced in PR FutureTense#569 used original_device_class to find battery sensors on lock devices. This only checks the integration-set device class and misses entities where the device class is resolved via user override. Use (entry.device_class or entry.original_device_class) to mirror Home Assistant's own resolution logic for the effective device class, matching both user-overridden and integration-set values. Fixes FutureTense#549 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Signed-off-by: Andrew Grimberg <tykeal@bardicgrove.org>
|
@raman325 I should have listened apparently! Found an issue while working on getting the Schlage provider built out! |
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #570 +/- ##
==========================================
+ Coverage 84.14% 84.69% +0.55%
==========================================
Files 10 25 +15
Lines 801 2751 +1950
==========================================
+ Hits 674 2330 +1656
- Misses 127 421 +294
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
This PR fixes battery sensor discovery for lock devices by using Home Assistant’s effective sensor device class resolution, ensuring battery badges appear even when the device class is set via user override.
Changes:
- Update
_find_battery_entityto match sensors using(entry.device_class or entry.original_device_class)rather than onlyoriginal_device_class.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Add test_find_battery_entity_user_overridden_device_class to verify that _find_battery_entity correctly finds battery sensors when the device_class is set via user override rather than original_device_class. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Signed-off-by: Andrew Grimberg <tykeal@bardicgrove.org>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Summary
The battery entity lookup introduced in PR #569 used
original_device_classto find battery sensors on lock devices. This only checks the integration-set device class and misses entities where the device class is resolved via user override.Fix
Use
(entry.device_class or entry.original_device_class)to mirror Home Assistant's own resolution logic for the effective device class, matching both user-overridden and integration-set values.Fixes #549