Skip to content

Z-Wave Lock: Report the result of Schlage PIN sets correctly - #3373

Open
ctowns wants to merge 3 commits into
mainfrom
zwave-lock/schlage-set-results
Open

ctowns wants to merge 3 commits into
mainfrom
zwave-lock/schlage-set-results

Conversation

@ctowns

@ctowns ctowns commented Nov 19, 2026

Copy link
Copy Markdown
Contributor

Check all that apply

Type of Change

  • WWST Certification Request
    • If this is your first time contributing code:
      • I have reviewed the README.md file
      • I have reviewed the CODE_OF_CONDUCT.md file
      • I have signed the CLA
    • I plan on entering a WWST Certification Request or have entered a request through the WWST Certification console at developer.smartthings.com
  • Bug fix
  • New feature
  • Refactor

Checklist

  • I have performed a self-review of my code
  • I have commented my code in hard-to-understand areas
  • I have verified my changes by testing with a device or have communicated a plan for testing
  • I am adding new behavior, such as adding a sub-driver, and have added and run new unit tests to cover the new behavior

Description of Change

Fixes #3365. Combines #3364 and #3366, which both edit user_code_report_handler in schlage-lock/init.lua.

On migrated Schlage locks, the UserCode Report that answers an addCredential or updateCredential Set was misread in two ways:

  • Refused PIN reported as success. Schlage refuses a PIN that is already in use. It answers with STATUS_NOT_AVAILABLE and a code of 0000, and sends no notification. The driver treated that as an occupied slot. So addCredential returned success and created a user whose PIN is not on the lock, and updateCredential returned success while the old PIN stayed.
  • Masked confirmation dropped. Some Schlage locks confirm a Set with an occupied report whose code is masked (**********). The sub-driver classed that as manufacturer-specific and dropped it. No commandResult was emitted, the credential was not recorded, and the next add reused the same slot and overwrote the PIN.

Now, while an add or update is waiting on a slot, the report for that slot is handled as follows:

Report Result
STATUS_NOT_AVAILABLE duplicate. Users and credentials are unchanged and the busy state is cleared.
ENABLED_GRANT_ACCESS (masked or clear code) Passed to the generic handler, which returns success.

Reports for other slots, and reports when no add or update is pending, are handled as before. Both checks share one helper, is_set_reported. The legacy (lockCodes) Schlage handler is unchanged.

Summary of Completed Tests

New tests in test_schlage_lock.lua:

  • addCredential / updateCredential: a STATUS_NOT_AVAILABLE report for the slot returns duplicate, and the slot stays free.
  • addCredential: a masked occupied report for the new slot confirms the add, and the next add goes to slot 2.
  • addCredential / updateCredential: a masked occupied report for another slot does not confirm the command.
  • updateCredential: a masked occupied report for the slot confirms the update.
  • addCredential: an occupied report with a blank code confirms the add (regression check).

test_schlage_lock.lua passes 8/8 and test_schlage_lock_legacy.lua passes 8/8. The full zwave-lock run has the same 17 failures as unmodified main (test_lock_code_slga_migration, test_lock_programming_code, test_zwave_responses). They come from the public lua_libs missing the programmingUser enum.

Device testing:

