Skip to content

Commit

Permalink
Fix abnormal rounding issue (#1749)
Browse files Browse the repository at this point in the history
Signed-off-by: Hunsup Jung <[email protected]>
  • Loading branch information
HunsupJung authored Nov 15, 2024
1 parent 33f44ec commit 8107bd9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions drivers/SmartThings/matter-thermostat/src/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1172,7 +1172,7 @@ local heating_setpoint_limit_handler_factory = function(minOrMax)
-- Only emit the capability for RPC version >= 5 (unit conversion for
-- heating setpoint range capability is only supported for RPC >= 5)
if version.rpc >= 5 then
device:emit_event_for_endpoint(ib.endpoint_id, capabilities.thermostatHeatingSetpoint.heatingSetpointRange({ value = { minimum = min, maximum = max }, unit = "C" }))
device:emit_event_for_endpoint(ib.endpoint_id, capabilities.thermostatHeatingSetpoint.heatingSetpointRange({ value = { minimum = min, maximum = max, step = 0.1 }, unit = "C" }))
end
else
device.log.warn_with({hub_logs = true}, string.format("Device reported a min heating setpoint %d that is not lower than the reported max %d", min, max))
Expand All @@ -1196,7 +1196,7 @@ local cooling_setpoint_limit_handler_factory = function(minOrMax)
-- Only emit the capability for RPC version >= 5 (unit conversion for
-- cooling setpoint range capability is only supported for RPC >= 5)
if version.rpc >= 5 then
device:emit_event_for_endpoint(ib.endpoint_id, capabilities.thermostatCoolingSetpoint.coolingSetpointRange({ value = { minimum = min, maximum = max }, unit = "C" }))
device:emit_event_for_endpoint(ib.endpoint_id, capabilities.thermostatCoolingSetpoint.coolingSetpointRange({ value = { minimum = min, maximum = max, step = 0.1 }, unit = "C" }))
end
else
device.log.warn_with({hub_logs = true}, string.format("Device reported a min cooling setpoint %d that is not lower than the reported max %d", min, max))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ test.register_coroutine_test(
clusters.Thermostat.attributes.AbsMaxHeatSetpointLimit:build_test_report_data(mock_device, 1, 3222)
})
test.socket.capability:__expect_send(
mock_device:generate_test_message("main", capabilities.thermostatHeatingSetpoint.heatingSetpointRange({ value = { minimum = 10.00, maximum = 32.22 }, unit = "C" }))
mock_device:generate_test_message("main", capabilities.thermostatHeatingSetpoint.heatingSetpointRange({ value = { minimum = 10.00, maximum = 32.22, step = 0.1 }, unit = "C" }))
)
configure(mock_device)
test.socket.capability:__queue_receive({
Expand All @@ -151,7 +151,7 @@ test.register_coroutine_test(
clusters.Thermostat.attributes.AbsMaxCoolSetpointLimit:build_test_report_data(mock_device, 1, 3222)
})
test.socket.capability:__expect_send(
mock_device:generate_test_message("main", capabilities.thermostatCoolingSetpoint.coolingSetpointRange({ value = { minimum = 10.00, maximum = 32.22 }, unit = "C" }))
mock_device:generate_test_message("main", capabilities.thermostatCoolingSetpoint.coolingSetpointRange({ value = { minimum = 10.00, maximum = 32.22, step = 0.1 }, unit = "C" }))
)
configure(mock_device)
test.socket.capability:__queue_receive({
Expand All @@ -176,7 +176,7 @@ test.register_coroutine_test(
clusters.Thermostat.attributes.AbsMaxHeatSetpointLimit:build_test_report_data(mock_device, 1, 3222)
})
test.socket.capability:__expect_send(
mock_device:generate_test_message("main", capabilities.thermostatHeatingSetpoint.heatingSetpointRange({ value = { minimum = 10.00, maximum = 32.22 }, unit = "C" }))
mock_device:generate_test_message("main", capabilities.thermostatHeatingSetpoint.heatingSetpointRange({ value = { minimum = 10.00, maximum = 32.22, step = 0.1 }, unit = "C" }))
)
configure(mock_device)
test.socket.capability:__queue_receive({
Expand All @@ -201,7 +201,7 @@ test.register_coroutine_test(
clusters.Thermostat.attributes.AbsMaxCoolSetpointLimit:build_test_report_data(mock_device, 1, 3222)
})
test.socket.capability:__expect_send(
mock_device:generate_test_message("main", capabilities.thermostatCoolingSetpoint.coolingSetpointRange({ value = { minimum = 10.00, maximum = 32.22 }, unit = "C" }))
mock_device:generate_test_message("main", capabilities.thermostatCoolingSetpoint.coolingSetpointRange({ value = { minimum = 10.00, maximum = 32.22, step = 0.1 }, unit = "C" }))
)
configure(mock_device)
test.socket.capability:__queue_receive({
Expand Down Expand Up @@ -285,7 +285,7 @@ test.register_message_test(
{
channel = "capability",
direction = "send",
message = mock_device:generate_test_message("main", capabilities.thermostatCoolingSetpoint.coolingSetpointRange({ value = { minimum = 10.00, maximum = 32.22 }, unit = "C" }))
message = mock_device:generate_test_message("main", capabilities.thermostatCoolingSetpoint.coolingSetpointRange({ value = { minimum = 10.00, maximum = 32.22, step = 0.1 }, unit = "C" }))
}
}
)
Expand All @@ -312,7 +312,7 @@ test.register_message_test(
{
channel = "capability",
direction = "send",
message = mock_device:generate_test_message("main", capabilities.thermostatHeatingSetpoint.heatingSetpointRange({ value = { minimum = 10.00, maximum = 32.22 }, unit = "C" }))
message = mock_device:generate_test_message("main", capabilities.thermostatHeatingSetpoint.heatingSetpointRange({ value = { minimum = 10.00, maximum = 32.22, step = 0.1 }, unit = "C" }))
}
}
)
Expand Down

0 comments on commit 8107bd9

Please sign in to comment.