Skip to content

Commit

Permalink
Matter Switch: ensure device init is called on added
Browse files Browse the repository at this point in the history
  • Loading branch information
ctowns committed Jun 14, 2024
1 parent 86d503a commit c49e121
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion drivers/SmartThings/matter-switch/src/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,10 @@ local function temp_attr_handler(driver, device, ib, response)
return
end
local temp = utils.round(MIRED_KELVIN_CONVERSION_CONSTANT/ib.data.value)
local temp_device = find_child(device, ib.endpoint_id) or device
local temp_device = device
if device:get_field(IS_PARENT_CHILD_DEVICE) == true then
temp_device = find_child(device, ib.endpoint_id) or device
end
local most_recent_temp = temp_device:get_field(MOST_RECENT_TEMP)
-- this is to avoid rounding errors from the round-trip conversion of Kelvin to mireds
if most_recent_temp ~= nil and
Expand Down Expand Up @@ -510,6 +513,9 @@ local function device_added(driver, device)
if device.network_type == device_lib.NETWORK_TYPE_CHILD then
handle_refresh(driver, device)
end

-- call device init in case init is not called after added due to device caching
device_init(driver, device)
end

local matter_driver_template = {
Expand Down

0 comments on commit c49e121

Please sign in to comment.