Skip to content

Commit c976fb6

Browse files
fix can_handle
1 parent 41c3356 commit c976fb6

4 files changed

Lines changed: 29 additions & 17 deletions

File tree

drivers/SmartThings/matter-switch/profiles/window-covering-modular.yml renamed to drivers/SmartThings/matter-switch/profiles/window-covering.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: window-covering-modular
1+
name: window-covering
22
components:
33
- id: main
44
capabilities:
Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,27 @@
11
-- Copyright © 2026 SmartThings, Inc.
22
-- Licensed under the Apache License, Version 2.0
33

4-
return function(opts, driver, device, ...)
5-
local device_lib = require "st.device"
6-
local fields = require "switch_utils.fields"
7-
local switch_utils = require "switch_utils.utils"
8-
if device.network_type == device_lib.NETWORK_TYPE_CHILD then
9-
device = device:get_parent_device()
4+
return function(opts, driver, device, ib)
5+
local capabilities = require "st.capabilities"
6+
local supported_capabilities = {
7+
capabilities.windowShade,
8+
capabilities.windowShadeLevel,
9+
capabilities.windowShadePreset,
10+
capabilities.windowShadeTiltLevel
11+
}
12+
-- MatterMessageDispatcher handles all events through a MATTER typed device.
13+
-- Therefore, find and check if an endpoint-mapped EDGE_CHILD device exists,
14+
-- Note: parameter ib should always be populated here by MatterMessageDispatcher.
15+
if opts and opts.dispatcher_class == "MatterMessageDispatcher" then
16+
local switch_utils = require "switch_utils.utils"
17+
if ib and ib.info_block and ib.info_block.endpoint_id then
18+
device = switch_utils.find_child(device, ib.info_block.endpoint_id) or device
19+
end
1020
end
11-
if #switch_utils.get_endpoints_by_device_type(device, fields.DEVICE_TYPE_ID.WINDOW_COVERING) > 0 then
12-
return true, require("sub_drivers.closures")
21+
for _, capability in ipairs(supported_capabilities) do
22+
if device:supports_capability(capability) then
23+
return true, require("sub_drivers.closures")
24+
end
1325
end
1426
return false
1527
end

drivers/SmartThings/matter-switch/src/switch_utils/device_configuration.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ function WindowCoveringDeviceConfiguration.assign_profile_for_window_covering_ep
180180
end
181181

182182
table.insert(optional_supported_component_capabilities, {"main", main_component_capabilities})
183-
return "window-covering-modular", optional_supported_component_capabilities
183+
return "window-covering", optional_supported_component_capabilities
184184
end
185185

186186

drivers/SmartThings/matter-switch/src/test/test_matter_window_covering.lua

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ local WindowCovering = clusters.WindowCovering
1212
local mock_device = test.mock_device.build_test_matter_device(
1313
{
1414
label = "Matter Window Covering",
15-
profile = t_utils.get_profile_definition("window-covering-modular.yml"),
15+
profile = t_utils.get_profile_definition("window-covering.yml"),
1616
manufacturer_info = {vendor_id = 0x0000, product_id = 0x0000},
1717
matter_version = {hardware = 1, software = 1},
1818
endpoints = {
@@ -59,7 +59,7 @@ local mock_device = test.mock_device.build_test_matter_device(
5959
)
6060

6161
local mock_child = test.mock_device.build_test_child_device({
62-
profile = t_utils.get_profile_definition("window-covering-modular.yml"),
62+
profile = t_utils.get_profile_definition("window-covering.yml"),
6363
device_network_id = string.format("%s:%d", mock_device.id, 20),
6464
parent_device_id = mock_device.id,
6565
parent_assigned_child_key = string.format("%d", 20)
@@ -106,7 +106,7 @@ local function test_init()
106106
mock_device:expect_device_create({
107107
type = "EDGE_CHILD",
108108
label = "Matter Window Covering 2",
109-
profile = "window-covering-modular",
109+
profile = "window-covering",
110110
parent_device_id = mock_device.id,
111111
parent_assigned_child_key = string.format("%d", 20)
112112
})
@@ -129,10 +129,10 @@ local function update_profile()
129129
test.socket.matter:__queue_receive({mock_device.id, clusters.PowerSource.attributes.AttributeList:build_test_report_data(
130130
mock_device, 10, {uint32(clusters.PowerSource.attributes.BatPercentRemaining.ID)}
131131
)})
132-
mock_child:expect_metadata_update({ profile = "window-covering-modular", optional_component_capabilities = {{"main", {"windowShadeLevel", "windowShadeTiltLevel"}}} })
133-
mock_device:expect_metadata_update({ profile = "window-covering-modular", optional_component_capabilities = {{"main", {"windowShadeLevel", "windowShadeTiltLevel", "battery"}}} })
132+
mock_child:expect_metadata_update({ profile = "window-covering", optional_component_capabilities = {{"main", {"windowShadeLevel", "windowShadeTiltLevel"}}} })
133+
mock_device:expect_metadata_update({ profile = "window-covering", optional_component_capabilities = {{"main", {"windowShadeLevel", "windowShadeTiltLevel", "battery"}}} })
134134
test.wait_for_events()
135-
local updated_device_profile = t_utils.get_profile_definition("window-covering-modular.yml",
135+
local updated_device_profile = t_utils.get_profile_definition("window-covering.yml",
136136
{enabled_optional_capabilities = {{"main", {"windowShadeLevel", "windowShadeTiltLevel"}}}}
137137
)
138138
test.socket.device_lifecycle:__queue_receive(mock_child:generate_info_changed({ profile = updated_device_profile }))
@@ -142,7 +142,7 @@ local function update_profile()
142142
end
143143
test.socket.matter:__expect_send({mock_device.id, subscribe_request})
144144
test.wait_for_events()
145-
updated_device_profile = t_utils.get_profile_definition("window-covering-modular.yml",
145+
updated_device_profile = t_utils.get_profile_definition("window-covering.yml",
146146
{enabled_optional_capabilities = {{"main", {"windowShadeLevel", "windowShadeTiltLevel", "battery"}}}}
147147
)
148148
test.socket.device_lifecycle:__queue_receive(mock_device:generate_info_changed({ profile = updated_device_profile }))

0 commit comments

Comments
 (0)