Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Matter Switch: ensure device init is called on added #1445

Merged
merged 2 commits into from
Jun 17, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
ctowns marked this conversation as resolved.
Show resolved Hide resolved
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)
Comment on lines +517 to +518
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just calling out here as well that this has been audited to be idempotent

end

local matter_driver_template = {
Expand Down
Loading