fix(akuvox): handle X916 user filtering where source_type is None#584
fix(akuvox): handle X916 user filtering where source_type is None#584tykeal merged 2 commits intoFutureTense:mainfrom
Conversation
The X916 firmware does not populate source_type for any users. Instead
it uses user_type to distinguish local ("-1") from cloud ("0") users.
The A08S and E18C models use source_type "1" (local) / "2" (cloud).
Replace the inline source_type check with a _is_local_user() helper
that handles both firmware patterns:
- source_type present: check == "1"
- source_type absent/None: fall back to user_type == "-1"
Co-authored-by: Copilot <copilot@github.com>
Signed-off-by: Andrew Grimberg <tykeal@bardicgrove.org>
There was a problem hiding this comment.
Pull request overview
Fixes Akuvox user filtering so X916 devices (which return source_type=None) no longer have all users incorrectly excluded, restoring proper usercode CRUD behavior in the provider.
Changes:
- Add
_is_local_user()helper to classify local vs cloud users across multiple Akuvox firmware patterns. - Replace inline
source_typechecks in all CRUD paths with_is_local_user(). - Extend the test suite with X916-pattern cases for filtering and CRUD flows.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
custom_components/keymaster/providers/akuvox.py |
Introduces _is_local_user() and uses it throughout user filtering logic. |
tests/providers/test_akuvox.py |
Adds unit/integration tests for X916/local-user classification and CRUD behavior. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #584 +/- ##
==========================================
+ Coverage 84.14% 88.44% +4.29%
==========================================
Files 10 26 +16
Lines 801 3141 +2340
==========================================
+ Hits 674 2778 +2104
- Misses 127 363 +236
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:
|
The edit that added test_get_code_skips_x916_cloud_users accidentally swallowed the function definition of test_get_code_empty_pin, merging its body into the X916 test. Restore it as a separate test function. Co-authored-by: Copilot <copilot@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.
Problem
The Akuvox provider filters local vs cloud users by checking
source_type == "1". This works for A08S and E18C models, but the X916 firmware does not populatesource_typeat all (returnsNonefor all users). This causes the provider to skip every user on X916 devices, breaking user code management entirely.Observed symptoms on X916:
async_get_usercodes()returns empty listasync_set_usercode()always callsadd_userinstead ofmodify_user, causingFAILEDerrors when a user already existsasync_clear_usercode()silently does nothingSolution
Replace the inline
source_typecheck with a_is_local_user()helper that handles both firmware patterns:source_type="1"source_type="2"source_type=None, user_type="-1"source_type=None, user_type="0"Logic:
source_typeis present (not None): check== "1"source_typeis None/absent: fall back touser_type == "-1"Testing
_is_local_user()covering all branchesakuvox.pyVerified against real hardware
Tested against three device models:
source_type="1"for local users ✅source_type="1"/"2"for local/cloud ✅source_type=None,user_type="-1"/"0"✅