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

Matter Switch: Support fan/light devices #1991

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 Mar 11, 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 adds support for an extended color light/fan combination device. A new profile for this device type was added by PR 2012. New logic is included in the matter switch driver to support the component mapping for this profile. This change also refactors some of the initialization logic to help support expanding the driver to cover more multi-type devices in the future.

Summary of Completed Tests

Tested with an Orein bathroom fan device. New unit tests also included.

@nickolas-deboom nickolas-deboom force-pushed the support-fan-with-light-devices branch 2 times, most recently from bbbc400 to 4b7727c Compare March 11, 2025 20:33
@nickolas-deboom nickolas-deboom force-pushed the support-fan-with-light-devices branch from 9946633 to ee09b1d Compare March 19, 2025 21:44
Copy link

Duplicate profile check: Passed - no duplicate profiles detected.

Copy link

Copy link

github-actions bot commented Mar 19, 2025

Test Results

   65 files    420 suites   0s ⏱️
2 144 tests 2 144 ✅ 0 💤 0 ❌
3 664 runs  3 664 ✅ 0 💤 0 ❌

Results for commit a5896f7.

♻️ This comment has been updated with latest results.

Copy link

github-actions bot commented Mar 19, 2025

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

Minimum allowed coverage is 90%

Generated by 🐒 cobertura-action against a5896f7

@nickolas-deboom nickolas-deboom force-pushed the support-fan-with-light-devices branch 8 times, most recently from b631bb6 to 2d59ee9 Compare March 25, 2025 19:12
This change adds support for fan/switch combination devices. A new
multicomponent profile contains the fan capability in the main component
as well as capabilities for a color light in a secondary comoponent. New
logic is also introduced in the matter switch driver to support the
component mapping for this profile.
@nickolas-deboom nickolas-deboom force-pushed the support-fan-with-light-devices branch from 2d59ee9 to a5896f7 Compare March 26, 2025 16:10

--- device_type_supports_multicomponent_configuration helper function used to check
--- whether the device is currently supported by a profile for a multicomponent configuration.
local function device_type_supports_multicomponent_configuration(device, main_endpoint, secondary_endpoints, secondary_device_type)
Copy link
Contributor

Choose a reason for hiding this comment

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

I think pulling both the endpoints and the device type in as separate parameters is a little confusing. It could be better in this case to grab the endpoints based on the device type within this function

if ep ~= main_endpoint then
local button_component = "button" .. component_num
component_map[button_component] = ep
local function build_component_map(device, main_endpoint, secondary_endpoints, secondary_device_type)
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we should grab and sort the "secondary endpoints" in the function itself rather than pulling it in as a separate parameter

configure_buttons(device)
return
build_component_map(device, main_endpoint, button_eps, GENERIC_SWITCH_ID)
build_profile(device, main_endpoint, button_eps, GENERIC_SWITCH_ID)
Copy link
Contributor

Choose a reason for hiding this comment

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

build_profile seems a little bit generic?

@@ -56,6 +56,7 @@ local COMPONENT_TO_ENDPOINT_MAP = "__component_to_endpoint_map"
-- containing both button endpoints and switch endpoints will use this field
-- rather than COMPONENT_TO_ENDPOINT_MAP.
local COMPONENT_TO_ENDPOINT_MAP_BUTTON = "__component_to_endpoint_map_button"
local COMPONENT_TO_ENDPOINT_MAP_FAN = "__component_to_endpoint_map_fan"
Copy link
Contributor

@hcarter-775 hcarter-775 Mar 27, 2025

Choose a reason for hiding this comment

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

This seems like a dark road to go down... since it only leads to more and more component to endpoint maps that are the same other than the name?

Copy link
Contributor

Choose a reason for hiding this comment

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

Mainly, I worry about this because this is the kind of system that can't necessarily be removed once we add it.

@@ -194,6 +196,21 @@ local child_device_profile_overrides_per_vendor_id = {
}
}

local supported_mcd_configs_per_main_endpoint_device_type = {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think modular profiles will make this kind of a moot point, no? Since we can just have all capabilities we could ever need in the main component, and then support any/all of the capabilties we'd ever need in x number of components? Then, we'd only really have to account for that "x" value, and the rest of this would already be handled.

I understand that this is not the case now, so I it's a little less clear how to proceed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants