Skip to content

Zigbee Switch: Add support/handling for Stateless Step Capabilities#2818

Open
wkhenon wants to merge 1 commit intomainfrom
zigbee-switch/stateless-capabilities
Open

Zigbee Switch: Add support/handling for Stateless Step Capabilities#2818
wkhenon wants to merge 1 commit intomainfrom
zigbee-switch/stateless-capabilities

Conversation

@wkhenon
Copy link
Copy Markdown
Contributor

@wkhenon wkhenon commented Mar 2, 2026

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

@wkhenon wkhenon changed the base branch from main to feature/color_temp_range March 2, 2026 21:53
@github-actions
Copy link
Copy Markdown

github-actions bot commented Mar 2, 2026

@github-actions
Copy link
Copy Markdown

github-actions bot commented Mar 2, 2026

Test Results

   72 files    494 suites   0s ⏱️
2 710 tests 2 710 ✅ 0 💤 0 ❌
4 581 runs  4 581 ✅ 0 💤 0 ❌

Results for commit 0d7e0a1.

♻️ This comment has been updated with latest results.

@github-actions
Copy link
Copy Markdown

github-actions bot commented Mar 2, 2026

File Coverage
All files 96%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/zigbee-switch/src/tuya-multi/can_handle.lua 90%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/zigbee-switch/src/laisiao/init.lua 96%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/zigbee-switch/src/frient/init.lua 94%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/zigbee-switch/src/configurations/init.lua 98%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/zigbee-switch/src/frient-IO/init.lua 88%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/zigbee-switch/src/frient-IO/unbind_request.lua 71%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/zigbee-switch/src/aqara/version/init.lua 94%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/zigbee-switch/src/aqara-light/init.lua 92%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/zigbee-switch/src/preferences.lua 97%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/zigbee-switch/src/init.lua 92%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/zigbee-switch/src/lazy_load_subdriver.lua 57%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/zigbee-switch/src/inovelli/init.lua 98%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/zigbee-switch/src/aqara/init.lua 94%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/zigbee-switch/src/inovelli/vzm32-sn/init.lua 95%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/zigbee-switch/src/color_temp_range_handlers/init.lua 71%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/zigbee-switch/src/inovelli/vzm30-sn/init.lua 95%

Minimum allowed coverage is 90%

Generated by 🐒 cobertura-action against 0d7e0a1

@wkhenon wkhenon force-pushed the zigbee-switch/stateless-capabilities branch 2 times, most recently from 535962c to cf1fc47 Compare March 3, 2026 15:24
@github-actions
Copy link
Copy Markdown

github-actions bot commented Mar 3, 2026

Duplicate profile check: Warning - duplicate profiles detected.
color-temp-bulb-2700K-6500K.yml == color-temp-bulb.yml

@greens greens force-pushed the feature/color_temp_range branch from 3d5baa4 to 8855768 Compare March 3, 2026 21:17
@wkhenon wkhenon force-pushed the zigbee-switch/stateless-capabilities branch 2 times, most recently from c0a48c5 to f4a7af9 Compare March 4, 2026 17:26
Base automatically changed from feature/color_temp_range to main March 4, 2026 19:07
@wkhenon wkhenon force-pushed the zigbee-switch/stateless-capabilities branch from f10a277 to 1bbafc5 Compare March 9, 2026 14:30
@wkhenon wkhenon force-pushed the zigbee-switch/stateless-capabilities branch from 1bbafc5 to 21d5850 Compare March 9, 2026 20:23
@wkhenon wkhenon force-pushed the zigbee-switch/stateless-capabilities branch from 4ad4ca3 to 75ef0dc Compare March 11, 2026 19:24
@wkhenon wkhenon force-pushed the zigbee-switch/stateless-capabilities branch from 671071f to 2023b46 Compare March 12, 2026 19:08
@hcarter-775 hcarter-775 force-pushed the zigbee-switch/stateless-capabilities branch from 2023b46 to 2a1d09d Compare March 26, 2026 18:40
Level.server.commands.Step(mock_device, Level.types.MoveStepMode.UP, 254, 3, 0x01, 0x00)
}
}
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Should probably add the min_api_version to these tests like in the other tests

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@cjswedes @aleclorimer Can you remind me what these checks are for? These capabilities should not be gated by the api version 19 I don't think. Is that what min_api_version is saying?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Min api version specifies the minimum lua lib api version that we will run against. So I think this is needed, since the stateless step caps are newer, and are not present in old lua libs artifacts.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

added to all new tests

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Talked to @aleclorimer about this and I'm not sure we should be gating what tests can be run based on the capabilities in old lua libs artifacts, since that isn't an accurate representation of actual hub characteristics.

I am going to leave these for now since it matches the current behavior across drivers, but in a vacuum I don't think this test should be gated by api 19.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

There's certainly going to be a weird grey area/time where tests would run on earlier versions of lua-libs than what is set by the min_api_version. If you would like to test this against earlier versions of lua_libs then update the min_api_version to the versions that you tested against, you could do that. You could also run the tools/update_min_tags.py --filter <driver> with the driver and it will update those values automatically (with a bit of lua-libs modifications).

Copy link
Copy Markdown
Contributor

@hcarter-775 hcarter-775 Apr 2, 2026

Choose a reason for hiding this comment

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

I'm not sure that should be the case, as this blocks all automatic pre-60 testing from matter switch, for example? And since new capabilities (with commands) are always defined in the top-level init file today, this means that anytime we create a new one and implement it, we can never automatically run tests against lower lua libs. This seems like a strange, artificial requirement to me.

For example, if we had older fw tests for switch, the fix implemented here would have been caught in CI

Comment on lines +21 to +22
local kelvin_min = device:get_field(switch_utils.KELVIN_MIN);
local kelvin_max = device:get_field(switch_utils.KELVIN_MAX);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

These fields are set with the endpoint appended to the field name, but are being read here without the endpoint.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Also noticed that the 3 lines above here have semicolons at the end that should be removed

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

done to both. This was a bit of a weird issue- in matter we have the component_to_endpoint logic to get endpoints from a component, but in zigbee we don't. For now, I removed the endpoint logic altogether, so we cannot support different bounds across parent/child zigbee bulbs. I think this is an ok trade-off for the work it might take to add new infrastructure to handle this.

-- Third tier: use defaults
min_mireds = switch_utils.COLOR_TEMPERATURE_MIRED_MIN
max_mireds = switch_utils.COLOR_TEMPERATURE_MIRED_MAX
end
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

It would probably be worth adding test cases to cover tiers 1 & 2

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I removed the tier 1 case... since I now have us persist the max/min fields there is never a case where the tier 1 exists and tier 2 doesn't.

That said, I added a test for the tier 2 (now tier 1) case

@hcarter-775 hcarter-775 force-pushed the zigbee-switch/stateless-capabilities branch from 74f650c to 555e4e3 Compare April 1, 2026 20:40
Comment on lines +10 to +11
local COLOR_TEMPERATURE_MIRED_MAX = 1000 -- 15000 Kelvin
local COLOR_TEMPERATURE_MIRED_MIN = 67 -- 1000 Kelvin
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

A note to reviewers- while looking at this all, I started noticing that while we are saving these fields in Kelvin, almost all functionality involving these occurs in Mireds. Therefore, I have altered the flow to more directly use mireds, only converting into kelvin at the specific colorTemperatureRange step.

I believe this should simplify the constant conversion back and forth.

-- Copyright 2026 SmartThings, Inc.
-- Licensed under the Apache License, Version 2.0

local capabilities = require "st.capabilities"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit: Move this inside the function call for slight memory savings

Copy link
Copy Markdown
Contributor

@hcarter-775 hcarter-775 Apr 2, 2026

Choose a reason for hiding this comment

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

I'm not sure that will cause savings in this case, since st.capabilities is already required at the top of the main init.lua file.

@hcarter-775 hcarter-775 force-pushed the zigbee-switch/stateless-capabilities branch from 6a091be to 0d7e0a1 Compare April 3, 2026 16:58
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.

7 participants