@@ -45,14 +45,14 @@ def steps_TC_VALCC_3_1(self) -> list[TestStep]:
45
45
steps = [
46
46
TestStep (1 , "Commissioning, already done" , is_commissioning = True ),
47
47
TestStep (2 , "Set up a subscription to all attributes on the DUT" ),
48
- TestStep (2 , "Send Open command" , "DUT returns SUCCESS" ),
49
- TestStep (3 , "Wait until TH receives and data report for TargetState set to NULL and an attribute report for CurrentState set to Open (ordering does not matter)" ,
48
+ TestStep (3 , "Send Open command" , "DUT returns SUCCESS" ),
49
+ TestStep (4 , "Wait until TH receives and data report for TargetState set to NULL and an attribute report for CurrentState set to Open (ordering does not matter)" ,
50
50
"Expected attribute reports are received" ),
51
- TestStep (4 , "Read CurrentState and TargetState attribute" , "CurrentState is Open, TargetState is NULL" ),
52
- TestStep (5 , "Send Close command" , "DUT returns SUCCESS" ),
53
- TestStep (3 , "Wait until TH receives and data report for TargetState set to NULL and an attribute report for CurrentState set to Closed (ordering does not matter)" ,
51
+ TestStep (5 , "Read CurrentState and TargetState attribute" , "CurrentState is Open, TargetState is NULL" ),
52
+ TestStep (6 , "Send Close command" , "DUT returns SUCCESS" ),
53
+ TestStep (7 , "Wait until TH receives and data report for TargetState set to NULL and an attribute report for CurrentState set to Closed (ordering does not matter)" ,
54
54
"Expected attribute reports are received" ),
55
- TestStep (7 , "Read CurrentState and TargetState attribute" , "CurrentState is Closed, TargetState is NULL" ),
55
+ TestStep (8 , "Read CurrentState and TargetState attribute" , "CurrentState is Closed, TargetState is NULL" ),
56
56
]
57
57
return steps
58
58
@@ -61,73 +61,45 @@ async def test_TC_VALCC_3_1(self):
61
61
62
62
endpoint = self .matter_test_config .endpoint
63
63
64
- self .step (1 )
64
+ self .step (1 ) # commissioning - already done
65
+
66
+ self .step (2 )
65
67
cluster = Clusters .ValveConfigurationAndControl
66
68
attributes = cluster .Attributes
67
69
attribute_subscription = ClusterAttributeChangeAccumulator (cluster )
68
70
await attribute_subscription .start (self .default_controller , self .dut_node_id , endpoint )
69
71
70
- self .step (2 )
71
- try :
72
- await self .send_single_cmd (cmd = Clusters .Objects .ValveConfigurationAndControl .Commands .Open (), endpoint = endpoint )
73
- except InteractionModelError as e :
74
- asserts .assert_equal (e .status , Status .Success , "Unexpected error returned" )
75
- pass
76
-
77
72
self .step (3 )
73
+ await self .send_single_cmd (cmd = Clusters .Objects .ValveConfigurationAndControl .Commands .Open (), endpoint = endpoint )
78
74
75
+ self .step (4 )
79
76
# Wait until the current state is open and the target state is Null.
80
77
# Wait for the entire duration of the test because this valve may be slow. The test will time out before this does. That's fine.
81
78
timeout = self .matter_test_config .timeout if self .matter_test_config .timeout is not None else self .default_timeout
82
79
expected_final_state = [AttributeValue (endpoint_id = endpoint , attribute = attributes .TargetState , value = NullValue ), AttributeValue (
83
80
endpoint_id = endpoint , attribute = attributes .CurrentState , value = cluster .Enums .ValveStateEnum .kOpen )]
84
81
attribute_subscription .await_all_final_values_reported (expected_final_values = expected_final_state , timeout_sec = timeout )
85
82
86
- # Read target state first in case the current state goes to open between these calls.
87
- # The test re-reads target state after CurrentState goes to open.
88
- target_state_dut = await self .read_valcc_attribute_expect_success (endpoint = endpoint , attribute = attributes .TargetState )
89
- current_state_dut = await self .read_valcc_attribute_expect_success (endpoint = endpoint , attribute = attributes .CurrentState )
90
-
91
- while current_state_dut is cluster .Enums .ValveStateEnum .kTransitioning :
92
- asserts .assert_equal (target_state_dut , cluster .Enums .ValveStateEnum .kOpen , "TargetState is incorrect" )
93
- time .sleep (1 )
94
-
95
- target_state_dut = await self .read_valcc_attribute_expect_success (endpoint = endpoint , attribute = attributes .TargetState )
96
- current_state_dut = await self .read_valcc_attribute_expect_success (endpoint = endpoint , attribute = attributes .CurrentState )
97
- asserts .assert_true (current_state_dut is not NullValue , "CurrentState is null" )
98
- asserts .assert_true (target_state_dut is not NullValue , "TargetState is null" )
99
-
100
- self .step (4 )
101
- current_state_dut = await self .read_valcc_attribute_expect_success (endpoint = endpoint , attribute = attributes .CurrentState )
102
- asserts .assert_equal (current_state_dut , cluster .Enums .ValveStateEnum .kOpen , "CurrentState is incorrect" )
103
- target_state_dut = await self .read_valcc_attribute_expect_success (endpoint = endpoint , attribute = attributes .TargetState )
104
- asserts .assert_true (target_state_dut is NullValue , "TargetState is not null" )
105
-
106
83
self .step (5 )
107
- try :
108
- await self .send_single_cmd (cmd = Clusters .Objects .ValveConfigurationAndControl .Commands .Close (), endpoint = endpoint )
109
- except InteractionModelError as e :
110
- asserts .assert_equal (e .status , Status .Success , "Unexpected error returned" )
111
- pass
112
-
113
- self .step (6 )
114
84
target_state_dut = await self .read_valcc_attribute_expect_success (endpoint = endpoint , attribute = attributes .TargetState )
115
85
current_state_dut = await self .read_valcc_attribute_expect_success (endpoint = endpoint , attribute = attributes .CurrentState )
86
+ asserts .assert_equal (current_state_dut , cluster .Enums .ValveStateEnum .kOpen , "CurrentState is not open" )
87
+ asserts .assert_equal (target_state_dut , NullValue , "TargetState is not null" )
116
88
117
- while current_state_dut is cluster .Enums .ValveStateEnum .kTransitioning :
118
- asserts .assert_equal (target_state_dut , cluster .Enums .ValveStateEnum .kClosed , "TargetState is incorrect" )
119
- time .sleep (1 )
120
-
121
- target_state_dut = await self .read_valcc_attribute_expect_success (endpoint = endpoint , attribute = attributes .TargetState )
122
- current_state_dut = await self .read_valcc_attribute_expect_success (endpoint = endpoint , attribute = attributes .CurrentState )
123
- asserts .assert_true (current_state_dut is not NullValue , "CurrentState is null" )
124
- asserts .assert_true (target_state_dut is not NullValue , "TargetState is null" )
89
+ self .step (6 )
90
+ attribute_subscription .reset ()
91
+ await self .send_single_cmd (cmd = Clusters .Objects .ValveConfigurationAndControl .Commands .Close (), endpoint = endpoint )
125
92
126
93
self .step (7 )
127
- current_state_dut = await self .read_valcc_attribute_expect_success (endpoint = endpoint , attribute = attributes .CurrentState )
128
- asserts .assert_equal (current_state_dut , cluster .Enums .ValveStateEnum .kClosed , "CurrentState is incorrect" )
94
+ expected_final_state = [AttributeValue (endpoint_id = endpoint , attribute = attributes .TargetState , value = NullValue ), AttributeValue (
95
+ endpoint_id = endpoint , attribute = attributes .CurrentState , value = cluster .Enums .ValveStateEnum .kClosed )]
96
+ attribute_subscription .await_all_final_values_reported (expected_final_values = expected_final_state , timeout_sec = timeout )
97
+
98
+ self .step (8 )
129
99
target_state_dut = await self .read_valcc_attribute_expect_success (endpoint = endpoint , attribute = attributes .TargetState )
130
- asserts .assert_true (target_state_dut is NullValue , "TargetState is not null" )
100
+ current_state_dut = await self .read_valcc_attribute_expect_success (endpoint = endpoint , attribute = attributes .CurrentState )
101
+ asserts .assert_equal (current_state_dut , cluster .Enums .ValveStateEnum .kClosed , "CurrentState is not closed" )
102
+ asserts .assert_equal (target_state_dut , NullValue , "TargetState is not null" )
131
103
132
104
133
105
if __name__ == "__main__" :
0 commit comments