Skip to content

zwave lock: do not assume a 20-entry limit when the lock's capacity is unknown - #3395

Open
jean-losi wants to merge 1 commit into
SmartThingsCommunity:mainfrom
jean-losi:zwave-lock-unknown-capacity
Open

jean-losi wants to merge 1 commit into
SmartThingsCommunity:mainfrom
jean-losi:zwave-lock-unknown-capacity

Conversation

@jean-losi

Copy link
Copy Markdown

Check all that apply

Type of Change

  • WWST Certification Request
  • 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

After migration to lockCredentials/lockUsers, some Z-Wave locks never get pinUsersSupported / totalUsersSupported: the lock does not answer UsersNumberGet, and migrate.lua only copies lockCodes.maxCodes when the hub holds it. table_utils.get_max_entries then falls back to an arbitrary 20, so on a lock that already holds 20 or more codes:

  • every addCredential answers resourceExhausted without the command reaching the lock;
  • add_credential_and_user would also refuse to record a code the lock confirmed.

We see this in the field on Yale Z-Wave locks (fingerprints 0129-8002-0600, 0129-8109-0DD2, 0129-8004-0600) whose cloud state shows lockCodes.maxCodes: 250, holding 21–47 credentials, with both capacity attributes unset after migration. Sending refresh (which issues UsersNumberGet when they are unset) did not fill them on the lock we tried. New guest codes cannot be added to these locks at all.

This change makes is_full use the lock's reported capacity, else the lockCodes.maxCodes it reported before migration, and treat the table as not full when neither is known, so the lock itself decides whether it has room. A lock that reports its capacity is still refused once it reaches it. get_max_entries (used by the code sync) is unchanged.

Summary of Completed Tests

Run with lua5.3 against the apiv22_63 lua_libs release, all zwave-lock test files:

  • New: addCredential: sends the code to the lock past 20 entries when the lock's capacity is unknown (fails on main with resourceExhausted, passes with the fix: sends UserCode:Set for index 21 and records the confirmed credential and user).
  • New: addCredential: emits resourceExhausted when the lock's reported capacity is reached (the lock reports 20 via UsersNumberReport).
  • Updated add_entry: returns RESOURCE_EXHAUSTED when table is at max capacity and the two programming-code limit tests to report the capacity explicitly instead of relying on the implicit 20.
  • Whole driver suite: 208 passed with the fix vs 206 on main; the same 17 tests fail on main without this change, none newly failing.
  • luacheck --config .github/workflows/.luacheckrc clean on all changed files.

Not yet verified on a device with this driver build; happy to test from a channel build if that helps.

…s unknown

A migrated lock whose capacity was never read (pinUsersSupported and
totalUsersSupported unset: the lock did not answer UsersNumberGet and the
hub held no lockCodes maxCodes to copy at migration) fell back to an
arbitrary limit of 20 in is_full. A lock already holding 20 or more codes
then answered every addCredential with resourceExhausted without the
command reaching the lock, and add_credential_and_user would also drop a
code the lock confirmed. Seen on Yale Z-Wave locks (0129-8002-0600,
0129-8109-0DD2, 0129-8004-0600) reporting maxCodes 250 and holding 21-47
codes after migration.

is_full now uses the lock's reported capacity, else the lockCodes maxCodes
it reported before migration, and treats the table as not full when
neither is known, so the lock itself decides. A lock that reports its
capacity is still refused at that capacity.
@CLAassistant

CLAassistant commented Dec 5, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

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