16
16
#
17
17
# === BEGIN CI TEST ARGUMENTS ===
18
18
# test-runner-runs: run1
19
- # test-runner-run/run1/app: ${TYPE_OF_APP }
19
+ # test-runner-run/run1/app: ${ALL_CLUSTERS_APP }
20
20
# test-runner-run/run1/factoryreset: True
21
21
# test-runner-run/run1/quiet: True
22
22
# test-runner-run/run1/app-args: --discriminator 1234 --KVS kvs1 --trace-to json:${TRACE_APP}.json
23
- # test-runner-run/run1/script-args: --storage-path admin_storage.json --commissioning-method on-network --discriminator 1234 --passcode 20202021 --trace-to json:${TRACE_TEST_JSON}.json --trace-to perfetto:${TRACE_TEST_PERFETTO}.perfetto
23
+ # test-runner-run/run1/script-args: --storage-path admin_storage.json --commissioning-method on-network --discriminator 1234 --passcode 20202021 --trace-to json:${TRACE_TEST_JSON}.json --trace-to perfetto:${TRACE_TEST_PERFETTO}.perfetto --endpoint 1
24
24
# === END CI TEST ARGUMENTS ===
25
25
# There are CI issues to be followed up for the test cases below that implements manually controlling sensor device for
26
26
# the occupancy state ON/OFF change.
29
29
30
30
import logging
31
31
import time
32
+ from typing import Any , Optional
32
33
33
34
import chip .clusters as Clusters
34
- from chip import ChipDeviceCtrl
35
35
from chip .interaction_model import Status
36
36
from matter_testing_support import MatterBaseTest , TestStep , async_test_body , default_matter_test_main
37
37
from mobly import asserts
38
38
39
39
40
40
class TC_OCC_3_1 (MatterBaseTest ):
41
- async def read_occ_attribute_expect_success (self , endpoint , attribute ):
41
+ async def read_occ_attribute_expect_success (self , attribute ):
42
42
cluster = Clusters .Objects .OccupancySensing
43
+ endpoint = self .matter_test_config .endpoint
43
44
return await self .read_single_attribute_check_success (endpoint = endpoint , cluster = cluster , attribute = attribute )
44
45
46
+ async def write_hold_time (self , hold_time : Optional [Any ]) -> Status :
47
+ dev_ctrl = self .default_controller
48
+ node_id = self .dut_node_id
49
+ endpoint = self .matter_test_config .endpoint
50
+
51
+ cluster = Clusters .OccupancySensing
52
+ write_result = await dev_ctrl .WriteAttribute (node_id , [(endpoint , cluster .Attributes .HoldTime (hold_time ))])
53
+ return write_result [0 ].Status
54
+
45
55
def desc_TC_OCC_3_1 (self ) -> str :
46
56
return "[TC-OCC-3.1] Primary functionality with server as DUT"
47
57
@@ -63,58 +73,56 @@ def pics_TC_OCC_3_1(self) -> list[str]:
63
73
64
74
@async_test_body
65
75
async def test_TC_OCC_3_1 (self ):
66
-
67
- endpoint = self .user_params .get ("endpoint" , 1 )
68
- node_id = self .matter_test_config .dut_node_ids [0 ]
69
76
hold_time = 10 # 10 seconds for occupancy state hold time
70
77
71
78
self .step (1 ) # commissioning and getting cluster attribute list
72
- attributes = Clusters .OccupancySensing .Attributes
73
- attribute_list = await self .read_occ_attribute_expect_success (endpoint = endpoint , attribute = attributes .AttributeList )
79
+ cluster = Clusters .OccupancySensing
80
+ attributes = cluster .Attributes
81
+ attribute_list = await self .read_occ_attribute_expect_success (attribute = attributes .AttributeList )
74
82
75
- self .step (2 )
76
- if attributes .HoldTime .attribute_id in attribute_list :
77
- # write 10 as a HoldTime attibute
78
- write_res = await ChipDeviceCtrl .WriteAttribute (node_id , [(endpoint , attributes .HoldTime (hold_time ))])
79
- asserts .assert_equal (write_res [0 ].status , Status .Success , "Write HoldTime failed" )
83
+ has_hold_time = attributes .HoldTime .attribute_id in attribute_list
80
84
85
+ self .step (2 )
86
+ if has_hold_time :
87
+ # write 10 as a HoldTime attribute
88
+ await self .write_single_attribute (cluster .Attributes .HoldTime (hold_time ))
81
89
else :
82
90
logging .info ("No HoldTime attribute supports. Will test only occupancy attribute triggering functionality" )
83
91
84
92
self .step (3 )
85
93
# check if Occupancy attribute is 0
86
- occupancy_dut = await self .read_occ_attribute_expect_success (endpoint = endpoint , attribute = attributes .Occupancy )
94
+ occupancy_dut = await self .read_occ_attribute_expect_success (attribute = attributes .Occupancy )
87
95
88
96
# if occupancy is on, then wait until the sensor occupancy state is 0.
89
97
if occupancy_dut == 1 :
90
98
# Don't trigger occupancy sensor to render occupancy attribute to 0
91
- if attributes . HoldTime . attribute_id in attribute_list :
92
- time .sleep (hold_time + 2 ) # add some extra 2 seconds to ensure hold time has passed.
99
+ if has_hold_time :
100
+ time .sleep (hold_time + 2.0 ) # add some extra 2 seconds to ensure hold time has passed.
93
101
else : # a user wait until a sensor specific time to change occupancy attribute to 0. This is the case where the sensor doesn't support HoldTime.
94
102
self .wait_for_user_input (
95
103
prompt_msg = "Type any letter and press ENTER after the sensor occupancy is detection ready state (occupancy attribute = 0)" )
96
104
97
105
# check sensor occupancy state is 0 for the next test step
98
- occupancy_dut = await self .read_occ_attribute_expect_success (endpoint = endpoint , attribute = attributes .Occupancy )
106
+ occupancy_dut = await self .read_occ_attribute_expect_success (attribute = attributes .Occupancy )
99
107
asserts .assert_equal (occupancy_dut , 0 , "Occupancy attribute is still 1." )
100
108
101
109
self .step (4 )
102
110
# Trigger occupancy sensor to change Occupancy attribute value to 1 => TESTER ACTION on DUT
103
111
self .wait_for_user_input (prompt_msg = "Type any letter and press ENTER after a sensor occupancy is triggered." )
104
112
105
113
# And then check if Occupancy attribute has changed.
106
- occupancy_dut = await self .read_occ_attribute_expect_success (endpoint = endpoint , attribute = attributes .Occupancy )
114
+ occupancy_dut = await self .read_occ_attribute_expect_success (attribute = attributes .Occupancy )
107
115
asserts .assert_equal (occupancy_dut , 1 , "Occupancy state is not changed to 1" )
108
116
109
117
self .step (5 )
110
118
# check if Occupancy attribute is back to 0 after HoldTime attribute period
111
119
# Tester should not be triggering the sensor for this test step.
112
- if attributes . HoldTime . attribute_id in attribute_list :
120
+ if has_hold_time :
113
121
114
122
# Start a timer based on HoldTime
115
- time .sleep (hold_time + 2 ) # add some extra 2 seconds to ensure hold time has passed.
123
+ time .sleep (hold_time + 2.0 ) # add some extra 2 seconds to ensure hold time has passed.
116
124
117
- occupancy_dut = await self .read_occ_attribute_expect_success (endpoint = endpoint , attribute = attributes .Occupancy )
125
+ occupancy_dut = await self .read_occ_attribute_expect_success (attribute = attributes .Occupancy )
118
126
asserts .assert_equal (occupancy_dut , 0 , "Occupancy state is not 0 after HoldTime period" )
119
127
120
128
else :
0 commit comments