fix(zwave_js): tolerate transient SetValueResult statuses on UC writes (#1251)#1256
Merged
Merged
Conversation
#1251) 3.x routed UC set/clear through ``zwave_js.set_lock_usercode`` / ``zwave_js.clear_lock_usercode``, which never inspected ``SetValueResult.status``. Flaky-interview Schlage UC v1 locks that respond with ``FAIL`` intermittently were silently tolerated; the optimistic push + next sync tick converged the slot. The 4.x rewrite added a strict status check that escalated any non-OK status to ``CodeRejectedError`` / ``LockOperationFailed``, which disabled the slot on the first transient ``FAIL`` -- exactly TheMegamind's symptom of "code slots won't stay enabled" after the #1252 fallback shipped. Split the status set in two: - ``_UC_SET_VALUE_FATAL`` (NO_DEVICE_SUPPORT, ENDPOINT_NOT_FOUND, NOT_IMPLEMENTED, INVALID_VALUE): structural impossibilities, still raise loudly because retrying cannot recover. - Everything not in OK and not in FATAL (canonically ``FAIL``): log at INFO and let the optimistic push + sync tick converge, matching 3.x tolerance. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> Entire-Checkpoint: 62765cba5358
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1256 +/- ##
=======================================
Coverage 97.11% 97.11%
=======================================
Files 54 54
Lines 6411 6416 +5
Branches 461 461
=======================================
+ Hits 6226 6231 +5
Misses 185 185
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 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.
Proposed change
Match the 3.x tolerance for non-OK `SetValueResult` statuses on User Code CC writes.
3.x routed sets/clears through HA's `zwave_js.set_lock_usercode` / `clear_lock_usercode` services. I just re-read that service in current HA (`homeassistant/components/zwave_js/lock.py:132`): it calls `set_usercode` and never inspects `SetValueResult.status` — anything short of a Z-Wave transport error is treated as success. So a flaky Schlage UC v1 lock that responded `FAIL` intermittently was silently tolerated; the optimistic push and the next sync tick converged the slot.
The 4.x rewrite (PR #1252) added a strict status check that escalates any status outside `(SUCCESS, SUCCESS_UNSUPERVISED, WORKING)` to `CodeRejectedError` / `LockOperationFailed`. That's the regression behind TheMegamind's "code slots won't stay enabled" symptom — the first transient `FAIL` from a flaky lock disabled the slot.
Split the status set in two:
This restores 3.x behavior for the flaky-lock population while keeping the loud-failure surface for genuinely unrecoverable cases.
Type of change
Additional information
Checklist
Tests:
🤖 Generated with Claude Code