Skip to content

Zwave lock: add explicit mins and migration validation - #3313

Open
hcarter-775 wants to merge 3 commits into
mainfrom
add/zwave-lock-explicit-mins-and-validation
Open

hcarter-775 wants to merge 3 commits into
mainfrom
add/zwave-lock-explicit-mins-and-validation

Conversation

@hcarter-775

@hcarter-775 hcarter-775 commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

Description of Change

Add explicit minimums to add greater clarity to the Zwave Lock table handling. Also, add explicit validation of Zwave codes during migration to ensure that only valid codes are moved (no indices allowed for 0, which is a special catch-all sentinal in Zwave), and that all codes are given a valid userIndex (>=1).

Summary of Completed Tests

Unit tests updated. Migration of device with a handful of valid lock codes tested on-device.

hcarter-775 and others added 2 commits October 28, 2026 12:59
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Drop legacy lockCodes slots that are not valid credential indices (such
as 0, which means "all users" in Z-Wave) when migrating to
lockUsers/lockCredentials. Remaining users are numbered sequentially
from 1.

Add tables.get_minimum to read a table's minimum index, and tests for
deleting credentials whose user or credential index maps to no entry.

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

Copy link
Copy Markdown

@github-actions

github-actions Bot commented Oct 28, 2026 •

Copy link
Copy Markdown

zwave-lock_coverage.xml

File Coverage
All files 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/zwave-alarm-v1-lock/init.lua 24% ❌
/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/lazy_load_subdriver.lua 57% ❌
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/zwave-lock/src/init.lua 93% ✅
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/zwave-lock/src/schlage-lock/can_handle.lua 75% ❌
/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/zwave-alarm-v1-lock/init.lua 89% ❌
/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/lock_handlers/capabilities.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 88% ❌
/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/samsung-lock/can_handle.lua 75% ❌

Minimum allowed coverage is 90%

Generated by 🐒 cobertura-action against 06b7443

@github-actions

github-actions Bot commented Oct 28, 2026 •

Copy link
Copy Markdown

Test Results

   73 files    545 suites   0s ⏱️
3 317 tests 3 317 ✅ 0 💤 0 ❌
5 317 runs  5 317 ✅ 0 💤 0 ❌

Results for commit 06b7443.

♻️ This comment has been updated with latest results.

Comment thread drivers/SmartThings/zwave-lock/src/legacy-handlers/init.lua Outdated
Comment thread drivers/SmartThings/zwave-lock/src/legacy-handlers/init.lua
Comment thread drivers/SmartThings/zwave-lock/src/lock_utils/tables.lua Outdated
@hcarter-775 hcarter-775 added the CGAI Contains code that was generated by AI label Oct 28, 2026

@cbaumler cbaumler left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM!

@ctowns ctowns left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM! Just one comment that could be a follow up if needed

max_entries = capabilities.lockCredentials.pinUsersSupported,
-- Z-Wave User Identifiers are a sequence starting at 1; 0 is reserved to mean "all users".
-- This differs from the lockCredentials capability, which allows a credentialIndex of 0.
minimum = 1,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Credential index is valid at the capability level as you mentioned, so we could potentially still get an addCredential command with index 0 - should we add this minumum check in the addCredential handling as well?

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

Labels

AIReview CGAI Contains code that was generated by AI

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants