fix(zwave_js): reconcile the driver value DB after User Code CC writes#1334
Conversation
Drivers before 15.25.2 (zwave-js/zwave-js#8927) never persist a supervised User Code CC write to the value database on success and never re-read the slot on failure, so cached reads -- including LCM's initial load after a restart -- serve stale slots. After each confirmed or rejected write on a User Code CC node, read the slot back through the unified API: the solicited report repairs the value database and doubles as a push through the report shim. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015tvvgVhy5F12XVyv6RQBv7 Entire-Checkpoint: 50f3161621d5
There was a problem hiding this comment.
Pull request overview
This PR extends the Z-Wave JS provider to proactively reconcile the driver’s value database after User Code CC credential writes, mitigating stale cached reads on driver versions prior to the upstream fixes. It fits into the provider’s existing “User Code CC report shim” block as an additional bridge until the minimum supported driver includes the upstream corrections.
Changes:
- Add a post-write single-slot read (
get_credential) on confirmed writes and on definitive supervised rejections to force the driver cache to converge on User Code CC nodes. - Skip reconciliation reads for optimistic writes and transient transport failures, and for successful deletes (driver already clears cached values).
- Add targeted provider tests + fixture support for
access_control.get_credential.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| custom_components/lock_code_manager/providers/zwave_js.py | Adds _async_uc_reconcile_value_db and wires it into set/delete credential paths; updates shim removal recipe. |
| tests/providers/zwave_js/conftest.py | Extends the mocked access_control to include get_credential. |
| tests/providers/zwave_js/test_provider.py | Adds test coverage for when reconciliation reads should/shouldn’t run and that failures are swallowed. |
💡 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 #1334 +/- ##
=======================================
Coverage 96.96% 96.97%
=======================================
Files 53 53
Lines 6429 6441 +12
Branches 473 473
=======================================
+ Hits 6234 6246 +12
Misses 195 195
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
The rejection call sites run inside except clauses; an unexpected exception from the read would replace the mapped typed error and derail the seam's handling. Swallow broadly like the coordinator's confirmation-read backstop: expected comms failures log at debug, unexpected exceptions log at error with traceback since the log line is the only remaining evidence of the bug. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015tvvgVhy5F12XVyv6RQBv7 Entire-Checkpoint: 7bc30d557a01
Proposed change
Follow-up to #1327, closing the remaining User Code CC gaps for users on the driver the Z-Wave JS add-on currently ships (15.25.0):
Both are fixed upstream in driver 15.25.2 (zwave-js/zwave-js#8927), which the add-on has not shipped yet.
The bridge: after each write on a User-Code-CC-advertising node,
_async_uc_reconcile_value_dbreads the written slot back viaaccess_control.get_credential— a fresh single-slot device read. On the User Code CC dispatch path the solicited report repairs the value database and doubles as a push through the #1327 report shim (confirming the write end-to-end); on a User Credential CC lock the driver dispatches natively and the read is merely redundant. The read is best-effort: a failure never changes the write outcome.Precisely scoped call sites:
OPTIMISTICset → skipped: the seam's on-demand confirmation read already hard-refreshes for every optimistic write; a single-slot read would be pure duplication.LockDisconnected) → skipped: the node is unreachable anyway.Self-sunsetting like the shim:
get_credentialis a supported API on both sides of the upstream transition — on ≥15.25.2 the read is merely redundant, and on the v16 branch (with zwave-js/zwave-js#8930) solicited reads still persist via the querying API methods. The helper lives inside the #1327 shim section and shares its removal recipe (updated in this PR), so the whole User Code CC bridge deletes as one unit once the minimum supported driver includes #8930.Cost: one extra Z-Wave round-trip per credential write (writes are rare events), none for optimistic writes or successful deletes.
Type of change
Additional information
Checklist
Full suite passes locally (1254 passed, 3 skipped);
prekclean.🤖 Generated with Claude Code
https://claude.ai/code/session_015tvvgVhy5F12XVyv6RQBv7