Skip to content

Hotfix Main -> Beta 11/13: Zigbee/Zwave Lock - #3352

Open
hcarter-775 wants to merge 9 commits into
betafrom
zlock-cherry-picks-to-beta
Open

hcarter-775 wants to merge 9 commits into
betafrom
zlock-cherry-picks-to-beta

Conversation

@hcarter-775

Copy link
Copy Markdown
Contributor

Description of Change

Merging recently merged Zigbee and Zwave lock changes into beta from main.

hcarter-775 and others added 9 commits November 13, 2026 13:57
…Credential/updateCredential validation (#3331)

* zigbee-lock: simplify reported and commanded credential management

Centralize how the lock's credential and user tables are updated after
a PIN is set on the lock, whether the PIN was set by a SmartThings
command or reported by the lock (sync or programming event).

addCredential
- The credential always takes the next available credential slot.
- userIndex 0 creates a new user for the credential; the user index is
  chosen when the lock confirms the code (next free user index).
- A non-zero userIndex must name an existing user, and the credential
  is attached to it. An unknown userIndex returns invalidCommand
  without contacting the lock. If that user vanishes before the lock
  confirms, it is re-added rather than failing an accepted code.
- resourceExhausted is returned up front when the credentials table is
  full, or when a new user is requested and the users table is full.

updateCredential
- Only handled when the given userIndex already owns the credentialIndex
  (otherwise invalidCommand); a credential can no longer be moved to
  another user. Only the credential name can change.

Reported credentials
- Codes reported by the lock without a command from us get a user and
  PIN credential via lock_utils.add_reported_credential.

Helpers
- lock_utils.add_credential_and_user(device, args, add_user) adds a
  credential and, when add_user is true, its user afterwards so a
  failed credential add never leaves a user behind.
- tables.next_index accepts an optional start index.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
* zigbee-lock: make credential code sync more robust

Sync the lock's PIN codes into the credentials/users tables more often
and more reliably, and recover from failures instead of stopping early.

- Start the sync from slot 0, and try it more often: on init (after a
  15s delay so NumberOfPINUsersSupported is known) and on refresh. The
  duplicate init sync in doConfigure is dropped.
- Move the sync checks into sync_device_state and continue_code_sync
  into lock_utils' sync section.
- Skip a sync while the device is busy, expiring stale busy state so a
  stalled sync can be retried, rather than clobbering a command in
  flight. Refresh waits 15s for updates to arrive.
- Persist the latest synced code index so a failed sync resumes from
  where it stopped, and ignore responses for any other index.
- Use a bump-able CODES_SYNC_VERSION: a persisted index started under a
  different version is cleared, which permits a re-sync when needed.
- Handle Default Responses during the sync. Default
  responses do not count towards the consecutive-unoccupied count that
  ends the sync.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
* Z-Wave Lock: Ensure a default pin length is set

* Z-Wave Lock: Ensure pin length bounds are set during migration
Represent the Zigbee master code pins as a programmingUser, keep it across delete-all, refuse to delete these kinds of codes, refuse to create these kinds of codes, and promote reported codes to master when the lock says so. A user cannot be changed to or from the programmingUser type via updateUser, and auto-assigned credentials start at index 1 so they never claim the master slot.

Move Yale-specific handling into its own sub-driver, which normalizes Yale's misreported user ids.

Extend the lockCodes migration to take the known master code slot (0 for Yale) and always migrate it as a programming user.

---------

Co-authored-by: Claude Sonnet 5.5 <noreply@anthropic.com>
* zwave lock: standardize management of credential and user additions/update

* zwave-lock: align credential/user management with zigbee-lock

Co-authored-by: Cooper Towns <cooper.towns@smartthings.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
…3339)

* zwave lock: make sync codes more robust, add it to refresh handling

* break apart occupied vs available as conceptually different

* zwave-lock: ignore sync reports for other code indexes

Co-authored-by: Cooper Towns <cooper.towns@smartthings.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This reverts commit 91a7498.

Conflicts with later changes (#3337, #3339, #3346) in the zwave-lock
tests were resolved by dropping the tests added by #3323 and keeping
the lock_utils require and Schlage mock device that remaining code
and tests still use.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown

@github-actions

Copy link
Copy Markdown

zigbee-lock_coverage.xml

File Coverage
All files 94% ✅
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/zigbee-lock/src/init.lua 99% ✅
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/zigbee-lock/src/configurations.lua 95% ✅
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/zigbee-lock/src/lazy_load_subdriver.lua 57% ❌
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/zigbee-lock/src/legacy-handlers/migrate.lua 98% ✅
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/zigbee-lock/src/legacy-handlers/init.lua 95% ✅
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/zigbee-lock/src/samsungsds/init.lua 89% ❌
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/zigbee-lock/src/lock_utils/tables.lua 98% ✅
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/zigbee-lock/src/lock_utils/utils.lua 97% ✅
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/zigbee-lock/src/lock_handlers/zigbee_responses.lua 86% ❌
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/zigbee-lock/src/lock_handlers/capabilities.lua 89% ❌
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/zigbee-lock/src/legacy-handlers/yale/init.lua 92% ✅

Minimum allowed coverage is 90%

Generated by 🐒 cobertura-action against c1ac8ec

@github-actions

Copy link
Copy Markdown

zwave-lock_coverage.xml

File Coverage
All files 87% ❌
/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/lock_utils/tables.lua 98% ✅
/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/zwave-alarm-v1-lock/init.lua 24% ❌
/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 51% ❌
/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/legacy-handlers/keywe-lock/init.lua 77% ❌
/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/lock_handlers/capabilities.lua 96% ✅
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/zwave-lock/src/lock_handlers/zwave_responses.lua 85% ❌
/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/samsung-lock/can_handle.lua 75% ❌

Minimum allowed coverage is 90%

Generated by 🐒 cobertura-action against c1ac8ec

@github-actions

Copy link
Copy Markdown

Test Results

   73 files    570 suites   0s ⏱️
3 404 tests 3 404 ✅ 0 💤 0 ❌
5 454 runs  5 454 ✅ 0 💤 0 ❌

Results for commit c1ac8ec.

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.

2 participants