Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add new-matter-lock driver #1624

Merged
merged 22 commits into from
Oct 21, 2024
Merged

Add new-matter-lock driver #1624

merged 22 commits into from
Oct 21, 2024

Conversation

HunsupJung
Copy link
Collaborator

@HunsupJung HunsupJung commented Sep 9, 2024

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

Adds a new sub-driver with updates to the door lock functionality. Leverages new capabilities and some new design architecture for the Aqara door locks.

Summary of Completed Tests

Completed Testing 9/27
Completed Testing 10/18

Copy link

github-actions bot commented Sep 9, 2024

Duplicate profile check: Passed - no duplicate profiles detected.

Copy link

github-actions bot commented Sep 9, 2024

Channel deleted.

Copy link

github-actions bot commented Sep 9, 2024

Test Results

   64 files    397 suites   0s ⏱️
1 974 tests 1 974 ✅ 0 💤 0 ❌
3 409 runs  3 409 ✅ 0 💤 0 ❌

Results for commit 37709e8.

♻️ This comment has been updated with latest results.

Copy link

github-actions bot commented Sep 9, 2024

File Coverage
All files 91%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/matter-lock/src/new-matter-lock/init.lua 90%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/matter-lock/src/init.lua 92%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/matter-lock/src/lock_utils.lua 98%

Minimum allowed coverage is 90%

Generated by 🐒 cobertura-action against 37709e8

@HunsupJung HunsupJung mentioned this pull request Sep 9, 2024
12 tasks
Signed-off-by: Hunsup Jung <[email protected]>
@HunsupJung HunsupJung force-pushed the feature/new-matter-lock branch from f428f81 to b6c9c65 Compare September 10, 2024 04:49
Signed-off-by: Hunsup Jung <[email protected]>
@HunsupJung HunsupJung force-pushed the feature/new-matter-lock branch from c38540b to 41bc486 Compare September 10, 2024 12:46
Copy link
Contributor

@tpmanley tpmanley left a comment

Choose a reason for hiding this comment

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

I'm still working my way through testing this. Can you add unit tests as well?

Copy link
Contributor

@lelandblue lelandblue left a comment

Choose a reason for hiding this comment

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

Hello @HunsupJung before merging this code , please provide tested results as communicated via slack.

@HunsupJung HunsupJung force-pushed the feature/new-matter-lock branch from 53e6f2b to ef622e0 Compare September 26, 2024 11:30
@HunsupJung HunsupJung force-pushed the feature/new-matter-lock branch from 21dfec8 to 45e3606 Compare October 2, 2024 10:15
Signed-off-by: Hunsup Jung <[email protected]>
@HunsupJung HunsupJung force-pushed the feature/new-matter-lock branch from 42fa87c to 1b19d30 Compare October 2, 2024 12:38
@ctowns ctowns self-requested a review October 2, 2024 20:01
@HunsupJung
Copy link
Collaborator Author

@lelandblue @ctowns
I would like to merge this patch before the next release. I hope you can help me to meet the schedule.

@HunsupJung HunsupJung requested a review from tpmanley October 7, 2024 13:46
@ctowns
Copy link
Contributor

ctowns commented Oct 9, 2024

