Skip to content

Commit

Permalink
Set setpoint to original value (#1743)
Browse files Browse the repository at this point in the history
Signed-off-by: Hunsup Jung <[email protected]>
  • Loading branch information
HunsupJung authored Nov 13, 2024
1 parent c5a25d4 commit 58877c2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
8 changes: 4 additions & 4 deletions drivers/SmartThings/matter-thermostat/src/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1122,15 +1122,15 @@ local function set_setpoint(setpoint)
"Invalid setpoint (%s) outside the min (%s) and the max (%s)",
value, min, max
))
device:emit_event(capabilities.thermostatHeatingSetpoint.heatingSetpoint(heating_setpoint))
device:emit_event(capabilities.thermostatHeatingSetpoint.heatingSetpoint(heating_setpoint, {state_change = true}))
return
end
if is_auto_capable and value > (cached_cooling_val - deadband) then
log.warn(string.format(
"Invalid setpoint (%s) is greater than the cooling setpoint (%s) with the deadband (%s)",
value, cooling_setpoint, deadband
))
device:emit_event(capabilities.thermostatHeatingSetpoint.heatingSetpoint(heating_setpoint))
device:emit_event(capabilities.thermostatHeatingSetpoint.heatingSetpoint(heating_setpoint, {state_change = true}))
return
end
else
Expand All @@ -1141,15 +1141,15 @@ local function set_setpoint(setpoint)
"Invalid setpoint (%s) outside the min (%s) and the max (%s)",
value, min, max
))
device:emit_event(capabilities.thermostatCoolingSetpoint.coolingSetpoint(cooling_setpoint))
device:emit_event(capabilities.thermostatCoolingSetpoint.coolingSetpoint(cooling_setpoint, {state_change = true}))
return
end
if is_auto_capable and value < (cached_heating_val + deadband) then
log.warn(string.format(
"Invalid setpoint (%s) is less than the heating setpoint (%s) with the deadband (%s)",
value, heating_setpoint, deadband
))
device:emit_event(capabilities.thermostatCoolingSetpoint.coolingSetpoint(cooling_setpoint))
device:emit_event(capabilities.thermostatCoolingSetpoint.coolingSetpoint(cooling_setpoint, {state_change = true}))
return
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,8 @@ local function test_init()
end
test.set_test_init_function(test_init)

local cached_heating_setpoint = capabilities.thermostatHeatingSetpoint.heatingSetpoint({ value = 24.44, unit = "C" })
local cached_cooling_setpoint = capabilities.thermostatCoolingSetpoint.coolingSetpoint({ value = 26.67, unit = "C" })
local cached_heating_setpoint = capabilities.thermostatHeatingSetpoint.heatingSetpoint({ value = 24.44, unit = "C" }, {state_change = true})
local cached_cooling_setpoint = capabilities.thermostatCoolingSetpoint.coolingSetpoint({ value = 26.67, unit = "C" }, {state_change = true})

local function configure(device)
test.socket.device_lifecycle:__queue_receive({ mock_device.id, "doConfigure" })
Expand All @@ -106,10 +106,10 @@ local function configure(device)
clusters.Thermostat.attributes.OccupiedCoolingSetpoint:build_test_report_data(mock_device, 1, 2667) --26.67 celcius
})
test.socket.capability:__expect_send(
device:generate_test_message("main", cached_heating_setpoint)
device:generate_test_message("main", capabilities.thermostatHeatingSetpoint.heatingSetpoint({ value = 24.44, unit = "C" }))
)
test.socket.capability:__expect_send(
device:generate_test_message("main", cached_cooling_setpoint)
device:generate_test_message("main", capabilities.thermostatCoolingSetpoint.coolingSetpoint({ value = 26.67, unit = "C" }))
)
test.wait_for_events()
end
Expand Down

0 comments on commit 58877c2

Please sign in to comment.