Co-authored with @kainpets (#3366).

🤖 Generated with Claude Code

@github-actions

Copy link
Copy Markdown

@ctowns ctowns changed the title Zwave lock/schlage set results Z-Wave Lock: Report the result of Schlage PIN sets correctly Nov 19, 2026
@github-actions

github-actions Bot commented Nov 19, 2026 •

Copy link
Copy Markdown

zwave-lock_coverage.xml

File Coverage
All files 91% ✅
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/zwave-lock/src/zwave-alarm-v1-lock/init.lua 43% ❌
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/zwave-lock/src/lazy_load_subdriver.lua 57% ❌
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/zwave-lock/src/init.lua 94% ✅
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/zwave-lock/src/legacy-handlers/samsung-lock/init.lua 94% ✅
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/zwave-lock/src/schlage-lock/init.lua 78% ❌
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/zwave-lock/src/legacy-handlers/zwave-alarm-v1-lock/init.lua 89% ❌
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/zwave-lock/src/lock_utils/utils.lua 96% ✅
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/zwave-lock/src/lock_utils/tables.lua 98% ✅
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/zwave-lock/src/legacy-handlers/schlage-lock/init.lua 95% ✅
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/zwave-lock/src/legacy-handlers/keywe-lock/init.lua 77% ❌
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/zwave-lock/src/keywe-lock/can_handle.lua 87% ❌
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/zwave-lock/src/lock_handlers/zwave_responses.lua 91% ✅
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/zwave-lock/src/lock_handlers/capabilities.lua 96% ✅
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/zwave-lock/src/samsung-lock/can_handle.lua 75% ❌

Minimum allowed coverage is 90%

Generated by 🐒 cobertura-action against 742fcf4

@github-actions

github-actions Bot commented Nov 19, 2026 •

Copy link
Copy Markdown

Test Results

   73 files    573 suites   0s ⏱️
3 491 tests 3 491 ✅ 0 💤 0 ❌
5 531 runs  5 531 ✅ 0 💤 0 ❌

Results for commit 742fcf4.

♻️ This comment has been updated with latest results.

@ctowns
ctowns force-pushed the zwave-lock/schlage-set-results branch 4 times, most recently from 993dd09 to 084d0aa Compare November 19, 2026 21:23
@ctowns
ctowns force-pushed the zwave-lock/schlage-set-results branch from 084d0aa to dfab261 Compare November 19, 2026 21:28
ctowns and others added 3 commits November 19, 2026 17:11
Schlage locks refuse a PIN that is already in use by answering the
UserCode Set with STATUS_NOT_AVAILABLE and a code of zeros, and send no
notification. The driver counted that report as a set slot, so
addCredential returned success and created a user whose PIN is not on
the lock, and updateCredential returned success while the old PIN stayed
in place.

While an add or update is waiting, a STATUS_NOT_AVAILABLE report for
that slot now returns duplicate, leaves users and credentials unchanged,
and clears the busy state. The legacy (lockCodes) Schlage handler is
unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…pending set

Some Schlage locks confirm a UserCode Set with an occupied report whose
code is masked ("**********"). On migrated locks the Schlage sub-driver
classified that report as manufacturer-specific and dropped it, so
addCredential and updateCredential never emitted a commandResult, the
credential was never recorded, and the next addCredential reused the same
slot and overwrote the PIN.

While an add or update is waiting on a slot, an occupied report for that
slot now goes to the generic handler, as a report with the code in clear
already does. Other masked reports are still consumed as before.

The pending-slot check is shared with the duplicate PIN handling
(STATUS_NOT_AVAILABLE) through is_pending_set_report.

Fixes #3365

Co-Authored-By: Pawel <41388251+kainpets@users.noreply.github.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
is_user_code_report_mfr_specific classified the same statuses that the
new pending-set checks look at, and on migrated locks only two of its
cases still did anything. Replace it with those two cases, checked
directly in user_code_report_handler:

- A report that slot 0 is available (master code changed) clears all
  credentials and users.
- A masked or missing code in an occupied report is ignored unless a
  sync is running or it is for the slot an add or update is waiting on.
  The generic handler would otherwise apply it to whatever command is
  pending, whichever slot it names.

Every other report goes to the generic handler. The legacy CODE_STATE
lookup is dropped: only the lockCodes handler writes that field, so on a
migrated lock it could only be stale and cause a clear-code report to be
ignored.

Adds tests for the master code reset, a masked report with no command
pending, and a clear-code report with no command pending.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ctowns
ctowns force-pushed the zwave-lock/schlage-set-results branch from be0275c to 742fcf4 Compare November 19, 2026 23:11
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.

zwave-lock: Schlage sub-driver drops the UserCode Report that confirms addCredential (no commandResult, slot reused)

1 participant