Skip to content

Commit 509df2c

Browse files
Use modular profile for window coverings
1 parent 13a371f commit 509df2c

File tree

9 files changed

+101
-187
lines changed

9 files changed

+101
-187
lines changed

drivers/SmartThings/matter-switch/profiles/window-covering-battery.yml

Lines changed: 0 additions & 22 deletions
This file was deleted.

drivers/SmartThings/matter-switch/profiles/window-covering-batteryLevel.yml

Lines changed: 0 additions & 22 deletions
This file was deleted.

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

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: window-covering-tilt-battery
1+
name: window-covering-modular
22
components:
33
- id: main
44
capabilities:
@@ -8,10 +8,16 @@ components:
88
version: 1
99
- id: windowShadeLevel
1010
version: 1
11+
optional: true
1112
- id: windowShadeTiltLevel
1213
version: 1
14+
optional: true
1315
- id: battery
1416
version: 1
17+
optional: true
18+
- id: batteryLevel
19+
version: 1
20+
optional: true
1521
- id: firmwareUpdate
1622
version: 1
1723
- id: refresh
@@ -21,4 +27,3 @@ components:
2127
preferences:
2228
- preferenceId: reverse
2329
explicit: true
24-

drivers/SmartThings/matter-switch/profiles/window-covering-tilt-only-battery.yml

Lines changed: 0 additions & 22 deletions
This file was deleted.

drivers/SmartThings/matter-switch/profiles/window-covering-tilt-only.yml

Lines changed: 0 additions & 20 deletions
This file was deleted.

drivers/SmartThings/matter-switch/profiles/window-covering-tilt.yml

Lines changed: 0 additions & 22 deletions
This file was deleted.

drivers/SmartThings/matter-switch/profiles/window-covering.yml

Lines changed: 0 additions & 20 deletions
This file was deleted.

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

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -187,21 +187,27 @@ function ButtonDeviceConfiguration.configure_buttons(device, momentary_switch_ep
187187
end
188188
end
189189

190-
function WindowCoveringDeviceConfiguration.assign_profile_for_window_covering_ep(device)
191-
local profile_name = "window-covering"
192-
if #device:get_endpoints(clusters.WindowCovering.ID, {feature_bitmap = clusters.WindowCovering.types.Feature.TILT}) > 0 then
193-
profile_name = profile_name .. "-tilt"
194-
if #device:get_endpoints(clusters.WindowCovering.ID, {feature_bitmap = clusters.WindowCovering.types.Feature.LIFT}) == 0 then
195-
profile_name = profile_name .. "-only"
196-
end
190+
function WindowCoveringDeviceConfiguration.assign_profile_for_window_covering_ep(device, server_window_covering_ep_id)
191+
local ep_info = switch_utils.get_endpoint_info(device, server_window_covering_ep_id)
192+
local window_covering_cluster_info = switch_utils.find_cluster_on_ep(ep_info, clusters.WindowCovering.ID)
193+
local optional_supported_component_capabilities = {}
194+
local main_component_capabilities = {}
195+
196+
if clusters.WindowCovering.are_features_supported(clusters.WindowCovering.types.Feature.LIFT, window_covering_cluster_info.feature_map) then
197+
table.insert(main_component_capabilities, capabilities.windowShadeLevel.ID)
198+
end
199+
if clusters.WindowCovering.are_features_supported(clusters.WindowCovering.types.Feature.TILT, window_covering_cluster_info.feature_map) then
200+
table.insert(main_component_capabilities, capabilities.windowShadeTiltLevel.ID)
197201
end
198202
local battery_support = device:get_field(fields.profiling_data.BATTERY_SUPPORT) or fields.battery_support.NO_BATTERY
199203
if battery_support == fields.battery_support.BATTERY_PERCENTAGE then
200-
profile_name = profile_name .. "-battery"
204+
table.insert(main_component_capabilities, capabilities.battery.ID)
201205
elseif battery_support == fields.battery_support.BATTERY_LEVEL then
202-
profile_name = profile_name .. "-batteryLevel"
206+
table.insert(main_component_capabilities, capabilities.batteryLevel.ID)
203207
end
204-
return profile_name
208+
209+
table.insert(optional_supported_component_capabilities, {"main", main_component_capabilities})
210+
return "window-covering-modular", optional_supported_component_capabilities
205211
end
206212

207213

@@ -272,7 +278,7 @@ function DeviceConfiguration.match_profile(driver, device)
272278
ChildConfiguration.create_or_update_child_devices(driver, device, window_covering_ep_ids, default_endpoint_id, WindowCoveringDeviceConfiguration.assign_profile_for_window_covering_ep)
273279
end
274280
if switch_utils.tbl_contains(window_covering_ep_ids, default_endpoint_id) then
275-
updated_profile = WindowCoveringDeviceConfiguration.assign_profile_for_window_covering_ep(device)
281+
updated_profile, optional_component_capabilities = WindowCoveringDeviceConfiguration.assign_profile_for_window_covering_ep(device, default_endpoint_id)
276282
end
277283

278284
device:try_update_metadata({ profile = updated_profile, optional_component_capabilities = optional_component_capabilities })

0 commit comments

Comments
 (0)