Skip to content

Commit 91917f1

Browse files
fix refresh
1 parent 475172b commit 91917f1

3 files changed

Lines changed: 8 additions & 2 deletions

File tree

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,8 @@ SwitchFields.LEVEL_MIN = "__level_min"
8484
SwitchFields.LEVEL_MAX = "__level_max"
8585
SwitchFields.COLOR_MODE = "__color_mode"
8686

87+
SwitchFields.SUBSCRIBED_ATTRIBUTES_KEY = "__subscribed_attributes"
88+
8789
SwitchFields.updated_fields = {
8890
{ current_field_name = "__component_to_endpoint_map_button", updated_field_name = SwitchFields.COMPONENT_TO_ENDPOINT_MAP },
8991
{ current_field_name = "__switch_intialized", updated_field_name = nil },

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -449,14 +449,17 @@ end
449449
--- @param subscribed_attributes table key-value pairs mapping capability ids to subscribed attributes
450450
--- @param subscribed_events table key-value pairs mapping capability ids to subscribed events
451451
function utils.populate_subscribe_request_for_device(checked_device, subscribe_request, capabilities_seen, attributes_seen, events_seen, subscribed_attributes, subscribed_events)
452-
for _, component in pairs(checked_device.st_store.profile.components) do
452+
local subscribed_attrs = {}
453+
for _, component in pairs(checked_device.st_store.profile.components) do
453454
for _, capability in pairs(component.capabilities) do
454455
if not capabilities_seen[capability.id] then
455456
for _, attr in ipairs(subscribed_attributes[capability.id] or {}) do
456457
local cluster_id = attr.cluster or attr._cluster.ID
457458
local attr_id = attr.ID or attr.attribute
458459
if not attributes_seen[cluster_id..attr_id] then
459460
local ib = im.InteractionInfoBlock(nil, cluster_id, attr_id)
461+
subscribed_attrs[cluster_id] = subscribed_attrs[cluster_id] or {}
462+
subscribed_attrs[cluster_id][attr_id] = ib
460463
subscribe_request:with_info_block(ib)
461464
attributes_seen[cluster_id..attr_id] = true
462465
end
@@ -474,6 +477,7 @@ function utils.populate_subscribe_request_for_device(checked_device, subscribe_r
474477
end
475478
end
476479
end
480+
checked_device:set_field(fields.SUBSCRIBED_ATTRIBUTES_KEY, subscribed_attrs)
477481
end
478482

479483
--- create and send a subscription request by checking all devices, accounting for both parent and child devices

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,6 @@ local CLUSTER_SUBSCRIBE_LIST = {
122122
WindowCovering.server.attributes.CurrentPositionLiftPercent100ths,
123123
WindowCovering.server.attributes.CurrentPositionTiltPercent100ths,
124124
WindowCovering.server.attributes.OperationalStatus,
125-
clusters.PowerSource.server.attributes.AttributeList,
126125
clusters.LevelControl.server.attributes.CurrentLevel,
127126
}
128127

@@ -140,6 +139,7 @@ local function update_profile()
140139
for i, clus in ipairs(CLUSTER_SUBSCRIBE_LIST) do
141140
if i > 1 then subscribe_request:merge(clus:subscribe(mock_device)) end
142141
end
142+
subscribe_request:merge(clusters.PowerSource.server.attributes.AttributeList:subscribe(mock_device))
143143
test.socket.matter:__expect_send({mock_device.id, subscribe_request})
144144
test.wait_for_events()
145145
updated_device_profile = t_utils.get_profile_definition("window-covering-modular.yml",

0 commit comments

Comments
 (0)