Skip to content

Matter Switch: Add subdriver for Third Reality MK1 #2109

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

nickolas-deboom
Copy link
Contributor

@nickolas-deboom nickolas-deboom commented May 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

Description of Change

Add new profile and a subdriver to support the Third Reality keyboard, which contains 12 matter-enabled buttons.

Summary of Testing

Tested on device and with new unit tests.

Copy link

github-actions bot commented May 1, 2025

Duplicate profile check: Passed - no duplicate profiles detected.

Copy link

github-actions bot commented May 1, 2025

Copy link

github-actions bot commented May 1, 2025

Test Results

   66 files    427 suites   0s ⏱️
2 186 tests 2 186 ✅ 0 💤 0 ❌
3 734 runs  3 734 ✅ 0 💤 0 ❌

Results for commit 064c7a6.

♻️ This comment has been updated with latest results.

Copy link

github-actions bot commented May 1, 2025

File Coverage
All files 92%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/matter-switch/src/third-reality-mk1/init.lua 95%
/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%
/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/aqara-cube/init.lua 96%

Minimum allowed coverage is 90%

Generated by 🐒 cobertura-action against 064c7a6

@nickolas-deboom nickolas-deboom changed the title Matter Switch: Add 13 button profile Matter Switch: Add subdriver for 12 button device May 1, 2025
@nickolas-deboom nickolas-deboom changed the title Matter Switch: Add subdriver for 12 button device Matter Switch: Add subdriver for 12 button keyboard May 1, 2025
@ldeora
Copy link

ldeora commented May 1, 2025

Is there a reason why the profiles for 9, 10 and 11 buttons are intentionally omitted? A device like the 3rd Reality MK1 Keyboard would work out of the box with these profiles. The device and the platform are Matter certified after all...

@nickolas-deboom
Copy link
Contributor Author

Is there a reason why the profiles for 9, 10 and 11 buttons are intentionally omitted? A device like the 3rd Reality MK1 Keyboard would work out of the box with these profiles. The device and the platform are Matter certified after all...

This PR is specifically meant for supporting the 3rd Reality MK1.

@nickolas-deboom nickolas-deboom changed the title Matter Switch: Add subdriver for 12 button keyboard Matter Switch: Add subdriver for Third Reality MK1 May 1, 2025
@nickolas-deboom nickolas-deboom force-pushed the add-new-button-profile branch 3 times, most recently from 7a822d1 to ccbdbbd Compare May 1, 2025 17:52
@nickolas-deboom nickolas-deboom force-pushed the add-new-button-profile branch 2 times, most recently from 52e5174 to bc937cc Compare May 8, 2025 15:35
@nickolas-deboom nickolas-deboom changed the base branch from main to matter-switch-update-field-names May 8, 2025 15:35
@nickolas-deboom nickolas-deboom requested a review from ctowns May 8, 2025 15:36
end

local function device_added(driver, device)
device_init(driver, device)
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe let's just subscribe or even return here rather than re-call the whole init? I understand we're mostly doing this call to overwrite the main driver, so I think we could also make a comment of that.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The main driver also calls device_init within device_added, which was done to ensure init is called in the case of device caching: ed8fe8f

So I think it might be needed here still?

Copy link
Contributor

Choose a reason for hiding this comment

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

@ctowns what was the reasoning for adding this init function in added for only matter switch? I see it was added in this pr but I don't see a description.

Copy link
Contributor

Choose a reason for hiding this comment

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

This was done to ensure that subscribe was called for all devices, because in some cases there is a race condition that causes the init event to not fire for some devices. Therefore, calling init again in added was meant to ensure that the processing in init was occuring even if the init event was not queued due to the race condition.

Parent-Child devices were primarily affected, so I wouldn't expect it to be an issue here.

There is a detail explanation here: https://smartthings.atlassian.net/browse/CHAD-13449

local function match_profile(driver, device)
device:try_update_metadata({profile = "12-button-keyboard"})
build_button_component_map(device)
configure_buttons(device)
Copy link
Contributor

Choose a reason for hiding this comment

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

would we want to use the new buttons.configure call here as well?

Copy link
Contributor Author

@nickolas-deboom nickolas-deboom May 8, 2025

Choose a reason for hiding this comment

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

Yes but that will need to wait until PR 1754 gets merged (or if this one gets merged first, then that other PR will need to do this change)

local function info_changed(driver, device, event, args)
if device.profile.id ~= args.old_st_store.profile.id then
configure_buttons(device)
subscribe(device)
Copy link
Contributor

@ctowns ctowns May 8, 2025

Choose a reason for hiding this comment

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

You could potentially just override the device:subscribe function directly by calling:

device:extend_device("subscribe", subscribe)

which will override the library subscribe function directly and point the device to the subscribe function you have defined here. I can't think of any cases where this would be needed over the solution you currently have, but if a library function call somewhere calls device:subscribe, it might be nice to just have the default subscribe itself overridden, since that is what the extend_device api is meant to be used for.

@nickolas-deboom nickolas-deboom force-pushed the matter-switch-update-field-names branch 2 times, most recently from 49ba419 to ea07e1b Compare May 9, 2025 18:37
@nickolas-deboom nickolas-deboom force-pushed the add-new-button-profile branch from ac5d0a0 to 02b2f8a Compare May 9, 2025 18:40
@nickolas-deboom nickolas-deboom force-pushed the matter-switch-update-field-names branch from ea07e1b to 653030b Compare May 9, 2025 18:47
@nickolas-deboom nickolas-deboom force-pushed the add-new-button-profile branch from 02b2f8a to 07b6e65 Compare May 12, 2025 20:13
@nickolas-deboom nickolas-deboom force-pushed the matter-switch-update-field-names branch from 653030b to ea1236c Compare May 13, 2025 15:40
Base automatically changed from matter-switch-update-field-names to main May 13, 2025 15:48
@nickolas-deboom nickolas-deboom force-pushed the add-new-button-profile branch from 07b6e65 to 2e69acd Compare May 13, 2025 15:58
Add new profile and a subdriver to support the Third Reality keyboard, which contains 12 matter-enabled buttons.
@nickolas-deboom nickolas-deboom force-pushed the add-new-button-profile branch from 2e69acd to 064c7a6 Compare May 13, 2025 18:40
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