Skip to content

Commit 3da8591

Browse files
committed
Clean up info changed handling
1 parent 37c73da commit 3da8591

File tree

1 file changed

+4
-14
lines changed
  • drivers/SmartThings/matter-thermostat/src

1 file changed

+4
-14
lines changed

drivers/SmartThings/matter-thermostat/src/init.lua

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -501,24 +501,14 @@ local function device_init(driver, device)
501501
end
502502

503503
local function info_changed(driver, device, event, args)
504-
-- Note this is needed because device:subscribe() does not recalculate
505-
-- the subscribed attributes each time it is run, that only happens at init.
506-
-- This will change in the 0.48.x release of the lua libs.
507-
for cap_id, attributes in pairs(subscribed_attributes) do
508-
if device:supports_capability_by_id(cap_id) then
509-
for _, attr in ipairs(attributes) do
510-
device:add_subscribed_attribute(attr)
511-
end
512-
end
504+
if device:get_field(SUPPORTED_COMPONENT_CAPABILITIES) then
505+
--re-up subscription with new capabilities using the modular supports_capability override
506+
device:extend_device("supports_capability_by_id", supports_capability_by_id_modular)
513507
end
514508

515509
if device.profile.id ~= args.old_st_store.profile.id then
516-
if device:get_field(SUPPORTED_COMPONENT_CAPABILITIES) then
517-
--re-up subscription with new capabilities using the modular supports_capability override
518-
device:extend_device("supports_capability_by_id", supports_capability_by_id_modular)
519-
end
510+
device:subscribe()
520511
end
521-
device:subscribe()
522512
schedule_polls_for_cumulative_energy_imported(device)
523513
end
524514

0 commit comments

Comments
 (0)