Skip to content

Commit

Permalink
Prevent multiple reads of MinSetpointDeadBand (SmartThingsCommunity#1686
Browse files Browse the repository at this point in the history
)

The driver currently attempts to only read MinSetpointDeadBand once
during the first time device_init is called, but the
MIN_SETPOINT_DEADBAND_CHECKED field is not persisted, so the read
request is sent during each device init. This is contributing to a spike
in InteractionQueueFull exceptions. This change ensures that the field
is persisted so that the read request is only sent once.
  • Loading branch information
nickolas-deboom authored Oct 14, 2024
1 parent 05a4ed3 commit 534b87c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
3 changes: 1 addition & 2 deletions drivers/SmartThings/matter-thermostat/src/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,6 @@ end
local function device_init(driver, device)
device:subscribe()
device:set_component_to_endpoint_fn(component_to_endpoint)

if not device:get_field(setpoint_limit_device_field.MIN_SETPOINT_DEADBAND_CHECKED) then
local auto_eps = device:get_endpoints(clusters.Thermostat.ID, {feature_bitmap = clusters.Thermostat.types.ThermostatFeature.AUTOMODE})
--Query min setpoint deadband if needed
Expand All @@ -280,7 +279,6 @@ local function device_init(driver, device)
deadband_read:merge(clusters.Thermostat.attributes.MinSetpointDeadBand:read())
device:send(deadband_read)
end
device:set_field(setpoint_limit_device_field.MIN_SETPOINT_DEADBAND_CHECKED, true)
end
end

Expand Down Expand Up @@ -808,6 +806,7 @@ local function min_deadband_limit_handler(driver, device, ib, response)
local val = ib.data.value / 10.0
log.info("Setting " .. setpoint_limit_device_field.MIN_DEADBAND .. " to " .. string.format("%s", val))
device:set_field(setpoint_limit_device_field.MIN_DEADBAND, val, { persist = true })
device:set_field(setpoint_limit_device_field.MIN_SETPOINT_DEADBAND_CHECKED, true, {persist = true})
end

local function fan_mode_handler(driver, device, ib, response)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,19 @@ test.register_coroutine_test(
end
)

test.register_coroutine_test(
"Set MIN_SETPOINT_DEADBAND_CHECKED flag on MinSetpointDeadBand attribute handler",
function()
test.socket.matter:__queue_receive({
mock_device.id,
clusters.Thermostat.attributes.MinSetpointDeadBand:build_test_report_data(mock_device, 1, 16) --1.6 celcius
})
test.wait_for_events()
local min_setpoint_deadband_checked = mock_device:get_field("MIN_SETPOINT_DEADBAND_CHECKED")
assert(min_setpoint_deadband_checked == true, "min_setpoint_deadband_checked is True")
end
)

test.register_message_test(
"Min and max heating setpoint attributes set capability constraint",
{
Expand Down

0 comments on commit 534b87c

Please sign in to comment.