Skip to content

Conversation

@raman325
Copy link
Collaborator

@raman325 raman325 commented Feb 2, 2026

Summary

This PR fixes an issue with Schlage locks that have PINs with lengths other than 4 digits. The masked usercode response uses repeated characters (e.g., "**********" or "0000000000") which need to be detected regardless of length.

Breaking change

None.

Proposed change

Coordinator changes (coordinator.py)

  • Use len(set(usercode)) == 1 to detect any single-character repeated pattern for masked responses
  • Check that masked response doesn't match the actual PIN before treating as empty
  • Add break after clearing usercode to exit loop early

Z-Wave JS Provider changes (zwave_js.py)

  • Simplify the cleared usercode verification logic
  • Move debug log to else block after successful clear operation
  • Return False when verification fails to properly trigger retry logic

Style fixes

  • Convert lists to tuples in for loops (pylint R6102) in:
    • __init__.py
    • coordinator.py
    • migrate.py

Type of change

  • Bugfix (non-breaking change which fixes an issue)

Additional information

  • This PR fixes Schlage locks with non-4-digit PINs
  • Tests: 360 passed, 84.61% coverage

🤖 Generated with Claude Code

@codecov-commenter
Copy link

codecov-commenter commented Feb 2, 2026

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

❌ Patch coverage is 76.47059% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 84.57%. Comparing base (a9a30ef) to head (5b36028).
⚠️ Report is 17 commits behind head on beta.

Files with missing lines Patch % Lines
custom_components/keymaster/coordinator.py 80.00% 2 Missing ⚠️
custom_components/keymaster/migrate.py 0.00% 1 Missing ⚠️
custom_components/keymaster/providers/zwave_js.py 80.00% 1 Missing ⚠️
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.
Additional details and impacted files
@@            Coverage Diff             @@
##             beta     #558      +/-   ##
==========================================
+ Coverage   80.86%   84.57%   +3.71%     
==========================================
  Files          19       25       +6     
  Lines        2341     2730     +389     
==========================================
+ Hits         1893     2309     +416     
+ Misses        448      421      -27     
Flag Coverage Δ
python 84.57% <76.47%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds support for Yale locks which use a different masked usercode format ("0000") compared to Schlage locks ("**********"), and fixes an issue with clearing codes on Schlage locks.

Changes:

  • Added Yale masked usercode detection using len(set(usercode)) == 1 to detect any single-character repeated pattern
  • Improved Z-Wave JS provider's clear operation by moving debug log to else block and returning False on verification failure
  • Applied pylint style fixes converting lists to tuples in for loops across multiple files

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
custom_components/keymaster/providers/zwave_js.py Improved error handling in async_clear_usercode by moving debug log to else block and returning False on verification failure
custom_components/keymaster/coordinator.py Added support for Yale masked usercode format ("0000") using len(set(usercode)) == 1 check and preventing false positives by comparing with stored PIN
custom_components/keymaster/__init__.py Style fix: converted list to tuple in for loop
custom_components/keymaster/migrate.py Style fix: converted list to tuple in for loop

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@raman325 raman325 changed the title fix: support Yale locks with masked usercode responses fix: support locks with 0000 masked usercode responses Feb 2, 2026
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@raman325 raman325 changed the title fix: support locks with 0000 masked usercode responses fix: handle Schlage masked usercode responses with varying PIN lengths Feb 2, 2026
@raman325 raman325 linked an issue Feb 2, 2026 that may be closed by this pull request
@raman325 raman325 added the bugfix Fixes a bug label Feb 2, 2026
@raman325 raman325 closed this Feb 2, 2026
@raman325 raman325 deleted the yale branch February 2, 2026 06:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bugfix Fixes a bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ISSUE: Infinite Loop when Clearing Pin (Schlage Bug)

2 participants