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

Update matter-lock driver for U-tec #1812

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

HunsupJung
Copy link
Collaborator

@HunsupJung HunsupJung commented Dec 10, 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

https://smartthings.atlassian.net/browse/IOTE-4705

Summary of Completed Tests

Copy link

Duplicate profile check: Passed - no duplicate profiles detected.

Copy link

@HunsupJung HunsupJung force-pushed the update-matter-lock-for-u-tec branch from e386b18 to 3c60f45 Compare December 10, 2024 07:58
Copy link

github-actions bot commented Dec 10, 2024

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

Minimum allowed coverage is 90%

Generated by 🐒 cobertura-action against fa76eda

Copy link

github-actions bot commented Dec 10, 2024

Test Results

   64 files    403 suites   0s ⏱️
2 005 tests 2 005 ✅ 0 💤 0 ❌
3 459 runs  3 459 ✅ 0 💤 0 ❌

Results for commit fa76eda.

♻️ This comment has been updated with latest results.

@nickolas-deboom
Copy link
Contributor

nickolas-deboom commented Dec 12, 2024

After an initial review, the changes look good to me overall. I have two comments -
(1) are there additional profiles needed for the possible combinations of lock/user/pin/schedule + battery/batteryLevel? Or are we just providing profiles for known configurations at this time?

(2) Would you be able to create a few test cases similar to what I have here? https://github.com/SmartThingsCommunity/SmartThingsEdgeDrivers/pull/1796/files#diff-188bbf519a245b9967a0a86552cf7b20bef0a2b5ce6598196cca7e6591acc56d

(In order to show that the BatPercentRemaining attribute being present in the AttributeList results in the correct profile being chosen.)

@HunsupJung
Copy link
Collaborator Author

(1) are there additional profiles needed for the possible combinations of lock/user/pin/schedule + battery/batteryLevel? Or are we just providing profiles for known configurations at this time?

There may be other possible combinations. But I added lock-user-pin-batteryLevel, lock-user-pin-battery and lock-user-pin-scheduled-battery which are highly likely. For U-tec, the lock-user-pin-batteryLevel profile is enough.
Do you want to consider all edge cases?

(2) Would you be able to create a few test cases similar to what I have here?

Okay, I will update it.

@nickolas-deboom
Copy link
Contributor

(1) are there additional profiles needed for the possible combinations of lock/user/pin/schedule + battery/batteryLevel? Or are we just providing profiles for known configurations at this time?

There may be other possible combinations. But I added lock-user-pin-batteryLevel, lock-user-pin-battery and lock-user-pin-scheduled-battery which are highly likely. For U-tec, the lock-user-pin-batteryLevel profile is enough. Do you want to consider all edge cases?

(2) Would you be able to create a few test cases similar to what I have here?

Okay, I will update it.

I think it's ok to include just the likely ones for now rather than every combination.

@HunsupJung HunsupJung force-pushed the update-matter-lock-for-u-tec branch from 2d7e508 to aa47454 Compare December 20, 2024 07:52
@@ -1685,7 +1752,10 @@ local new_matter_lock_handler = {
capabilities.lock,
capabilities.lockUsers,
capabilities.lockCredentials,
capabilities.lockSchedules
capabilities.lockSchedules,
capabilities.remoteControlStatus,
Copy link
Contributor

Choose a reason for hiding this comment

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

There is no handler for remoteControlStatus, should there be or should this be removed?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I don't think it's needed. I will remove it.

end
test.set_test_init_function(test_init)

test.register_coroutine_test(
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you create a test case for the following cases also?

  1. battery percent remaining is available ✅
  2. battery charge level only is available ❌
  3. battery charge level and battery percent remaining are available ❌

You will just need to modify the attributes list in the AttributeList:build_test_report_data function you are using to test these different combinations of attributes in the new test cases.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I thought the second case was added, but it wasn't. I will modify it.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

For reference, it is impossible to support only Battery percent remaining. Because if server supports BAT feature, Battery change level is mandatory. I will create as follows.

  1. Attributes related to BAT feature is not available.
  2. battery charge level only is available.
  3. battery charge level and battery percent remaining are available.

local support_battery_percentage = false
for _, attr in ipairs(ib.data.elements) do
-- Re-profile the device if BatPercentRemaining (Attribute ID 0x0C) is present.
if attr.value == 0x0C then
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we add an explicit check for the BatChargeLevel attribute here?

if attr.value == 0x0C then
  support_battery_percentage = true
end
if attr.value == 0x0E then
    support_battery_level = true
end
------then later add this :-----------
  if support_battery_percentage then
    profile_name = profile_name .. "-battery"
  elseif support_battery_level
    profile_name = profile_name .. "-batteryLevel"
  end

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Okay, I will

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.

This looks pretty good to me! After adding the additional unit tests and making the small change in the handler, I think this will be good to go - thank you @HunsupJung !

Also, has this been regression tested with the other locks that use this driver?

@Kwang-Hui
Copy link
Contributor

I tested this PR with Aqara U200/U300 door lock - it was fine. Thank you.

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.

4 participants