Skip to content

Matter Window Covering: Update preset handling #2295

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 4 commits into
base: main
Choose a base branch
from

Conversation

nickolas-deboom
Copy link
Contributor

@nickolas-deboom nickolas-deboom commented Jul 29, 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 utilizes the setPresetPosition command that was recently added to the windowShadePreset capability to set the preset rather than using an embedded preference.

Summary of Completed Tests

Tested new attributes via SmartThings cli and updated UTs.

This change utilizes the setPresetPosition command that was recently
added to the windowCoveringPreset capability to set the preset rather
than using an embedded preference.
Copy link

Duplicate profile check: Warning - duplicate profiles detected.
window-covering-battery.yml == window-covering-profile.yml

Copy link

Copy link

github-actions bot commented Jul 29, 2025

Test Results

   68 files    447 suites   0s ⏱️
2 296 tests 2 296 ✅ 0 💤 0 ❌
3 890 runs  3 890 ✅ 0 💤 0 ❌

Results for commit c40d936.

♻️ This comment has been updated with latest results.

Copy link

github-actions bot commented Jul 29, 2025

File Coverage
All files NaN%

Minimum allowed coverage is 90%

Generated by 🐒 cobertura-action against c40d936

Comment on lines 132 to 136
device:emit_event(capabilities.windowShadePreset.supportedCommands({"presetPosition", "setPresetPosition"}, {visibility = {displayed = false}}))
if device:supports_capability_by_id(capabilities.windowShadePreset.ID) and
device:get_latest_state("main", capabilities.windowShadePreset.ID, capabilities.windowShadePreset.position.NAME) == nil then
device:emit_event(capabilities.windowShadePreset.position(PRESET_LEVEL, {visibility = {displayed = false}}))
end
Copy link
Contributor

Choose a reason for hiding this comment

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

I ultimately decided to omit the additions in the added handler for now, since these events will be sent by init. After migration is complete we can remove the init code and add the added events.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sounds good, updated in the latest commit!

@nickolas-deboom nickolas-deboom requested a review from greens July 29, 2025 19:22
These events are already present in the init handler and can be moved to
added after the migration is complete.
Comment on lines 132 to 143
local function set_preset(device)
test.socket.capability:__expect_send(
device:generate_test_message(
"main", capabilities.windowShadePreset.supportedCommands({"presetPosition", "setPresetPosition"}, {visibility = {displayed = false}})
)
)
test.socket.capability:__expect_send(
device:generate_test_message(
"main", capabilities.windowShadePreset.position(30, {visibility = {displayed = false}})
)
)
end
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd maybe extend this test just to verify that the updated value is used for the next presetPosition command

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 call, I updated the test case called 'Handle preset commands' to verify this behavior in the latest commit

Remove preset preference from test cases in favor of using
setPresetPosition command to set preset lift value, and update test case
to verify the behavior.
@nickolas-deboom nickolas-deboom requested a review from ctowns August 11, 2025 14:53
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.

2 participants