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

BUG2-4037 Z-Wave Thermostat: Whole number workaround #1984

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
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
3 changes: 3 additions & 0 deletions drivers/SmartThings/zwave-thermostat/src/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@ local function set_setpoint_factory(setpoint_type)
size = 2
})
else
-- There have been issues with some thermostats failing to handle non-integer values
-- correctly. This rounding is intended to be removed.
value = utils.round(value)
set = ThermostatSetpoint:Set({
setpoint_type = setpoint_type,
scale = scale,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ test.register_coroutine_test(
ThermostatSetpoint:Set({
setpoint_type = ThermostatSetpoint.setpoint_type.HEATING_1,
scale = 1,
value = 84.2
value = 84
})
)
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -635,4 +635,56 @@ test.register_coroutine_test(
end
)

test.register_coroutine_test(
"Setting the heating setpoint should generate the appropriate commands and round values not at half-degree increments",
function()
test.timer.__create_and_queue_test_time_advance_timer(1, "oneshot")

test.socket.zwave:__queue_receive(
{
mock_device.id,
zw_test_utilities.zwave_test_build_receive_command(
ThermostatSetpoint:Report(
{
setpoint_type = ThermostatSetpoint.setpoint_type.HEATING_1,
scale = 1,
value = 68
})
)
}
)
test.socket.capability:__expect_send(
mock_device:generate_test_message("main",
capabilities.thermostatHeatingSetpoint.heatingSetpoint({ value = 68, unit = "F" })
)
)
test.wait_for_events()

test.socket.capability:__queue_receive({ mock_device.id, { capability = "thermostatHeatingSetpoint", command = "setHeatingSetpoint", args = { 70.2 } } })
test.socket.zwave:__expect_send(
zw_test_utilities.zwave_test_build_send_command(
mock_device,
ThermostatSetpoint:Set({
setpoint_type = ThermostatSetpoint.setpoint_type.HEATING_1,
value = 70,
precision = 0,
size = 1,
scale = 1,
})
)
)
test.wait_for_events()

test.mock_time.advance_time(1)
test.socket.zwave:__expect_send(
zw_test_utilities.zwave_test_build_send_command(
mock_device,
ThermostatSetpoint:Get({
setpoint_type = ThermostatSetpoint.setpoint_type.HEATING_1
})
)
)
end
)

test.run_registered_tests()
Loading