Repository navigation
Report the arrival sensor's battery voltage within the device tracker keepalive - #1051
Draft
zigpy-review-bot wants to merge 1 commit into
Draft
zigpy-review-bot wants to merge 1 commit into
zigpy-review-bot wants to merge 1 commit into
Conversation
The device tracker is connected only while the device was seen within the last 60 seconds, but it configured battery voltage reporting at 1-3 hours. The SmartThings tagV4 quirk meant to raise this to 45 seconds by overriding `configure_reporting`, which ZHA never calls (it configures reporting with `configure_reporting_multiple`), so the tracker showed the device away almost all the time. Configure the 45 second heartbeat in the tracker itself.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## dev #1051 +/- ##
=======================================
Coverage 97.48% 97.48%
=======================================
Files 61 61
Lines 10870 10870
=======================================
Hits 10597 10597
Misses 273 273 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Severity: medium (the audit's estimate)
The device tracker for the SmartThings arrival sensor (tagV4) treats the device as connected only when it was seen within the last 60 seconds, but it configured battery voltage reporting every one to three hours, so a tag that is home showed as away almost all of the time. The
SmartThingsTagV4quirk tries to set a 45 second report by overridingconfigure_reporting(), which ZHA never calls: it configures reporting throughconfigure_reporting_multiple(). This PR configures the 45 second battery voltage report in the tracker entity itself.Changes
DeviceScannerEntitynow asks forbattery_voltagereporting withmin_interval=45, max_interval=45, reportable_change=1(the quirk's intended values) instead of 3600/10800. The tracker only matches the0x8000device type that this quirk sets (or an endpoint a user'sdevice_configoverride turns into adevice_tracker, which needs the same heartbeat), and the cluster config aggregation merges non-override reporting configs to the tightest interval, so this config wins over the Battery sensor's for the same attribute and no other device changes.configure_reporting()override is left for zigpy/zha-device-handlers.Open items
Testing
test_device_tracker_reporting_within_keepalivejoins a device with theSmartThingsTagV4quirk and checks that the maximum battery voltage reporting interval ZHA configures is within the tracker's keepalive interval. It fails at 2da1a5b (assert 10800 <= 60) and passes with the fix.tests/test_device_tracker.py,tests/test_cluster_config.py,tests/test_sensor.pyandtests/test_discover.pypass (1277 tests), as does the full suite (1782 tests); pre-commit (codespell, ruff, mypy) passes.Opened by the scheduled code audit; not requested by a maintainer.
Fixes #1050