Skip to content

Commit 3634532

Browse files
committed
Spec parsing: Add global commands for thermostat
1 parent e96ddd9 commit 3634532

File tree

2 files changed

+47
-0
lines changed

2 files changed

+47
-0
lines changed

src/python_testing/TestSpecParsingSupport.py

+26
Original file line numberDiff line numberDiff line change
@@ -462,6 +462,32 @@ def test_provisional_clusters(self):
462462
asserts.assert_in(id, clusters.keys(), "Non-provisional cluster not parsed")
463463
asserts.assert_false(clusters[id].is_provisional, "Non-provisional cluster marked as provisional")
464464

465+
def test_atomic_thermostat(self):
466+
tot_xml_clusters, problems = build_xml_clusters(PrebuiltDataModelDirectory.kMaster)
467+
one_three_clusters, problems = build_xml_clusters(PrebuiltDataModelDirectory.k1_3)
468+
in_progress, problems = build_xml_clusters(PrebuiltDataModelDirectory.kInProgress)
469+
470+
asserts.assert_in("Atomic Request", tot_xml_clusters[Clusters.Thermostat.id].command_map,
471+
"Atomic request not found on thermostat command map")
472+
request_id = tot_xml_clusters[Clusters.Thermostat.id].command_map["Atomic Request"]
473+
asserts.assert_in(request_id, tot_xml_clusters[Clusters.Thermostat.id].accepted_commands.keys(),
474+
"Atomic request not found in thermostat accepted command list")
475+
476+
asserts.assert_in("Atomic Response", tot_xml_clusters[Clusters.Thermostat.id].command_map,
477+
"Atomic response not found in the thermostat command map")
478+
response_id = tot_xml_clusters[Clusters.Thermostat.id].command_map["Atomic Response"]
479+
asserts.assert_in(response_id, tot_xml_clusters[Clusters.Thermostat.id].generated_commands.keys(),
480+
"Atomic response not found in thermostat generated command list")
481+
482+
asserts.assert_not_in(
483+
"Atomic Request", one_three_clusters[Clusters.Thermostat.id].command_map, "Atomic request found on thermostat command map for 1.3")
484+
asserts.assert_not_in(request_id, one_three_clusters[Clusters.Thermostat.id].accepted_commands.keys(),
485+
"Atomic request found in thermostat accepted command list for 1.3")
486+
asserts.assert_not_in(
487+
"Atomic Response", one_three_clusters[Clusters.Thermostat.id].command_map, "Atomic response found on thermostat command map for 1.3")
488+
asserts.assert_not_in(response_id, one_three_clusters[Clusters.Thermostat.id].generated_commands.keys(),
489+
"Atomic request found in thermostat generated command list for 1.3")
490+
465491

466492
if __name__ == "__main__":
467493
default_matter_test_main()

src/python_testing/spec_parsing_support.py

+21
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@
2626
from typing import Callable, Optional
2727

2828
import chip.clusters as Clusters
29+
import conformance_support
30+
2931
from chip.tlv import uint
3032
from conformance_support import (OPTIONAL_CONFORM, TOP_LEVEL_CONFORMANCE_TAGS, ConformanceDecision, ConformanceException,
3133
ConformanceParseParameters, feature, is_disallowed, mandatory, optional, or_operation,
@@ -611,6 +613,25 @@ def remove_problem(location: typing.Union[CommandPathLocation, FeaturePathLocati
611613
0x05: XmlAttribute(name='SupportedTemperatureLevels', datatype='list', conformance=feature(0x02, 'TL'), read_access=view, write_access=none, write_optional=False),
612614
}
613615

616+
# TODO: Need automated parsing for atomic attributes.
617+
atomic_request_cmd_id = 0xFE
618+
atomic_response_cmd_id = 0xFD
619+
atomic_request_name = "Atomic Request"
620+
atomic_response_name = "Atomic Response"
621+
presets_name = "Presets"
622+
schedules_name = "Schedules"
623+
if clusters[Clusters.Thermostat.id].revision >= 8:
624+
presents_id = clusters[Clusters.Thermostat.id].attribute_map[presets_name]
625+
schedules_id = clusters[Clusters.Thermostat.id].attribute_map[schedules_name]
626+
conformance = or_operation([conformance_support.attribute(presents_id, presets_name),
627+
conformance_support.attribute(schedules_id, schedules_name)])
628+
clusters[Clusters.Thermostat.id].accepted_commands[atomic_request_cmd_id] = XmlCommand(
629+
id=atomic_request_cmd_id, name=atomic_request_name, conformance=conformance)
630+
clusters[Clusters.Thermostat.id].generated_commands[atomic_response_cmd_id] = XmlCommand(
631+
id=atomic_response_cmd_id, name=atomic_response_name, conformance=conformance)
632+
clusters[Clusters.Thermostat.id].command_map[atomic_request_name] = atomic_request_cmd_id
633+
clusters[Clusters.Thermostat.id].command_map[atomic_response_name] = atomic_response_cmd_id
634+
614635
check_clusters_for_unknown_commands(clusters, problems)
615636

616637
return clusters, problems

0 commit comments

Comments
 (0)