Skip to content

Matter lock: Update embedded cluster definitions and drop alias uses - #3388

Open
hcarter-775 wants to merge 4 commits into
mainfrom
matter-lock/update-embedded-cluster
Open

hcarter-775 wants to merge 4 commits into
mainfrom
matter-lock/update-embedded-cluster

Conversation

@hcarter-775

Copy link
Copy Markdown
Contributor

Description of Change

Older hubs are crashing in matter-lock with:

Referenced unknown attribute AliroReaderVerificationKey on cluster DoorLock

Hub Lua libraries didn't get the Aliro DoorLock attributes until api 11 (v11_hc0.54.x); the api-10 libraries (v10_hc0.53.x) don't have them. The driver only used its embedded DoorLock cluster when version.api < 10, so api-10 hubs fell back to their own DoorLock definition and errored on the first Aliro attribute lookup during subscribe.

Changes:

  • Version check: use the embedded DoorLock cluster when version.api < 11 (was < 10), in init.lua and lock_sync.lua.
  • Regenerated embedded DoorLock from the current scripting-engine codegen:
    • adds definitions that were previously listed in the cluster maps but had no file, including AliroSupportedBLEUWBProtocolVersions (which the driver subscribes to) and UnboltDoor
    • picks up recent codegen fixes (nil-safe elements, SetCredential.credential_data as OctetString2)
  • Canonical type names: the driver used Matter 1.2 alias names (DlAlarmCode, DlCredentialType, DoorLockFeature.PIN_CREDENTIALS, ...), which only resolve through the hub's alias tables. Without aliases in the embedded cluster, those would fail on api < 11, so they are replaced with the canonical names (AlarmCodeEnum, CredentialTypeEnum, Feature.PIN_CREDENTIAL, ...). Values are unchanged.
  • api-9 battery fix: handle_battery_charge_level uses PowerSource.types.BatChargeLevel on api < 10, where BatChargeLevelEnum doesn't exist.
  • Tests: apply the same embedded DoorLock swap for api < 11 and use the canonical type names.

Summary of Completed Tests

  • All 188 matter-lock unit tests pass against current (api 22) lua_libs.
  • With the regenerated embedded cluster, all 188 tests also pass when forced to version.api = 10, so they exercise the embedded DoorLock path end to end, including the Aliro tests.
  • Ran against the published api-9 (0.52) lua_libs: tests load and run, but most fail on test-harness lifecycle differences (api 9 subscribes on added/doConfigure rather than init), not on driver errors.

hcarter-775 and others added 3 commits December 1, 2026 13:37
- Swap in the embedded `DoorLock` cluster for api < 11, matching driver
- Use canonical type names instead of Matter 1.2 aliases
- Select `BatChargeLevel` vs `BatChargeLevelEnum` by api version

Co-Authored-By: Claude <claude@anthropic.com>
- Regenerate from current codegen without `lazy_require`
- Keep only attributes, commands, events and types the driver uses
- Add missing Aliro attribute and `UnboltDoor` definitions
- Strip comments and alias support

Co-Authored-By: Claude <claude@anthropic.com>
- Hub libs before api 11 lack Aliro attributes, crashing on
  `AliroReaderVerificationKey` lookups; use embedded cluster instead
- Replace alias type names with canonical names available everywhere
- Handle `BatChargeLevel` naming on api 9 hubs

Co-Authored-By: Claude <claude@anthropic.com>
@github-actions

github-actions Bot commented Dec 1, 2026

Copy link
Copy Markdown

@github-actions

github-actions Bot commented Dec 1, 2026 •

Copy link
Copy Markdown

matter-lock_coverage.xml

File Coverage
All files 91% ✅
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/matter-lock/src/lazy_load_subdriver.lua 57% ❌
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/matter-lock/src/lock_sync.lua 97% ✅
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/matter-lock/src/init.lua 90% ✅
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/matter-lock/src/lock_utils.lua 89% ❌
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/matter-lock/src/unmigrated-matter-lock/init.lua 92% ✅

Minimum allowed coverage is 90%

Generated by 🐒 cobertura-action against 3487f02

@github-actions

github-actions Bot commented Dec 1, 2026 •

Copy link
Copy Markdown

Test Results

   73 files    584 suites   0s ⏱️
3 552 tests 3 552 ✅ 0 💤 0 ❌
5 613 runs  5 613 ✅ 0 💤 0 ❌

Results for commit 3487f02.

♻️ This comment has been updated with latest results.

@cjswedes
cjswedes removed their request for review December 2, 2026 17:42

@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.

Overall the changes make sense to me, and the refactor is clean and matches what we have in the scripting-engine.

I also confirmed that the only aliases for the DoorLock cluster are from renames during the 1.2, so there wouldn't be any intermediate hub versions that would need their aliases account for, so using the most up to date names as you have done here should be good!

Just a couple questions:
What is the scale of this issue, as in how many hubs are experiencing this crash? I don't think we've seen it called out in our monitoring at all. It looks like this is something that would have been crashing for older hubs (<53) since v54 was released if I am understanding correctly, since that AliroReaderVerificationKey field wasn't added to the lua libs until the 54 release, so I am just trying to get a better idea of the scale of this issue.

Also, is there a plan to test this against a real device? I'm not sure if we can even backport a hub that far without running into issues, so real device testing might be difficult.

)

local DlAlarmCode = clusters.DoorLock.types.DlAlarmCode
local DlAlarmCode = clusters.DoorLock.types.AlarmCodeEnum

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.

nit

Suggested change
local DlAlarmCode = clusters.DoorLock.types.AlarmCodeEnum
local AlarmCodeEnum = clusters.DoorLock.types.AlarmCodeEnum

This is in drivers/SmartThings/matter-lock/src/test/test_matter_lock.lua as well, so update there too

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thanks! 3487f02

@hcarter-775

hcarter-775 commented Dec 4, 2026 •

Copy link
Copy Markdown
Contributor Author

@ctowns , scale is low, but I see it whenever I monitor the Matter Lock driver. It is a longstanding issue that likely affects only a handful of devices, since the version it affects is so far back.

Given that the version is so far back for the gates to take effect, I did not plan to test this on-device- I just expected to see that the crashes stopped on these older FW hubs. It is really only a pathing issue anyway.

Match the embedded cluster type name per review feedback.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
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