Skip to content

Matter Window Covering: Always report accurate capability operational state#3133

Open
hcarter-775 wants to merge 3 commits into
mainfrom
bugfix/report-movement-while-moving
Open

Matter Window Covering: Always report accurate capability operational state#3133
hcarter-775 wants to merge 3 commits into
mainfrom
bugfix/report-movement-while-moving

Conversation

@hcarter-775

@hcarter-775 hcarter-775 commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

Description of Change

Use target positions and timeouts to ensure that idle states are only emitted when all state is cached properly. In doing this, add subscriptions to the target lift and target tilt attributes, to ensure that proper targets are being tracked at all times, from any source.

Resolves: #3043

Note: This builds on top of #3132, but technically these can be merged together and released as a single commit. I am currently leaning towards merging this branch into that branch and continuing that way, but I may end up just closing that PR and merging the whole thing here.

I am going to continue with just this PR, I think

Tag-along updates:

Several fields are not needed, so I have removed them to add greater clarity to the updated handling.

  • CURRENT_LIFT/CURRENT_TILT are fields that store some latest attribute states during runtime. A field is not required for this.
  • REVERSE_POLARITY stored the state of device.preferences.reverse, which is already stored in the data model. Therefore this is not needed. As it is persisted, it needs to be made nil to remove.
  • PRESET_LEVEL_KEY is only ever used (get_field) when the capability state is nil, and is therefore nil in that context as well. So we don't need this.

In info_changed, we should not try to update the device profile on any non-profile update, as the inventories can be synced for many reasons. In fact, the only case this would be required for is a software update, so I have altered the logic to explicitly check for that- this has been validated with identical handling in Matter Switch, and a unit test has been updated to validate this as well.

Summary of Completed Tests

Unit tests updated. Tested with VDA Window Covering as well as Bridged Ikea Blinds.

New tests are added to ensure the handlers do what they are expected to do.

@github-actions

Copy link
Copy Markdown

@github-actions

github-actions Bot commented Jul 20, 2026

Copy link
Copy Markdown

Test Results

   73 files    540 suites   0s ⏱️
3 241 tests 3 241 ✅ 0 💤 0 ❌
5 233 runs  5 233 ✅ 0 💤 0 ❌

Results for commit a2ccb07.

♻️ This comment has been updated with latest results.

@github-actions

github-actions Bot commented Jul 20, 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_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/lazy_load_subdriver.lua 57%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/matter-window-covering/src/init.lua 91%
/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/sub_drivers/closure/closure_utils/utils.lua 91%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/matter-window-covering/src/sub_drivers/closure/closure_utils/embedded_cluster_utils.lua 43%

Minimum allowed coverage is 90%

Generated by 🐒 cobertura-action against 9aaf446

@hcarter-775 hcarter-775 changed the title Bugfix/report movement while moving Matter Window Covering: Always report accurate capability operational state Jul 21, 2026
end

local function is_target_value_reached(current_value, target_value)
if (target_value and math.abs(current_value - target_value) <= TARGET_REACH_TOLERANCE) then

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.

If there is no target value then do we want to return true so that we do emit the status or will we never be in that situation?

@hcarter-775 hcarter-775 Jul 21, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The only cases I can see where there would be no target value would be if

  1. we reached it already, (handled)
  2. the timer this value was stored with times out, (handled in the timeout)
  3. the update came from a third party and we never received a target attribute (kinda handled)
  4. we received a target attribute report out of order. (handled)

Case 3 is the only one I can see where some mixup may happen might happen, but even then, the idle oprerational status attribute update response should take care of setting this.

Case 4 is the reason I don't think we'd want to default to true, since this very well may happen- timings are finnicky, especially since many times these reports are grouped together into a single response, and so there's no guaranteed ordering there.

@cjswedes cjswedes 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.

By moving this out of the subdriver it now applies to all window coverings. We should consider testing some other models too.

Comment thread drivers/SmartThings/matter-window-covering/src/init.lua
Comment thread drivers/SmartThings/matter-window-covering/src/init.lua
Comment thread drivers/SmartThings/matter-window-covering/src/init.lua
Comment thread drivers/SmartThings/matter-window-covering/src/init.lua
Comment thread drivers/SmartThings/matter-window-covering/src/init.lua
@hcarter-775

Copy link
Copy Markdown
Contributor Author

By moving this out of the subdriver it now applies to all window coverings. We should consider testing some other models too.

The current VDA does not have the same handling it did at the time this subdriver was introduced. Between the current handling it has and the bridged handling, I believe we have a pretty good variety of devices being checked. To be clear, this is handling that has never worked well either.

@hcarter-775
hcarter-775 changed the base branch from bugfix/handle-0-operational-state to main July 21, 2026 20:50
@hcarter-775
hcarter-775 force-pushed the bugfix/report-movement-while-moving branch from 90fa859 to 9aaf446 Compare July 21, 2026 20:53
Comment thread drivers/SmartThings/matter-window-covering/src/init.lua Outdated
@hcarter-775
hcarter-775 force-pushed the bugfix/report-movement-while-moving branch from 61f1750 to 71a36ed Compare July 23, 2026 02:03
@hcarter-775
hcarter-775 force-pushed the bugfix/report-movement-while-moving branch from 71a36ed to 09c8f10 Compare July 23, 2026 14:24
@github-actions

github-actions Bot commented Jul 23, 2026

Copy link
Copy Markdown

matter-window-covering_coverage.xml

File Coverage
All files 88%
/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/sub_drivers/closure/closure_utils/utils.lua 91%
/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/lazy_load_subdriver.lua 57%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/matter-window-covering/src/init.lua 92%

Minimum allowed coverage is 90%

Generated by 🐒 cobertura-action against a2ccb07

@tpmanley tpmanley 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.

I've done a fair amount of testing of these changes with bridged Ikea shades that support lift (not tilt) and it's working well, including fixing the issue where it would not show "opening" or "closing" the whole time it was moving.

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

4 participants