27
27
from chip .clusters .Attribute import AttributePath , TypedAttributePath
28
28
from chip .exceptions import ChipStackError
29
29
from chip .interaction_model import Status
30
- from matter_testing_support import MatterBaseTest , TestStep , async_test_body , default_matter_test_main
30
+ from matter_testing_support import AttributeChangeCallback , MatterBaseTest , TestStep , async_test_body , default_matter_test_main , EventChangeCallback
31
31
from mobly import asserts
32
32
33
33
'''
@@ -97,7 +97,6 @@ async def test_TC_IDM_4_3(self):
97
97
98
98
# Test setup
99
99
node_label_attr = Clusters .BasicInformation .Attributes .NodeLabel
100
- # node_label_attr = Clusters.OnOff
101
100
node_label_attr_path = [(0 , node_label_attr )]
102
101
TH : ChipDeviceController = self .default_controller
103
102
@@ -112,12 +111,17 @@ async def test_TC_IDM_4_3(self):
112
111
reportInterval = (3 , 5 ),
113
112
keepSubscriptions = False
114
113
)
115
-
116
-
117
114
118
115
119
116
120
117
118
+ # secs = 60
119
+ # print(f"\n\n\n\n\nTime to sleep {secs} second(s)")
120
+ # time.sleep(secs)
121
+ # print(f"Rise and shine after {secs} second(s)\n\n\n\n\n")
122
+
123
+
124
+
121
125
122
126
123
127
@@ -135,20 +139,26 @@ async def test_TC_IDM_4_3(self):
135
139
sub_th_step1a_min_interval_sec , sub_th_step1a_max_interval_sec = sub_th_step1a .GetReportingIntervalsSeconds ()
136
140
asserts .assert_is_not_none (sub_th_step1a_max_interval_sec , "MaxInterval field not present" )
137
141
138
- sub_th_step1a .Shutdown ()
142
+ # sub_th_step1a.Shutdown()
139
143
140
144
# *** Step 1b ***
141
145
# Change the value of the attribute which has been subscribed on the DUT by manually changing some
142
146
# settings on the device. Example: Temperature sensor may update the value of the room temperature.
143
147
# Turning on/off on a light bulb.
144
148
self .step ("1b" )
145
149
146
- # # Modify attribute value
147
- # new_node_label_write = "NewNodeLabel_11001100"
148
- # await TH.WriteAttribute(
149
- # self.dut_node_id,
150
- # [(0, node_label_attr(value=new_node_label_write))]
151
- # )
150
+ # Set Attribute Update Callback
151
+ node_label_update_cb = AttributeChangeCallback (node_label_attr )
152
+ sub_th_step1a .SetAttributeUpdateCallback (node_label_update_cb )
153
+
154
+ # Modify attribute value
155
+ new_node_label_write = "NewNodeLabel_11001100"
156
+ await TH .WriteAttribute (
157
+ self .dut_node_id ,
158
+ [(0 , node_label_attr (value = new_node_label_write ))]
159
+ )
160
+
161
+ node_label_update_cb .wait_for_report ()
152
162
153
163
154
164
if __name__ == "__main__" :
0 commit comments