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

raman325 and others added 3 commits February 2, 2026 00:00
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>
Copilot AI review requested due to automatic review settings February 2, 2026 06:40
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 fixes handling of Schlage lock masked usercode responses for PINs with varying lengths (not just 4 digits). The main issue was that the code used isdigit() checks which failed to detect masked responses that consisted of repeated characters of any length.

Changes:

  • Improved masked usercode detection using len(set(usercode)) == 1 to identify any single-character repeated pattern
  • Enhanced verification logic for cleared usercodes to handle varying PIN lengths
  • Style improvements: converted lists to tuples in for loops (pylint R6102 compliance)

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
custom_components/keymaster/coordinator.py Enhanced masked usercode detection logic to use set-based checking for any single-character pattern; added loop to check multiple mask characters with early exit
custom_components/keymaster/providers/zwave_js.py Refactored cleared usercode verification to use dynamic length checking; moved debug log to else block for better flow; added return False for verification failures
custom_components/keymaster/migrate.py Style fix: converted list to tuple in for loop
custom_components/keymaster/init.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: Copilot <175728472+Copilot@users.noreply.github.com>
@codecov-commenter
Copy link

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

Codecov Report

❌ Patch coverage is 77.77778% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 84.58%. Comparing base (a9a30ef) to head (8a3d7f5).
⚠️ 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 83.33% 1 Missing ⚠️
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.
Additional details and impacted files
@@            Coverage Diff             @@
##             beta     #559      +/-   ##
==========================================
+ Coverage   80.86%   84.58%   +3.72%     
==========================================
  Files          19       25       +6     
  Lines        2341     2731     +390     
==========================================
+ Hits         1893     2310     +417     
+ Misses        448      421      -27     
Flag Coverage Δ
python 84.58% <77.77%> (?)

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants