Skip to content

Matter Window Covering: Fix shades that get stuck opening/closing#3050

Open
tpmanley wants to merge 1 commit into
mainfrom
bugfix/window-covering-status
Open

Matter Window Covering: Fix shades that get stuck opening/closing#3050
tpmanley wants to merge 1 commit into
mainfrom
bugfix/window-covering-status

Conversation

@tpmanley

Copy link
Copy Markdown
Contributor

As reported in https://community.smartthings.com/t/smartwings-shades-matter-over-thread-stuck-on-opening-and-closing/309925 and thanks to the analysis done by @ldeora, it seems some shades get stuck in an opening or closing state. This attempts to fix this by starting a timer when the shade reports that it stopped moving. If a lift or tilt report is received then it cancels the timer. If the timer fires (meaning a lift or tilt report was not received within the timeout) then it will do a read of lift and/or tilt to determine the current position and update the windowShade state.

Resolves: #3043

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

Summary of Completed Tests

I have not had a chance to test this with a real device yet and won't be in a position to for some time. Would appreciate some help testing.

@tpmanley
tpmanley requested review from ctowns and hcarter-775 June 25, 2026 06:00
@github-actions

Copy link
Copy Markdown

@github-actions

github-actions Bot commented Jun 25, 2026

Copy link
Copy Markdown

Test Results

   73 files  ±0    538 suites  ±0   0s ⏱️ ±0s
3 194 tests +2  3 194 ✅ +2  0 💤 ±0  0 ❌ ±0 
5 195 runs  +2  5 195 ✅ +2  0 💤 ±0  0 ❌ ±0 

Results for commit b5f19e1. ± Comparison against base commit 4a06ba8.

♻️ This comment has been updated with latest results.

@github-actions

github-actions Bot commented Jun 25, 2026

Copy link
Copy Markdown

File Coverage
All files 86%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/matter-window-covering/src/sub_drivers/closure/closure_utils/embedded_cluster_utils.lua 43%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/matter-window-covering/src/sub_drivers/closure/closure_utils/utils.lua 94%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/matter-window-covering/src/sub_drivers/closure/closure_handlers/attribute_handlers.lua 86%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/matter-window-covering/src/sub_drivers/closure/closure_handlers/capability_handlers.lua 73%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/matter-window-covering/src/sub_drivers/matter-window-covering-position-updates-while-moving/can_handle.lua 70%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/matter-window-covering/src/sub_drivers/closure/init.lua 78%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/matter-window-covering/src/lazy_load_subdriver.lua 57%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/matter-window-covering/src/init.lua 91%

Minimum allowed coverage is 90%

Generated by 🐒 cobertura-action against b5f19e1

@NoahCornell NoahCornell left a comment

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.

LGTM, but would wait for one of the true matter driver dogs to approve before merging.

device:emit_event_for_endpoint(ib.endpoint_id, reverse and windowShade.opening() or windowShade.closing())
elseif state ~= 0 then -- unknown
elseif state == 0 then -- not moving; schedule a read to resolve final state if no position report arrives
schedule_position_read(device, ib.endpoint_id)

@hcarter-775 hcarter-775 Jul 16, 2026

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.

maybe we can just call a refresh command here instead of this unique call?

Suggested change
schedule_position_read(device, ib.endpoint_id)
driver:inject_capability_command(device, {
capability = capabilities.refresh.ID,
command = capabilities.refresh.commands.refresh.NAME,
args = {}
})

Then we wouldn't need this extra logic (which basically repeats itself anyway) at all.

Oops, this would still probably go in the "schedule" function, just in place of the read, we could do a refresh.

@hcarter-775

Copy link
Copy Markdown
Contributor

Looks like several tests are failing on 60.

As reported in https://community.smartthings.com/t/smartwings-shades-matter-over-thread-stuck-on-opening-and-closing/309925
and thanks to the analysis done by @ldeora, it seems some shades get stuck
in an opening or closing state. This attempts to fix this by starting a timer
when the shade reports that it stopped moving. If a lift or tilt report is
received then it cancels the timer. If the timer fires (meaning a lift or
tilt report was not received within the timeout) then it will do a read
of lift and/or tilt to determine the current position and update the
windowShade state.

Resolves: #3043
@tpmanley
tpmanley force-pushed the bugfix/window-covering-status branch from 931af02 to b5f19e1 Compare July 16, 2026 18:13
@tpmanley

Copy link
Copy Markdown
Contributor Author

Looks like several tests are failing on 60.

These errors were on a different driver and went away when I rebased on latest main branch

@hcarter-775

hcarter-775 commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

I have created a PR that attempts to solve this in a different way, without adding relatively slow timers that have the ability to complicate handling (by adding time into the mix!).

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.

Matter Window Covering: final open/closed state may not be resolved when OperationalStatus returns to 0

3 participants