Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -481,4 +481,88 @@ test.register_message_test(
}
)

local ControlSequenceOfOperation = clusters.Thermostat.attributes.ControlSequenceOfOperation
test.register_message_test(
"Room AC control sequence reports should generate correct messages",
{
{
channel = "matter",
direction = "receive",
message = {
mock_device.id,
ControlSequenceOfOperation:build_test_report_data(mock_device, 1, ControlSequenceOfOperation.COOLING_AND_HEATING_WITH_REHEAT)
}
},
{
channel = "capability",
direction = "send",
message = mock_device:generate_test_message("main", capabilities.thermostatMode.supportedThermostatModes({"cool", "heat"}, {visibility={displayed=false}}))
},
{
channel = "matter",
direction = "receive",
message = {
mock_device.id,
ControlSequenceOfOperation:build_test_report_data(mock_device, 1, ControlSequenceOfOperation.HEATING_WITH_REHEAT)
}
},
{
channel = "capability",
direction = "send",
message = mock_device:generate_test_message("main", capabilities.thermostatMode.supportedThermostatModes({"heat"}, {visibility={displayed=false}}))
},
{
channel = "matter",
direction = "receive",
message = {
mock_device.id,
ControlSequenceOfOperation:build_test_report_data(mock_device, 1, ControlSequenceOfOperation.COOLING_WITH_REHEAT)
}
},
{
channel = "capability",
direction = "send",
message = mock_device:generate_test_message("main", capabilities.thermostatMode.supportedThermostatModes({"cool"}, {visibility={displayed=false}}))
},
}
)

test.register_message_test(
"Additional mode reports should extend the supported modes",
{
{
channel = "matter",
direction = "receive",
message = {
mock_device.id,
clusters.Thermostat.server.attributes.ControlSequenceOfOperation:build_test_report_data(mock_device, 1, 5)
}
},
{
channel = "capability",
direction = "send",
message = mock_device:generate_test_message("main", capabilities.thermostatMode.supportedThermostatModes({"cool", "heat"}, {visibility={displayed=false}}))
},
{
channel = "matter",
direction = "receive",
message = {
mock_device.id,
clusters.Thermostat.server.attributes.SystemMode:build_test_report_data(mock_device, 1, 5)
}
},
{
channel = "capability",
direction = "send",
message = mock_device:generate_test_message("main", capabilities.thermostatMode.supportedThermostatModes({"cool", "heat", "emergency heat"}, {visibility={displayed=false}}))
},
{
channel = "capability",
direction = "send",
message = mock_device:generate_test_message("main", capabilities.thermostatMode.thermostatMode.emergency_heat())
}
}
)


test.run_registered_tests()
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,13 @@ end
function AttributeHandlers.control_sequence_of_operation_handler(driver, device, ib, response)
-- The ControlSequenceOfOperation attribute only directly specifies what can't be operated by the operating environment, not what can.
-- However, we assert here that a Cooling enum value implies that SystemMode supports cooling, and the same for a Heating enum.
-- We also assert that Off is supported, though per spec this is optional.
-- We also assert that Off is supported if the switch capability is not supported, though per spec this is optional.
if device:get_field(fields.OPTIONAL_THERMOSTAT_MODES_SEEN) == nil then
device:set_field(fields.OPTIONAL_THERMOSTAT_MODES_SEEN, {capabilities.thermostatMode.thermostatMode.off.NAME}, {persist=true})
if device:supports_capability(capabilities.switch) == false then
device:set_field(fields.OPTIONAL_THERMOSTAT_MODES_SEEN, {capabilities.thermostatMode.thermostatMode.off.NAME}, {persist=true})
else
device:set_field(fields.OPTIONAL_THERMOSTAT_MODES_SEEN, {}, {persist=true})
end
end
local supported_modes = st_utils.deep_copy(device:get_field(fields.OPTIONAL_THERMOSTAT_MODES_SEEN))
local disallowed_mode_operations = {}
Expand Down
Loading