@HunsupJung could you add more unit tests for the new-matter-lock driver? Currently the code coverage for this driver is very low, so we should add additional test cases to increase the code coverage. You should be able to copy the test cases from the test_matter_lock_cota.lua and test_matter_lock_codes.lua files as a example, and make the necessary changes to account for the new capabilities (such as using lockAlarm instead of tamperAlert, and including the new capabilities such as `lockCredentials'). The structure should be similar to what is done in the other test files, but you will need to swap in the new capabilities. If you need additional help with this, please let me know and I can help!

@HunsupJung HunsupJung force-pushed the feature/new-matter-lock branch from 8b33ca1 to 65d52f9 Compare October 10, 2024 11:30
@HunsupJung
Copy link
Collaborator Author

@ctowns
Okay, I will update unit test for new door lock driver tomorrow.

@HunsupJung HunsupJung force-pushed the feature/new-matter-lock branch from 404cddc to 17d8148 Compare October 11, 2024 02:02
@HunsupJung HunsupJung force-pushed the feature/new-matter-lock branch from a7a6dca to 3035dbc Compare October 11, 2024 10:13
@hcarter-775
Copy link
Contributor

@lelandblue I think I added the testing you requested that's blocking the merge. Was there anything else you needed for this?

end

if device:get_field(lock_utils.SET_CREDENTIAL) ~= nil then
device.log.debug("delaying setting COTA credential since a credential is currently being set")
Copy link
Contributor

Choose a reason for hiding this comment

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

When I test with a lock that uses COTA and the initial attempt to set the COTA PIN fails with a "duplicate" error, then it gets stuck in a loop logging this message and failing to ever retry setting the COTA PIN.

end

-- Save values to field
device:set_field(lock_utils.COMMAND_NAME, cmdName, {persist = true})
Copy link
Contributor

Choose a reason for hiding this comment

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

@HunsupJung I understand how you are using these fields to save information to be used in a different function, but could you help me understand why we need to do it this way? Do the commands themselves not have the relevant information that we can use in the handler? It seems this is the case for things like the ClearUser command, but do we really need to save all of this information or can be pull some of it from the command args and ib elements?

Also, it seems like there could be issues if two commands that rely on a field like USER_INDEX are processed at the same time. For example, if one command sets USER_INDEX to 1 and then before we handle that response, another command sets USER_INDEX to 2 , the original value would be overwritten and could cause problems in handling the first command that expected USER_INDEX to be 1. Are there cases where this could happen?

Copy link
Collaborator Author

@HunsupJung HunsupJung Oct 12, 2024

Choose a reason for hiding this comment

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

Also, it seems like there could be issues if two commands that rely on a field like USER_INDEX are processed at the same time. For example, if one command sets USER_INDEX to 1 and then before we handle that response, another command sets USER_INDEX to 2 , the original value would be overwritten and could cause problems in handling the first command that expected USER_INDEX to be 1. Are there cases where this could happen?

Therefore, I used busy_state so that only one command is proceed at a time.

[DoorLock.types.DlStatus.OCCUPIED] = "occupied",
[DoorLock.types.DlStatus.INVALID_FIELD] = "invalidCommand",
[DoorLock.types.DlStatus.RESOURCE_EXHAUSTED] = "resourceExhausted",
[DoorLock.types.DlStatus.NOT_FOUND] = "failure"
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this be "notFound" instead of "failure"?

Copy link
Contributor

Choose a reason for hiding this comment

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

I guess not because "notFound" is not a valid value for the statusCode property in the capability

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, there's no notFound value for capability

@ctowns
Copy link
Contributor

ctowns commented Oct 18, 2024

Thank you for writing the new unit tests @HunsupJung ! I think this looks like it is ready to go.

One last thing - were you able to run the regression tests listed here with the new code changes? I know you have been doing a lot of testing over the past few days, so I think many of these cases have been covered but I just want to make sure the testing is good to go.

Otherwise, I think this PR is ready to go. Thank you for your hard work on this 💪 !

@HunsupJung
Copy link
Collaborator Author

@ctowns
Thank you for checking. I updated the regression tests here.
It's all thanks to the help of you and the US team.

Copy link
Contributor

@ctowns ctowns left a comment

Choose a reason for hiding this comment

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

Thank you for your hard work on this @HunsupJung !

@lelandblue lelandblue dismissed their stale review October 18, 2024 17:04

Testing results provided, team should continue to review results.

@HunsupJung HunsupJung merged commit 2f519c6 into main Oct 21, 2024
12 checks passed
@HunsupJung HunsupJung deleted the feature/new-matter-lock branch October 21, 2024 01:01
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.

8 participants