Skip to content

Conversation

@nickolas-deboom
Copy link
Contributor

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

Summary of Completed Tests

@github-actions
Copy link

Duplicate profile check: Passed - no duplicate profiles detected.

@github-actions
Copy link

@github-actions
Copy link

github-actions bot commented Oct 28, 2025

Test Results

   71 files    465 suites   0s ⏱️
2 411 tests 2 298 ✅ 0 💤 0 ❌ 113 🔥
4 094 runs  3 910 ✅ 0 💤 0 ❌ 184 🔥

For more details on these errors, see this check.

Results for commit 5662469.

♻️ This comment has been updated with latest results.

@github-actions
Copy link

github-actions bot commented Oct 28, 2025

File Coverage
All files 28%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/matter-switch/src/utils/switch_utils.lua 23%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/matter-switch/src/utils/color_utils.lua 9%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/matter-switch/src/utils/device_configuration.lua 16%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/matter-switch/src/utils/switch_fields.lua 99%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/matter-switch/src/utils/embedded_cluster_utils.lua 32%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/matter-switch/src/generic_handlers/attribute_handlers.lua 13%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/matter-switch/src/generic_handlers/event_handlers.lua 24%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/matter-switch/src/generic_handlers/capability_handlers.lua 21%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/matter-switch/src/init.lua 80%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/matter-switch/src/sub_drivers/aqara_cube/init.lua 28%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/matter-switch/src/sub_drivers/camera/init.lua 3%

Minimum allowed coverage is 90%

Generated by 🐒 cobertura-action against 5662469

Copy link
Contributor

@hcarter-775 hcarter-775 left a comment

Choose a reason for hiding this comment

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

Just an initial review but I figured I'd get these thoughts out there

if child_profile then
num_floodlight_eps = num_floodlight_eps + 1
local name = string.format("%s %d", "Floodlight", num_floodlight_eps)
driver:try_create_device(
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think we should be trying to create new children every init

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's gated by CAMERA_INITIALIZED

Copy link
Contributor

Choose a reason for hiding this comment

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

why do we have this in init at all is my question then? Why not have it in do_configure if it's meant to be a one-time call

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We could definitely move it to configure. It was placed here during testing because it was easier to just delete the inventory db to clear CAMERA_INITIALIZED and get a new profile update rather than having to re-onboard.


local function info_changed(driver, device, event, args)
-- resubscribe and initialize relevant camera capabilities if a modular update has occurred
if not compare_components(device.profile.components, args.old_st_store.profile.components) then
Copy link
Contributor

Choose a reason for hiding this comment

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

not compare_components is kinda odd wording... maybe are_profiles_equal or something like that? And then we could just pass in device.profile if we wanted to be clearer with the now.

Also, this is a useful function, I might suggest moving it to switch_utils.

supported_capabilities = fields.supported_capabilities,
sub_drivers = {
require("sub_drivers.aqara_cube"),
require("sub_drivers.camera"),
Copy link
Contributor

Choose a reason for hiding this comment

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

this is a large bit of code... would we be able to leverage @cjswedes's improvements to subdriver loading to avoid loading it?

end

local function status_light_enabled_attr_handler(driver, device, ib, response)
local component = device.profile.components[component_map.statusLed]
Copy link
Contributor

Choose a reason for hiding this comment

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

to add to this comment, I think it could be good to get a clearer mapping between endpoints and these components so that we can endpoint_to_component in the emit_event_for_endpoint function. This may help cut out edge cases and bugs by putting all this mapping logic together into one place.

Copy link
Contributor Author

@nickolas-deboom nickolas-deboom Oct 29, 2025

Choose a reason for hiding this comment

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

I agree, I will add proper component mapping and switch away from using emit_component_event

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thinking about this more, there isn't any assurance that the clusters will be implemented on separate endpoints, so I'm not sure what the best way to handle this would be. Since this subdriver only applies to one profile, we know which capabilities belong in each component and so therefore always know where to route them with emit_component_event. So there might not be much benefit in further endpoint/component mapping. What do you think?

nickolas-deboom and others added 9 commits November 4, 2025 14:16
* Use assign_child_profile from device_configuration
* Use find_child from switch_utils
* Move st.utils to a global require
To avoid breaking routines, add in any capabilities from the current
profile before updating the profile with the new list of component
capabilities.
Compare the newly generated component capabilities list against the
current device profile rather than saving this information in a
persisted field.
@nickolas-deboom nickolas-deboom force-pushed the add-matter-camera-support branch 2 times, most recently from 66f0b0a to 31c2294 Compare November 4, 2025 20:47
},
supported_capabilities = fields.supported_capabilities,
sub_drivers = {
require("sub_drivers.aqara_cube"),
Copy link
Contributor Author

Choose a reason for hiding this comment

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

lazy loading for other subdrivers is implemented in #2525

@nickolas-deboom nickolas-deboom force-pushed the add-matter-camera-support branch from 31c2294 to 5662469 Compare November 4, 2025 20:54
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