Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #983 +/- ##
==========================================
+ Coverage 86.66% 86.79% +0.12%
==========================================
Files 41 41
Lines 4590 4672 +82
Branches 467 467
==========================================
+ Hits 3978 4055 +77
- Misses 612 617 +5
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
Adds a new “lock reset” step to the Lock Code Manager config flow to detect unmanaged lock codes after lock selection and let the user clear, adopt, or cancel before proceeding.
Changes:
- Introduces
_async_get_unmanaged_codes()and new config-flow menu steps (lock_reset,lock_reset_clear,lock_reset_adopt,lock_reset_cancel). - Adds UI strings/translations for the new step and abort reason.
- Adds config flow tests covering skip/clear/adopt/cancel and masked/mixed-code scenarios.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
custom_components/lock_code_manager/config_flow.py |
Adds unmanaged-code detection + new config-flow step/menu actions for clearing/adopting/cancelling. |
custom_components/lock_code_manager/strings.json |
Adds user-facing strings for the new lock_reset step and abort reason. |
custom_components/lock_code_manager/translations/en.json |
Adds the English translations matching the new strings.json entries. |
tests/test_config_flow.py |
Adds unit tests for the new config-flow step and its menu paths. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
b3cea97 to
f986e8d
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 4 out of 4 changed files in this pull request and generated 9 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
b129277 to
b6ccd86
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 4 out of 4 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.
716e14f to
5f19a01
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
1a891c5 to
4a70183
Compare
4d4d9b7 to
94d7ff0
Compare
94d7ff0 to
385ab83
Compare
After lock selection, the config flow now checks for unmanaged codes on selected locks. If found, users are presented with options to clear all codes, adopt readable codes into Lock Code Manager, or cancel setup. Masked (SlotCode.UNKNOWN) codes can only be cleared, not adopted. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…tion - Use async_internal_get_usercodes/async_internal_clear_usercode instead of direct provider calls for rate limiting and availability checks - Add comment noting provider limitation for slot detection - Add PIN conflict detection in adopt step: first-seen PIN wins, skip conflicting values with warning log Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Entire-Checkpoint: 732e178917ee
Cover exception handling in _async_get_unmanaged_codes, missing lock instances, clear failures, PIN conflict detection, and masked slot clearing errors. Brings config_flow.py to 100% coverage. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Entire-Checkpoint: cfd76bc5ac60
- Guard _async_get_unmanaged_codes behind check to avoid re-querying locks on menu re-entry - Collapse redundant menu option branches into single has_readable check - Remove unnecessary int() cast on slot keys that are already int Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Entire-Checkpoint: f60a9b6e05e7
- Guard lock_config_entry is None before constructing provider instance - Precompute managed slots per lock instead of calling find_entry_for_lock_slot per slot (O(slots) vs O(slots × entries)) - Remove line number references from test docstrings Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Entire-Checkpoint: cde3e9143f4d
- Raise usercode fetch failure from debug to warning level - Add warning log when lock_config_entry is None - Add warning log when entity missing from registry - Add debug log for unsupported platform (expected skip) - Add warning log when lock instance missing in clear/adopt paths Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Entire-Checkpoint: 297e64ce4d52
Move lock instance creation inside the exception handler so a provider __post_init__ failure skips the lock gracefully instead of crashing the entire config flow. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Entire-Checkpoint: 8996839393c7
- Move lock instance creation inside existing exception handler so a provider __post_init__ failure skips gracefully - Update comment: Matter/Virtual provider filtering is a known issue to be fixed in a follow-up PR Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Entire-Checkpoint: 642d587af47e
PR #988 made Matter and Virtual providers return all occupied slots, so the limitation comment is no longer accurate. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Entire-Checkpoint: 333c8bb88ffd
Filters out both UNKNOWN and EMPTY sentinel values rather than checking only for UNKNOWN. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Entire-Checkpoint: f9f550f1f44d
When the same slot appears on multiple locks with the same PIN, keep the first-seen entry intact instead of overwriting it with identical defaults. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Entire-Checkpoint: 4ad72cad860a
The lock reset step currently only runs during initial setup. Extend it to the options flow when new locks are added, with merge-based adopt that preserves existing slot config. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Entire-Checkpoint: 9d57f2b4c257
Replace guard-clause-with-continue pattern with an inner function that raises LockCodeManagerError on skip conditions. The outer loop catches expected skips (LockCodeManagerError) and unexpected failures (Exception) separately. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Entire-Checkpoint: 2c7783140f9d
Move inner function to module level with explicit parameters. Rename to _async_check_existing_usercodes to distinguish from provider get_usercodes operations. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Entire-Checkpoint: 10d0912a53d7
- Replace inline managed_slots comprehension with get_managed_slots from data.py (matches PR #989 pattern) - Extract _clear_slots helper to deduplicate the per-lock slot clearing loop used in both lock_reset_clear and lock_reset_adopt Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Entire-Checkpoint: 76009cde6ae0
385ab83 to
61b03a4
Compare
Proposed change
After lock selection in the config flow, check for existing unmanaged codes on the selected locks. If found, show a menu step where users can:
If no unmanaged codes are found, the step is silently skipped.
Implementation details
_async_check_existing_usercodes()— top-level function that validates lock entity, creates temporary provider instance, and queries usercodes. RaisesLockCodeManagerErrorfor expected skip conditions. Reusable for future options flow integration._async_get_unmanaged_codes()— iterates locks, calls the above, filters to unmanaged non-empty slots usingget_managed_slots()helper._clear_slots()— shared helper for clearing slots with per-lock/per-slot error handling, used by both clear and adopt steps.isinstance(code, SlotCode)check.Known limitations
Type of change
Additional information
🤖 Generated with Claude Code