Skip to content

Conversation

@seojune79
Copy link
Contributor

@seojune79 seojune79 commented Jan 16, 2026

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

Summary of Completed Tests

@github-actions
Copy link

github-actions bot commented Jan 16, 2026

Test Results

   71 files    480 suites   0s ⏱️
2 488 tests 2 488 ✅ 0 💤 0 ❌
4 271 runs  4 271 ✅ 0 💤 0 ❌

Results for commit eaad1cd.

♻️ This comment has been updated with latest results.

@github-actions
Copy link

github-actions bot commented Jan 16, 2026

File Coverage
All files 55%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/Aqara/aqara-lock/src/init.lua 53%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/Aqara/aqara-lock/src/credential_utils.lua 60%

Minimum allowed coverage is 90%

Generated by 🐒 cobertura-action against eaad1cd

@kdbang
Copy link
Collaborator

kdbang commented Jan 19, 2026

linter fail

Checking drivers/Aqara/aqara-lock/src/credential_utils.lua 1 warning

    drivers/Aqara/aqara-lock/src/credential_utils.lua:99:1: (W611) line contains only whitespace

@seojune79
Copy link
Contributor Author

linter fail

Checking drivers/Aqara/aqara-lock/src/credential_utils.lua 1 warning

    drivers/Aqara/aqara-lock/src/credential_utils.lua:99:1: (W611) line contains only whitespace

I have removed the whitespace.

local HOST_COUNT = "__host_count"
local PERSIST_DATA = "__persist_area"

credential_utils.attrCopy = function(table)
Copy link
Contributor

Choose a reason for hiding this comment

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

I believe this is an unnecessary function. utils.deep_copy is already doing this recursively for the whole table.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you for your feedback. I have revised the implementation to manage data at the table unit level now.

local credentialInfoTable = device:get_field(PERSIST_DATA)
if credentialInfoTable ~= nil then
device:emit_event(lockCredentialInfo.credentialInfo(credentialInfoTable, { visibility = { displayed = false } }))
end
Copy link
Contributor

Choose a reason for hiding this comment

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

Should there be an else clause where we call backup_data in the case that there is nothing persisted? I think this will help ensure existing devices have the state for this capability persisted.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Could you please elaborate on this part a bit more? Are you suggesting that adding a check for backup_data would be beneficial if capability information could be deleted during normal use? I'd appreciate further explanation to ensure my understanding is correct.

Copy link
Contributor

Choose a reason for hiding this comment

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

This sync function is called on device_init. Devices out there right now, do not have PERSIST_DATA set on the device object yet. We want any device that does not yet have this persisted, to have it persisted as soon as we detect that it hasnt been persisted. So my suggestion is, if table is nil, then we should read the current state and persist it in the driver datastore with credential_utils.backup_data. If we do not detect and persist in the device_init handler, then we are waiting for a capability command to come in that will cause the persistence, which may or may not happen before a hub failover.

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.

3 participants