Skip to content

Conversation

nickolas-deboom
Copy link
Contributor

@nickolas-deboom nickolas-deboom commented Oct 1, 2024

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

CHAD-13993

This change adds support for devices that contain both switch and button endpoints. The button driver was initially merged into the driver in PR 1547, but until now only pure-button and pure-switch devices were supported.

The first switch endpoint and all button endpoints will join as a multi-component device, and additional switch endpoints will join as child devices.

The GE/Cync dimmer/keypad is an example of a device that is supported by this change.

Summary of Completed Tests

See new unit tests and also here for an overview of testing. Additional regression testing is documented here.

This change adds support for devices containing both switch and button
endpoints.
This change adds support for devices containing both switch and button
endpoints.
…m:SmartThingsCommunity/SmartThingsEdgeDrivers into support-combination-switch-button-devices
2-button-battery-switch.yml was created during the initial work of this
PR, when different configurations for combo button/switch devices were
being tested, but should be removed now.
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.

Just a reminder to rebase as well so that the latest changes are present and so that unit tests can run :)

* Sort endpoints before returning the default endpoint
* Add comment on why the main endpoint should be a button endpoint if
  one exists
Copy link

github-actions bot commented Oct 2, 2024

Channel deleted.

Copy link

github-actions bot commented Oct 2, 2024

Test Results

   64 files    401 suites   0s ⏱️
1 999 tests 1 999 ✅ 0 💤 0 ❌
3 439 runs  3 439 ✅ 0 💤 0 ❌

Results for commit d14d457.

♻️ This comment has been updated with latest results.

Copy link

github-actions bot commented Oct 2, 2024

File Coverage
All files 94%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/matter-switch/src/init.lua 96%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/matter-switch/src/eve-energy/init.lua 91%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/matter-switch/src/aqara-cube/init.lua 96%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/matter-switch/src/embedded-cluster-utils.lua 38%

Minimum allowed coverage is 90%

Generated by 🐒 cobertura-action against d14d457

@nickolas-deboom
Copy link
Contributor Author

Just a reminder to rebase as well so that the latest changes are present and so that unit tests can run :)

Done!

* remove the component argument from find_default_endpoint
* remove checks for button and switch endpoints in initialize_switch as
  they are not necessary
@ctowns
Copy link
Contributor

ctowns commented Oct 3, 2024

One thing we will want to do before merging these changes is complete a set of regression tests for the various device types that share this driver since we are touching a critical code path. I think you could potentially add the test cases to the great confluence page you already put together, listing which cases are covered by unit tests and real devices, or both: https://smartthings.atlassian.net/wiki/spaces/~7120201ec2fa4a1b0548dd86df78b89d08422e/pages/3449815291/Supporting+Combination+Button+Switch+Devices#Testing.

Let's think of some device compositions that are commonly used and also add in some that might be corner cases. For example:

  1. Single switch device (bulb, plug, etc.)
  2. Single button device
  3. Multi-switch only device
  4. Multi-button only device
  5. Switch/Button combo device with a single switch and multiple buttons
  6. Switch/Button combo with a multiple switches and a single button
  7. Switch/Button combo with multiple switches and multiple buttons
  8. Switch/Button combo with multiple switches and multiple buttons where the switch has lower endpoints than the buttons

A good chunk of these are already covered by existing unit tests and the ones you have added, I just wanted to list all the ones I could think of to be complete. Where we can, we should do smoke testing with real devices in addition to the unit tests. Some of these will be impossible to test with real devices (test 8 for example, I'm not sure we have a real device like that), so they can be covered by a unit test case (which it looks like you've already done for test 8). If you can think of any more edge cases, please add them!

@nickolas-deboom
Copy link
Contributor Author

One thing we will want to do before merging these changes is complete a set of regression tests for the various device types that share this driver since we are touching a critical code path. I think you could potentially add the test cases to the great confluence page you already put together, listing which cases are covered by unit tests and real devices, or both: https://smartthings.atlassian.net/wiki/spaces/~7120201ec2fa4a1b0548dd86df78b89d08422e/pages/3449815291/Supporting+Combination+Button+Switch+Devices#Testing.

Let's think of some device compositions that are commonly used and also add in some that might be corner cases. For example:

1. Single switch device (bulb, plug, etc.)

2. Single button device

3. Multi-switch only device

4. Multi-button only device

5. Switch/Button combo device with a single switch and multiple buttons

6. Switch/Button combo with a multiple switches and a single button

7. Switch/Button combo with multiple switches and multiple buttons

8. Switch/Button combo with multiple switches and multiple buttons where the switch has lower endpoints than the buttons

A good chunk of these are already covered by existing unit tests and the ones you have added, I just wanted to list all the ones I could think of to be complete. Where we can, we should do smoke testing with real devices in addition to the unit tests. Some of these will be impossible to test with real devices (test 8 for example, I'm not sure we have a real device like that), so they can be covered by a unit test case (which it looks like you've already done for test 8). If you can think of any more edge cases, please add them!

Good point! I added section Test coverage for other device compositions to the confluence page. I created a table with the endpoint configurations you listed and linked to the test case files that cover each configuration. I tested out a few cases with physical devices I have, and I also expanded test_matter_multi_button_child_switch.lua to include test cases to cover cases 5, 7, and 8. Please let me know if you think there is anything else I should add!

@nickolas-deboom nickolas-deboom force-pushed the support-combination-switch-button-devices branch from c5f1348 to c5a9b6f Compare October 29, 2024 18:59
@nickolas-deboom nickolas-deboom force-pushed the support-combination-switch-button-devices branch from 96e3191 to 926b8b4 Compare November 11, 2024 16:21
@ctowns
Copy link
Contributor

ctowns commented Nov 11, 2024

I think this confluence page needs to be updated with the latest screenshots with the new component layout: Test coverage for other device compositions

I would also note on that page what switch/button combos are supported, and what expected behavior is for an unsupported combination device.

Also, I think another round of device regression testing might be good to verify the latest changes with the new layout. Fortunately, a lot of this is covered with unit tests, so good job on that test coverage!

@nickolas-deboom nickolas-deboom force-pushed the support-combination-switch-button-devices branch from bdc0c0b to 174d2da Compare November 11, 2024 20:00
@nickolas-deboom nickolas-deboom force-pushed the support-combination-switch-button-devices branch from 174d2da to 25cf9d3 Compare November 11, 2024 20:07
@nickolas-deboom
Copy link
Contributor Author

nickolas-deboom commented Nov 11, 2024

I think this confluence page needs to be updated with the latest screenshots with the new component layout: Test coverage for other device compositions

I would also note on that page what switch/button combos are supported, and what expected behavior is for an unsupported combination device.

Also, I think another round of device regression testing might be good to verify the latest changes with the new layout. Fortunately, a lot of this is covered with unit tests, so good job on that test coverage!

I updated the confluence page with new details about testing, for both the Inovelli and the GE/Cync device. I added some notes on what the behavior would be for unsupported device types as well in the Testing section.

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.

Few minor comments but otherwise looks good to me. Need to make sure to do a thorough regression test with devices that would use the affected code paths.

@nickolas-deboom
Copy link
Contributor Author

nickolas-deboom commented Nov 13, 2024

Few minor comments but otherwise looks good to me. Need to make sure to do a thorough regression test with devices that would use the affected code paths.

I did regression testing on all of the devices listed on this page, which includes lights, plugs, and buttons as well as the GE/Cync and Inovelli switch/button combo devices. I also created unit tests to verify the functionality for a device that would join a MCD profile containing switch and button components as well as a device that has button endpoints and a switch endpoint that would not be supported by a MCD profile and uses parent-child for the switch endpoint instead.

@nickolas-deboom nickolas-deboom merged commit 33f44ec into main Nov 14, 2024
12 checks passed
@nickolas-deboom nickolas-deboom deleted the support-combination-switch-button-devices branch November 14, 2024 15:35
@nickolas-deboom nickolas-deboom mentioned this pull request Jan 15, 2025
12 tasks
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.

5 participants