Skip to content

Conversation

@hcarter-775
Copy link
Contributor

@hcarter-775 hcarter-775 commented Dec 29, 2025

Description of Change

Update all profiles to support statelessStep capabilities as needed. Include handlers for these step capabilities using the Matter-provided step commands.

This breaks apart the work found in #2669 so that the stateless capability support can be reviewed as an isolated unit.

Summary of Completed Tests

Unit tests added. Tested on-device.

@github-actions
Copy link

Duplicate profile check: Warning - duplicate profiles detected.
light-color-level-2200K-6500K.yml == light-color-level.yml
light-level-colorTemperature-2200K-6500K.yml == light-level-colorTemperature.yml

@github-actions
Copy link

@github-actions
Copy link

github-actions bot commented Dec 29, 2025

Test Results

   71 files    481 suites   0s ⏱️
2 485 tests 2 331 ✅ 0 💤 0 ❌ 154 🔥
4 266 runs  4 027 ✅ 0 💤 0 ❌ 239 🔥

For more details on these errors, see this check.

Results for commit 17f06e2.

♻️ This comment has been updated with latest results.

@github-actions
Copy link

github-actions bot commented Dec 29, 2025

File Coverage
All files 42%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/matter-switch/src/switch_handlers/attribute_handlers.lua 13%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/matter-switch/src/switch_handlers/event_handlers.lua 24%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/matter-switch/src/switch_handlers/capability_handlers.lua 20%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/matter-switch/src/switch_utils/utils.lua 18%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/matter-switch/src/switch_utils/embedded_cluster_utils.lua 32%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/matter-switch/src/switch_utils/color_utils.lua 9%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/matter-switch/src/switch_utils/device_configuration.lua 17%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/matter-switch/src/switch_utils/fields.lua 99%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/matter-switch/src/init.lua 76%

Minimum allowed coverage is 90%

Generated by 🐒 cobertura-action against 17f06e2

local step_mode = step_percent_change > 0 and (clusters.ColorControl.types.StepModeEnum and clusters.ColorControl.types.StepModeEnum.DOWN or 3) or (clusters.ColorControl.types.StepModeEnum and clusters.ColorControl.types.StepModeEnum.UP or 1)
local min_mireds = switch_utils.get_field_for_endpoint(device, fields.COLOR_TEMP_BOUND_RECEIVED_MIRED..fields.COLOR_TEMP_MIN, endpoint_id) or fields.COLOR_TEMPERATURE_MIRED_MIN -- default min mireds
local max_mireds = switch_utils.get_field_for_endpoint(device, fields.COLOR_TEMP_BOUND_RECEIVED_MIRED..fields.COLOR_TEMP_MAX, endpoint_id) or fields.COLOR_TEMPERATURE_MIRED_MAX -- default max mireds
local step_size_in_mireds = (max_mireds - min_mireds) * st_utils.round((math.abs(step_percent_change)/100))
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 wouldn't want to round this value right? Since abs(step_percent_change) is between 0 and 100 so this expression would round to 0 or 1

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh shoot, when making some changes last week I dropped the "*100". Will add that back in

@hcarter-775 hcarter-775 force-pushed the feature/statelessStep branch from 80a5c0a to 00f1bf4 Compare January 7, 2026 19:16
Copy link
Contributor

@nickolas-deboom nickolas-deboom left a comment

Choose a reason for hiding this comment

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

I approved earlier but noticed there are some print statements from debugging I assume

@hcarter-775
Copy link
Contributor Author

@nickolas-deboom thanks for the catch, got those removed

Copy link
Contributor

@nickolas-deboom nickolas-deboom left a comment

Choose a reason for hiding this comment

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

LGTM! Looks like there is are test failures but I ran the tests locally and they pass, so they might need to be re-run in CI

version: 1
- id: switchLevel
version: 1
- id: statelessSwitchLevelStep
Copy link
Contributor

Choose a reason for hiding this comment

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

This should be after the config here and in some of the other profiles

Copy link
Contributor Author

Choose a reason for hiding this comment

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

good catch!

@@ -0,0 +1,163 @@
-- Copyright © 2022 SmartThings, Inc.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
-- Copyright © 2022 SmartThings, Inc.
-- Copyright © 2026 SmartThings, Inc.

local COLOR_TEMPERATURE_KELVIN_MIN = 1000
SwitchFields.COLOR_TEMPERATURE_MIRED_MAX = SwitchFields.MIRED_KELVIN_CONVERSION_CONSTANT/COLOR_TEMPERATURE_KELVIN_MIN
SwitchFields.COLOR_TEMPERATURE_MIRED_MIN = SwitchFields.MIRED_KELVIN_CONVERSION_CONSTANT/COLOR_TEMPERATURE_KELVIN_MAX
SwitchFields.COLOR_TEMPERATURE_MIRED_MAX = math.floor(SwitchFields.MIRED_KELVIN_CONVERSION_CONSTANT/COLOR_TEMPERATURE_KELVIN_MIN)
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is this changing?

Copy link
Contributor

Choose a reason for hiding this comment

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

If these default values got used (which normally they would not be), COLOR_TEMPERATURE_MIRED_MAX specifically would be a decimal value while commands are expecting ints, which a unit test was complaining about. I should also note that the min/max kelvin values here were arbitrarily chosen, and I mistakenly assumed these conversions would be a clean integer division

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 step function requires that these are numbers, not floats. I could have done the floor-ing in the handler, but since they are just arbitrary constants, I figured why not do it in the base def

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