Skip to content

Matter Switch move button and switch initialization to doConfigure #2041

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

Merged
merged 1 commit into from
May 13, 2025

Conversation

nickolas-deboom
Copy link
Contributor

@nickolas-deboom nickolas-deboom commented Apr 1, 2025

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

This change moves the initialization logic for buttons and switches to do_configure. This consolidates all of the profile selection logic to be within doConfigure and allows the removal of logic gates from device_init that were there to ensure init code only ran one time.

Also added is a new function that runs at init that can rename or delete persisted fields on the device. The original __component_to_endpoint_map field can now be utilized by buttons and other devices because initialize_buttons_and_switches is ensured to only run one time, meaning that old MCD switch devices will not be affected. Also, the __switch_intialized field can now be deleted from devices.

Summary of Completed Tests

Tested with various matter buttons and lights to ensure no change in behavior.

Copy link

github-actions bot commented Apr 1, 2025

Channel deleted.

Copy link

github-actions bot commented Apr 1, 2025

Test Results

   66 files  +   66    426 suites  +426   0s ⏱️ ±0s
2 185 tests +2 185  2 185 ✅ +2 185  0 💤 ±0  0 ❌ ±0 
3 733 runs  +3 733  3 733 ✅ +3 733  0 💤 ±0  0 ❌ ±0 

Results for commit ea1236c. ± Comparison against base commit 40b6262.

♻️ This comment has been updated with latest results.

Copy link

github-actions bot commented Apr 1, 2025

File Coverage
All files 92%
/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/eve-energy/init.lua 92%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/matter-switch/src/init.lua 92%
/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 ea1236c

@nickolas-deboom nickolas-deboom force-pushed the matter-switch-update-field-names branch from 951333e to d2843e6 Compare April 1, 2025 19:51
@hcarter-775
Copy link
Contributor

I found this line: -- The resulting endpoint to component map is saved in the COMPONENT_TO_ENDPOINT_MAP_BUTTON field
Can you update it to the correct field name?

@nickolas-deboom
Copy link
Contributor Author

I found this line: -- The resulting endpoint to component map is saved in the COMPONENT_TO_ENDPOINT_MAP_BUTTON field Can you update it to the correct field name?

Good catch! Fixed in latest commit

@nickolas-deboom nickolas-deboom force-pushed the matter-switch-update-field-names branch 6 times, most recently from 2879761 to 7b5daf1 Compare April 15, 2025 20:02
@nickolas-deboom nickolas-deboom force-pushed the matter-switch-update-field-names branch 2 times, most recently from cbaa7b4 to 1d46a97 Compare May 7, 2025 21:15
nickolas-deboom added a commit that referenced this pull request May 9, 2025
With the changes from
#2041,
the matter-switch subdrivers should be updated to maintain consistency.
This involves:
* Moving the initialization code from device_init into do_configure
* Implement the driverSwitched lifecycle event
* Additionally, improve the lifecycle event testing for the Aqara
  subdriver, removing the `TEST_CONFIGURE` field and instead leveraging a
  technique used in other test files to set `device.profile.id` for a mock
  device.
nickolas-deboom added a commit that referenced this pull request May 9, 2025
With the changes from
#2041,
the matter-switch subdrivers should be updated to maintain consistency.
This involves:
* Moving the initialization code from device_init into do_configure
* Implement the driverSwitched lifecycle event
* Additionally, improve the lifecycle event testing for the Aqara
  subdriver, removing the `TEST_CONFIGURE` field and instead leveraging a
  technique used in other test files to set `device.profile.id` for a mock
  device.
nickolas-deboom added a commit that referenced this pull request May 9, 2025
With the changes from
#2041,
the matter-switch subdrivers should be updated to maintain consistency.
This involves:
* Moving the initialization code from device_init into do_configure
* Implement the driverSwitched lifecycle event
* Additionally, improve the lifecycle event testing for the Aqara
  subdriver, removing the `TEST_CONFIGURE` field and instead leveraging a
  technique used in other test files to set `device.profile.id` for a mock
  device.
@nickolas-deboom nickolas-deboom force-pushed the matter-switch-update-field-names branch 3 times, most recently from ea07e1b to 653030b Compare May 9, 2025 18:47
This change moves the initialization logic for buttons and switches to
doConfigure. This keeps all of the profile selection logic all within
doConfigure and allows the removal of logic gates from device_init that
were there to ensure init code only ran one time.

Also added is a new function that runs at init that can rename or delete
persisted fields on the device.
@nickolas-deboom nickolas-deboom force-pushed the matter-switch-update-field-names branch from 653030b to ea1236c Compare May 13, 2025 15:40
@nickolas-deboom nickolas-deboom merged commit 39bd9cf into main May 13, 2025
11 checks passed
@nickolas-deboom nickolas-deboom deleted the matter-switch-update-field-names branch May 13, 2025 15:48
nickolas-deboom added a commit that referenced this pull request May 13, 2025
With the changes from #2041, the matter-switch subdrivers should be
updated to maintain consistency. This involves:
* Moving the initialization code from device_init into do_configure
* Implement the driverSwitched lifecycle event
* Additionally, improve the lifecycle event testing for the Aqara
  subdriver, removing the `TEST_CONFIGURE` field and instead leveraging a
  technique used in other test files to set `device.profile.id` for a mock
  device.
nickolas-deboom added a commit that referenced this pull request Jun 17, 2025
With the changes from #2041, the matter-switch subdrivers should be
updated to maintain consistency. This involves:
* Moving the initialization code from device_init into do_configure
* Implement the driverSwitched lifecycle event
* Additionally, improve the lifecycle event testing for the Aqara
  subdriver, removing the `TEST_CONFIGURE` field and instead leveraging a
  technique used in other test files to set `device.profile.id` for a mock
  device.
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