diff --git a/src/python_testing/TC_DEM_2_2.py b/src/python_testing/TC_DEM_2_2.py index 6bc2348fa8f738..ac0f0d96bf54dc 100644 --- a/src/python_testing/TC_DEM_2_2.py +++ b/src/python_testing/TC_DEM_2_2.py @@ -61,86 +61,88 @@ def pics_TC_DEM_2_2(self): def steps_TC_DEM_2_2(self) -> list[TestStep]: """Execute the test steps.""" steps = [ - TestStep("1", "Commissioning, already done", - is_commissioning=True), - TestStep("2", "TH reads TestEventTriggersEnabled attribute from General Diagnostics Cluster.", - "Verify that TestEventTriggersEnabled attribute has a value of 1 (True)"), - TestStep("3", "TH sends TestEventTrigger command to General Diagnostics Cluster on Endpoint 0 with EnableKey field set to PIXIT.DEM.TEST_EVENT_TRIGGER_KEY and EventTrigger field set to PIXIT.DEM.TEST_EVENT_TRIGGER for Power Adjustment Test Event", - "Verify DUT responds with status SUCCESS(0x00)"), - TestStep("3a", "TH reads ESAState attribute.", - "Verify value is 0x01 (Online)"), - TestStep("3b", "TH reads PowerAdjustmentCapability attribute.", + TestStep("1", "Commission DUT to TH (can be skipped if done in a preceding test)"), + TestStep("2", "TH reads from the DUT the _Featuremap_ attribute", + "Verify that the DUT response contains the _Featuremap_ attribute. Verify PowerAdjustment is supported."), + TestStep("3", "Set up a subscription to all DeviceEnergyManagement cluster events"), + TestStep("4", "TH reads TestEventTriggersEnabled attribute from General Diagnostics Cluster", + "Value has to be 1 (True)"), + TestStep("5", "TH sends TestEventTrigger command to General Diagnostics Cluster on Endpoint 0 with EnableKey field set to PIXIT.DEM.TEST_EVENT_TRIGGER_KEY and EventTrigger field set to PIXIT.DEM.TEST_EVENT_TRIGGER for Power Adjustment Test Event", + "Verify DUT responds w/ status SUCCESS(0x00)"), + TestStep("5a", "TH reads from the DUT the ESAState", + "Value has to be 0x01 (Online)"), + TestStep("5b", "TH reads from the DUT the PowerAdjustmentCapability", "Value has to include Cause=NoAdjustment. Note value for later. Determine the OverallMaxPower and OverallMaxDuration as the largest MaxPower and MaxDuration of the PowerAdjustStructs returned, and similarly the OverallMinPower and OverallMinDuration as the smallest of the MinPower and MinDuration values."), - TestStep("3c", "TH reads OptOutState attribute.", - "Verify value is 0x00 (NoOptOut)"), - TestStep("4", "TH sends PowerAdjustRequest with Power=PowerAdjustmentCapability[0].MaxPower, Duration=PowerAdjustmentCapability[0].MinDuration, Cause=LocalOptimization.", - "Verify DUT responds with status SUCCESS(0x00) and Event DEM.S.E00(PowerAdjustStart) sent"), - TestStep("4a", "TH reads ESAState attribute.", - "Verify value is 0x04 (PowerAdjustActive)"), - TestStep("4b", "TH reads PowerAdjustmentCapability attribute.", + TestStep("5c", "TH reads from the DUT the OptOutState", + "Value has to be 0x00 (NoOptOut)"), + TestStep("6", "TH sends command PowerAdjustRequest with Power=PowerAdjustmentCapability[0].MaxPower, Duration=PowerAdjustmentCapability[0].MinDuration, Cause=LocalOptimization", + "Verify DUT responds w/ status SUCCESS(0x00) and Event DEM.S.E00(PowerAdjustStart) sent"), + TestStep("6a", "TH reads from the DUT the ESAState", + "Value has to be 0x04 (PowerAdjustActive)"), + TestStep("6b", "TH reads from the DUT the PowerAdjustmentCapability", "Value has to include Cause=LocalOptimizationAdjustment."), - TestStep("5", "TH sends CancelPowerAdjustRequest.", - "Verify DUT responds with status SUCCESS(0x00) and Event DEM.S.E01(PowerAdjustEnd) sent with Cause=Cancelled"), - TestStep("5a", "TH reads PowerAdjustmentCapability attribute.", + TestStep("7", "TH sends command CancelPowerAdjustRequest", + "Verify DUT responds w/ status SUCCESS(0x00) and Event DEM.S.E01(PowerAdjustEnd) sent with Cause=Cancelled"), + TestStep("7a", "TH reads from the DUT the PowerAdjustmentCapability", "Value has to include Cause=NoAdjustment."), - TestStep("5b", "TH reads ESAState attribute.", - "Verify value is 0x01 (Online)"), - TestStep("6", "TH sends CancelPowerAdjustRequest.", - "Verify DUT responds with status INVALID_IN_STATE(0xcb)"), - TestStep("7", "TH sends PowerAdjustRequest with Power=OverallMaxPower+1 Duration=OverallMinDuration Cause=LocalOptimization.", - "Verify DUT responds with status CONSTRAINT_ERROR(0x87)"), - TestStep("8", "TH sends PowerAdjustRequest with Power=OverallMinPower Duration=OverallMaxDuration+1 Cause=LocalOptimization.", - "Verify DUT responds with status CONSTRAINT_ERROR(0x87)"), - TestStep("9", "TH sends PowerAdjustRequest with Power=OverallMinPower-1 Duration=OverallMaxDuration Cause=LocalOptimization.", - "Verify DUT responds with status CONSTRAINT_ERROR(0x87)"), - TestStep("10", "TH sends PowerAdjustRequest with Power=OverallMaxPower Duration=OverallMinDuration-1 Cause=LocalOptimization.", - "Verify DUT responds with status CONSTRAINT_ERROR(0x87)"), - TestStep("11", "TH sends PowerAdjustRequest with Power=PowerAdjustmentCapability[0].MaxPower, Duration=PowerAdjustmentCapability[0].MinDuration, Cause=LocalOptimization.", - "Verify DUT responds with status SUCCESS(0x00) and event DEM.S.E00(PowerAdjustStart) sent"), - TestStep("11a", "TH reads PowerAdjustmentCapability attribute.", + TestStep("7b", "TH reads from the DUT the ESAState", + "Value has to be 0x01 (Online)"), + TestStep("8", "TH sends command CancelPowerAdjustRequest", + "Verify DUT responds w/ status INVALID_IN_STATE(0xcb)"), + TestStep("9", "TH sends command PowerAdjustRequest with Power=OverallMaxPower+1 Duration=OverallMinDuration Cause=LocalOptimization", + "Verify DUT responds w/ status CONSTRAINT_ERROR(0x87)"), + TestStep("10", "TH sends command PowerAdjustRequest with Power=OverallMinPower Duration=OverallMaxDuration+1 Cause=LocalOptimization", + "Verify DUT responds w/ status CONSTRAINT_ERROR(0x87)"), + TestStep("11", "TH sends command PowerAdjustRequest with Power=OverallMinPower-1 Duration=OverallMaxDuration Cause=LocalOptimization", + "Verify DUT responds w/ status CONSTRAINT_ERROR(0x87)"), + TestStep("12", "TH sends command PowerAdjustRequest with Power=OverallMaxPower Duration=OverallMinDuration-1 Cause=LocalOptimization", + "Verify DUT responds w/ status CONSTRAINT_ERROR(0x87)"), + TestStep("13", "TH sends command PowerAdjustRequest with Power=PowerAdjustmentCapability[0].MaxPower, Duration=PowerAdjustmentCapability[0].MinDuration, Cause=LocalOptimization", + "Verify DUT responds w/ status SUCCESS(0x00) and event DEM.S.E00(PowerAdjustStart) sent"), + TestStep("13a", "TH reads from the DUT the PowerAdjustmentCapability", "Value has to include Cause=LocalOptimizationAdjustment."), - TestStep("12", "TH sends PowerAdjustRequest with Power=PowerAdjustmentCapability[0].MaxPower, Duration=PowerAdjustmentCapability[0].MinDuration, Cause=GridOptimization.", - "Verify DUT responds with status SUCCESS(0x00) and no event sent"), - TestStep("12a", "TH reads ESAState attribute.", - "Verify value is 0x04 (PowerAdjustActive)"), - TestStep("12b", "TH reads PowerAdjustmentCapability attribute.", + TestStep("14", "TH sends command PowerAdjustRequest with Power=PowerAdjustmentCapability[0].MaxPower, Duration=PowerAdjustmentCapability[0].MinDuration, Cause=GridOptimization", + "Verify DUT responds w/ status SUCCESS(0x00) and no event sent"), + TestStep("14a", "TH reads from the DUT the ESAState", + "Value has to be 0x04 (PowerAdjustActive)"), + TestStep("14b", "TH reads from the DUT the PowerAdjustmentCapability", "Value has to include Cause=GridOptimizationAdjustment."), - TestStep("13", "TH sends TestEventTrigger command to General Diagnostics Cluster on Endpoint 0 with EnableKey field set to PIXIT.DEM.TEST_EVENT_TRIGGER_KEY and EventTrigger field set to PIXIT.DEM.TEST_EVENT_TRIGGER for User Opt-out Local Optimization Test Event.", - "Verify DUT responds with status SUCCESS(0x00) and no event sent"), - TestStep("13a", "TH reads ESAState attribute.", - "Verify value is 0x04 (PowerAdjustActive)"), - TestStep("13b", "TH reads OptOutState attribute.", - "Verify value is 0x02 (LocalOptOut)"), - TestStep("14", "TH sends PowerAdjustRequest with Power=PowerAdjustmentCapability[0].MaxPower, Duration=PowerAdjustmentCapability[0].MinDuration, Cause=LocalOptimization.", - "Verify DUT responds with status CONSTRAINT_ERROR(0x87)"), - TestStep("15", "TH sends TestEventTrigger command to General Diagnostics Cluster on Endpoint 0 with EnableKey field set to PIXIT.DEM.TEST_EVENT_TRIGGER_KEY and EventTrigger field set to PIXIT.DEM.TEST_EVENT_TRIGGER for User Opt-out Grid Optimization Test Event.", - "Verify DUT responds with status SUCCESS(0x00) and event DEM.S.E01(PowerAdjustEnd) sent with Cause=UserOptOut, Duration= approx time from step 11 to step 15, EnergyUse= a valid value"), - TestStep("15a", "TH reads ESAState attribute.", - "Verify value is 0x01 (Online)"), - TestStep("15b", "TH reads OptOutState attribute.", - "Verify value is 0x03 (OptOut)"), - TestStep("15c", "TH reads PowerAdjustmentCapability attribute.", + TestStep("15", "TH sends TestEventTrigger command to General Diagnostics Cluster on Endpoint 0 with EnableKey field set to PIXIT.DEM.TEST_EVENT_TRIGGER_KEY and EventTrigger field set to PIXIT.DEM.TEST_EVENT_TRIGGER for User Opt-out Local Optimization Test Event", + "Verify DUT responds w/ status SUCCESS(0x00) and no event sent"), + TestStep("15a", "TH reads from the DUT the ESAState", + "Value has to be 0x04 (PowerAdjustActive)"), + TestStep("15b", "TH reads from the DUT the OptOutState", + "Value has to be 0x02 (LocalOptOut)"), + TestStep("16", "TH sends command PowerAdjustRequest with Power=PowerAdjustmentCapability[0].MaxPower, Duration=PowerAdjustmentCapability[0].MinDuration, Cause=LocalOptimization", + "Verify DUT responds w/ status CONSTRAINT_ERROR(0x87)"), + TestStep("17", "TH sends TestEventTrigger command to General Diagnostics Cluster on Endpoint 0 with EnableKey field set to PIXIT.DEM.TEST_EVENT_TRIGGER_KEY and EventTrigger field set to PIXIT.DEM.TEST_EVENT_TRIGGER for User Opt-out Grid Optimization Test Event", + "Verify DUT responds w/ status SUCCESS(0x00) and event DEM.S.E01(PowerAdjustEnd) sent with Cause=UserOptOut, Duration= approx time from step 11 to step 15, EnergyUse= a valid value"), + TestStep("17a", "TH reads from the DUT the ESAState", + "Value has to be 0x01 (Online)"), + TestStep("17b", "TH reads from the DUT the OptOutState", + "Value has to be 0x03 (OptOut)"), + TestStep("17c", "TH reads from the DUT the PowerAdjustmentCapability", "Value has to include Cause=NoAdjustment."), - TestStep("16", "TH sends TestEventTrigger command to General Diagnostics Cluster on Endpoint 0 with EnableKey field set to PIXIT.DEM.TEST_EVENT_TRIGGER_KEY and EventTrigger field set to PIXIT.DEM.TEST_EVENT_TRIGGER for User Opt-out Test Event Clear", - "Verify DUT responds with status SUCCESS(0x00)"), - TestStep("16a", "TH reads ESAState attribute.", - "Verify value is 0x01 (Online)"), - TestStep("16b", "TH reads OptOutState attribute.", - "Verify value is 0x00 (NoOptOut)"), - TestStep("17", "TH sends PowerAdjustRequest with Power=PowerAdjustmentCapability[0].MaxPower, Duration=PowerAdjustmentCapability[0].MinDuration, Cause=LocalOptimization.", - "Verify DUT responds with status SUCCESS(0x00) and event DEM.S.E00(PowerAdjustStart) sent"), - TestStep("17a", "TH reads ESAState attribute.", - "Verify value is 0x04 (PowerAdjustActive)"), - TestStep("17b", "TH reads PowerAdjustmentCapability attribute.", + TestStep("18", "TH sends TestEventTrigger command to General Diagnostics Cluster on Endpoint 0 with EnableKey field set to PIXIT.DEM.TEST_EVENT_TRIGGER_KEY and EventTrigger field set to PIXIT.DEM.TEST_EVENT_TRIGGER for User Opt-out Test Event Clear", + "Verify DUT responds w/ status SUCCESS(0x00)"), + TestStep("18a", "TH reads from the DUT the ESAState", + "Value has to be 0x01 (Online)"), + TestStep("18b", "TH reads from the DUT the OptOutState", + "Value has to be 0x00 (NoOptOut)"), + TestStep("19", "TH sends command PowerAdjustRequest with Power=PowerAdjustmentCapability[0].MaxPower, Duration=PowerAdjustmentCapability[0].MinDuration, Cause=LocalOptimization", + "Verify DUT responds w/ status SUCCESS(0x00) and event DEM.S.E00(PowerAdjustStart) sent"), + TestStep("19a", "TH reads from the DUT the ESAState", + "Value has to be 0x04 (PowerAdjustActive)"), + TestStep("19b", "TH reads from the DUT the PowerAdjustmentCapability", "Value has to include Cause=LocalOptimizationAdjustment."), - TestStep("18", "Wait 10 seconds.", + TestStep("20", "Wait 10 seconds", "Event DEM.S.E01(PowerAdjustEnd) sent with Cause=NormalCompletion, Duration=10s, EnergyUse= a valid value"), - TestStep("18a", "TH reads ESAState attribute.", - "Verify value is 0x01 (Online)"), - TestStep("18b", "TH reads PowerAdjustmentCapability attribute.", + TestStep("20a", "TH reads from the DUT the ESAState", + "Value has to be 0x01 (Online)"), + TestStep("20b", "TH reads from the DUT the PowerAdjustmentCapability", "Value has to include Cause=NoAdjustment."), - TestStep("19", "TH sends TestEventTrigger command to General Diagnostics Cluster on Endpoint 0 with EnableKey field set to PIXIT.DEM.TEST_EVENT_TRIGGER_KEY and EventTrigger field set to PIXIT.DEM.TEST_EVENT_TRIGGER for Power Adjustment Test Event Clear", - "Verify DUT responds with status SUCCESS(0x00)"), + TestStep("21", "TH sends TestEventTrigger command to General Diagnostics Cluster on Endpoint 0 with EnableKey field set to PIXIT.DEM.TEST_EVENT_TRIGGER_KEY and EventTrigger field set to PIXIT.DEM.TEST_EVENT_TRIGGER for Power Adjustment Test Event Clear", + "Verify DUT responds w/ status SUCCESS(0x00)"), ] return steps @@ -155,24 +157,26 @@ async def test_TC_DEM_2_2(self): self.step("1") # Commission DUT - already done + self.step("2") await self.validate_feature_map([Clusters.DeviceEnergyManagement.Bitmaps.Feature.kPowerAdjustment], []) + self.step("3") # Subscribe to Events and when they are sent push them to a queue for checking later events_callback = EventChangeCallback(Clusters.DeviceEnergyManagement) await events_callback.start(self.default_controller, self.dut_node_id, self.matter_test_config.endpoint) - self.step("2") + self.step("4") await self.check_test_event_triggers_enabled() - self.step("3") + self.step("5") await self.send_test_event_trigger_power_adjustment() - self.step("3a") + self.step("5a") await self.check_dem_attribute("ESAState", Clusters.DeviceEnergyManagement.Enums.ESAStateEnum.kOnline) - self.step("3b") + self.step("5b") powerAdjustCapabilityStruct = await self.read_dem_attribute_expect_success(attribute="PowerAdjustmentCapability") asserts.assert_greater_equal(len(powerAdjustCapabilityStruct.powerAdjustCapability), 1) logging.info(powerAdjustCapabilityStruct) @@ -194,66 +198,66 @@ async def test_TC_DEM_2_2(self): result = f"min_power {min_power} max_power {max_power} min_duration {min_duration} max_duration {max_duration}" logging.info(result) - self.step("3c") + self.step("5c") await self.check_dem_attribute("OptOutState", Clusters.DeviceEnergyManagement.Enums.OptOutStateEnum.kNoOptOut) - self.step("4") + self.step("6") await self.send_power_adjustment_command(power=powerAdjustCapabilityStruct.powerAdjustCapability[0].maxPower, duration=powerAdjustCapabilityStruct.powerAdjustCapability[0].minDuration, cause=Clusters.DeviceEnergyManagement.Enums.AdjustmentCauseEnum.kLocalOptimization) event_data = events_callback.wait_for_event_report(Clusters.DeviceEnergyManagement.Events.PowerAdjustStart) - self.step("4a") + self.step("6a") await self.check_dem_attribute("ESAState", Clusters.DeviceEnergyManagement.Enums.ESAStateEnum.kPowerAdjustActive) - self.step("4b") + self.step("6b") powerAdjustCapabilityStruct = await self.read_dem_attribute_expect_success(attribute="PowerAdjustmentCapability") asserts.assert_greater_equal(len(powerAdjustCapabilityStruct.powerAdjustCapability), 1) asserts.assert_equal(powerAdjustCapabilityStruct.cause, Clusters.DeviceEnergyManagement.Enums.PowerAdjustReasonEnum.kLocalOptimizationAdjustment) - self.step("5") + self.step("7") await self.send_cancel_power_adjustment_command() event_data = events_callback.wait_for_event_report(Clusters.DeviceEnergyManagement.Events.PowerAdjustEnd) asserts.assert_equal(event_data.cause, Clusters.DeviceEnergyManagement.Enums.CauseEnum.kCancelled) - self.step("5a") + self.step("7a") powerAdjustCapabilityStruct = await self.read_dem_attribute_expect_success(attribute="PowerAdjustmentCapability") asserts.assert_equal(powerAdjustCapabilityStruct.cause, Clusters.DeviceEnergyManagement.Enums.PowerAdjustReasonEnum.kNoAdjustment) - self.step("5b") + self.step("7b") await self.check_dem_attribute("ESAState", Clusters.DeviceEnergyManagement.Enums.ESAStateEnum.kOnline) - self.step("6") + self.step("8") await self.send_cancel_power_adjustment_command(expected_status=Status.InvalidInState) - self.step("7") + self.step("9") await self.send_power_adjustment_command(power=max_power + 1, duration=min_duration, cause=Clusters.DeviceEnergyManagement.Enums.AdjustmentCauseEnum.kLocalOptimization, expected_status=Status.ConstraintError) - self.step("8") + self.step("10") await self.send_power_adjustment_command(power=min_power, duration=max_duration + 1, cause=Clusters.DeviceEnergyManagement.Enums.AdjustmentCauseEnum.kLocalOptimization, expected_status=Status.ConstraintError) - self.step("9") + self.step("11") await self.send_power_adjustment_command(power=min_power - 1, duration=max_duration, cause=Clusters.DeviceEnergyManagement.Enums.AdjustmentCauseEnum.kLocalOptimization, expected_status=Status.ConstraintError) - self.step("10") + self.step("12") await self.send_power_adjustment_command(power=max_power, duration=min_duration - 1, cause=Clusters.DeviceEnergyManagement.Enums.AdjustmentCauseEnum.kLocalOptimization, expected_status=Status.ConstraintError) - self.step("11") + self.step("13") start = datetime.datetime.now() await self.send_power_adjustment_command(power=powerAdjustCapabilityStruct.powerAdjustCapability[0].minPower, duration=min_duration, @@ -261,12 +265,12 @@ async def test_TC_DEM_2_2(self): event_data = events_callback.wait_for_event_report(Clusters.DeviceEnergyManagement.Events.PowerAdjustStart) - self.step("11a") + self.step("13a") powerAdjustCapabilityStruct = await self.read_dem_attribute_expect_success(attribute="PowerAdjustmentCapability") asserts.assert_equal(powerAdjustCapabilityStruct.cause, Clusters.DeviceEnergyManagement.Enums.PowerAdjustReasonEnum.kLocalOptimizationAdjustment) - self.step("12") + self.step("14") await self.send_power_adjustment_command(power=powerAdjustCapabilityStruct.powerAdjustCapability[0].maxPower, duration=powerAdjustCapabilityStruct.powerAdjustCapability[0].minDuration, cause=Clusters.DeviceEnergyManagement.Enums.AdjustmentCauseEnum.kGridOptimization) @@ -274,30 +278,30 @@ async def test_TC_DEM_2_2(self): # Wait 5 seconds for an event not to be reported events_callback.wait_for_event_expect_no_report(5) - self.step("12a") + self.step("14a") await self.check_dem_attribute("ESAState", Clusters.DeviceEnergyManagement.Enums.ESAStateEnum.kPowerAdjustActive) - self.step("12b") + self.step("14b") powerAdjustCapabilityStruct = await self.read_dem_attribute_expect_success(attribute="PowerAdjustmentCapability") asserts.assert_equal(powerAdjustCapabilityStruct.cause, Clusters.DeviceEnergyManagement.Enums.PowerAdjustReasonEnum.kGridOptimizationAdjustment) - self.step("13") + self.step("15") await self.send_test_event_trigger_user_opt_out_local() - self.step("13a") + self.step("15a") await self.check_dem_attribute("ESAState", Clusters.DeviceEnergyManagement.Enums.ESAStateEnum.kPowerAdjustActive) - self.step("13b") + self.step("15b") await self.check_dem_attribute("OptOutState", Clusters.DeviceEnergyManagement.Enums.OptOutStateEnum.kLocalOptOut) - self.step("14") + self.step("16") await self.send_power_adjustment_command(power=max_power, duration=powerAdjustCapabilityStruct.powerAdjustCapability[0].maxDuration, cause=Clusters.DeviceEnergyManagement.Enums.AdjustmentCauseEnum.kLocalOptimization, expected_status=Status.ConstraintError) - self.step("15") + self.step("17") await self.send_test_event_trigger_user_opt_out_grid() event_data = events_callback.wait_for_event_report(Clusters.DeviceEnergyManagement.Events.PowerAdjustEnd) asserts.assert_equal(event_data.cause, Clusters.DeviceEnergyManagement.Enums.CauseEnum.kUserOptOut) @@ -307,42 +311,42 @@ async def test_TC_DEM_2_2(self): asserts.assert_less_equal(abs(elapsed.seconds - event_data.duration), 3) asserts.assert_greater_equal(event_data.energyUse, 0) - self.step("15a") + self.step("17a") await self.check_dem_attribute("ESAState", Clusters.DeviceEnergyManagement.Enums.ESAStateEnum.kOnline) - self.step("15b") + self.step("17b") await self.check_dem_attribute("OptOutState", Clusters.DeviceEnergyManagement.Enums.OptOutStateEnum.kOptOut) - self.step("15c") + self.step("17c") powerAdjustCapabilityStruct = await self.read_dem_attribute_expect_success(attribute="PowerAdjustmentCapability") asserts.assert_equal(powerAdjustCapabilityStruct.cause, Clusters.DeviceEnergyManagement.Enums.PowerAdjustReasonEnum.kNoAdjustment) - self.step("16") + self.step("18") await self.send_test_event_trigger_user_opt_out_clear_all() - self.step("16a") + self.step("18a") await self.check_dem_attribute("ESAState", Clusters.DeviceEnergyManagement.Enums.ESAStateEnum.kOnline) - self.step("16b") + self.step("18b") await self.check_dem_attribute("OptOutState", Clusters.DeviceEnergyManagement.Enums.OptOutStateEnum.kNoOptOut) - self.step("17") + self.step("19") await self.send_power_adjustment_command(power=powerAdjustCapabilityStruct.powerAdjustCapability[0].maxPower, duration=powerAdjustCapabilityStruct.powerAdjustCapability[0].minDuration, cause=Clusters.DeviceEnergyManagement.Enums.AdjustmentCauseEnum.kLocalOptimization, expected_status=Status.Success) event_data = events_callback.wait_for_event_report(Clusters.DeviceEnergyManagement.Events.PowerAdjustStart) - self.step("17a") + self.step("19a") await self.check_dem_attribute("ESAState", Clusters.DeviceEnergyManagement.Enums.ESAStateEnum.kPowerAdjustActive) - self.step("17b") + self.step("19b") powerAdjustCapabilityStruct = await self.read_dem_attribute_expect_success(attribute="PowerAdjustmentCapability") asserts.assert_equal(powerAdjustCapabilityStruct.cause, Clusters.DeviceEnergyManagement.Enums.PowerAdjustReasonEnum.kLocalOptimizationAdjustment) - self.step("18") + self.step("20") time.sleep(10) # Allow a little tolerance checking the duration returned in the event as CI tests can run "slower" @@ -352,15 +356,15 @@ async def test_TC_DEM_2_2(self): asserts.assert_equal(event_data.cause, Clusters.DeviceEnergyManagement.Enums.CauseEnum.kNormalCompletion) asserts.assert_greater(event_data.energyUse, 0) - self.step("18a") + self.step("20a") await self.check_dem_attribute("ESAState", Clusters.DeviceEnergyManagement.Enums.ESAStateEnum.kOnline) - self.step("18b") + self.step("20b") powerAdjustCapabilityStruct = await self.read_dem_attribute_expect_success(attribute="PowerAdjustmentCapability") asserts.assert_equal(powerAdjustCapabilityStruct.cause, Clusters.DeviceEnergyManagement.Enums.PowerAdjustReasonEnum.kNoAdjustment) - self.step("19") + self.step("21") await self.send_test_event_trigger_power_adjustment_clear() diff --git a/src/python_testing/TC_DEM_2_3.py b/src/python_testing/TC_DEM_2_3.py index c44271bd3b5d41..5287546f79ace4 100644 --- a/src/python_testing/TC_DEM_2_3.py +++ b/src/python_testing/TC_DEM_2_3.py @@ -31,7 +31,7 @@ import chip.clusters as Clusters from chip.clusters.Types import NullValue from chip.interaction_model import Status -from matter_testing_support import EventChangeCallback, MatterBaseTest, TestStep, async_test_body, default_matter_test_main +from matter_testing_support import MatterBaseTest, TestStep, async_test_body, default_matter_test_main from mobly import asserts from TC_DEMTestBase import DEMTestBase @@ -54,78 +54,79 @@ def pics_TC_DEM_2_3(self): def steps_TC_DEM_2_3(self) -> list[TestStep]: steps = [ - TestStep("1", "Commissioning, already done", - is_commissioning=True), - TestStep("2", "TH reads TestEventTriggersEnabled attribute from General Diagnostics Cluster.", - "Verify that TestEventTriggersEnabled attribute has a value of 1 (True)"), - TestStep("3", "TH sends TestEventTrigger command to General Diagnostics Cluster on Endpoint 0 with EnableKey field set to PIXIT.DEM.TEST_EVENT_TRIGGER_KEY and EventTrigger field set to PIXIT.DEM.TEST_EVENT_TRIGGER for Start Time Adjustment Test Event", - "Verify DUT responds with status SUCCESS(0x00)"), - TestStep("3a", "TH reads ESAState attribute.", - "Verify value is 0x01 (Online)"), - TestStep("3b", "TH reads Forecast attribute.", + TestStep("1", "Commission DUT to TH (can be skipped if done in a preceding test)"), + TestStep("2", "TH reads from the DUT the _Featuremap_ attribute", + "Verify that the DUT response contains the _Featuremap_ attribute. Verify StartTimeAdjustment is supported."), + TestStep("3", "TH reads TestEventTriggersEnabled attribute from General Diagnostics Cluster", + "Value has to be 1 (True)"), + TestStep("4", "TH sends TestEventTrigger command to General Diagnostics Cluster on Endpoint 0 with EnableKey field set to PIXIT.DEM.TEST_EVENT_TRIGGER_KEY and EventTrigger field set to PIXIT.DEM.TEST_EVENT_TRIGGER for Start Time Adjustment Test Event", + "Verify DUT responds w/ status SUCCESS(0x00)"), + TestStep("4a", "TH reads from the DUT the ESAState", + "Value has to be 0x01 (Online)"), + TestStep("4b", "TH reads from the DUT the Forecast", "Value has to include EarliestStartTime<=StartTime, LatestEndTime>=EndTime, and ForecastUpdateReason=Internal Optimization"), - TestStep("3c", "TH reads OptOutState attribute.", - "Verify value is 0x00 (NoOptOut)"), - TestStep("4", "TH sends TestEventTrigger command to General Diagnostics Cluster on Endpoint 0 with EnableKey field set to PIXIT.DEM.TEST_EVENT_TRIGGER_KEY and EventTrigger field set to PIXIT.DEM.TEST_EVENT_TRIGGER for User Opt-out Local Optimization Test Event", - "Verify DUT responds with status SUCCESS(0x00)"), - TestStep("4a", "TH reads ESAState attribute.", - "Verify value is 0x01 (Online)"), - TestStep("4b", "TH reads OptOutState attribute.", - "Verify value is 0x01 (LocalOptOut)"), - TestStep("5", "TH sends StartTimeAdjustRequest with RequestedStartTime=EarliestStartTime from Forecast, Cause=LocalOptimization.", - "Verify DUT responds with status CONSTRAINT_ERROR(0x87)"), - TestStep("5a", "TH reads ESAState attribute.", - "Verify value is 0x01 (Online)"), - TestStep("5b", "TH reads Forecast attribute.", + TestStep("4c", "TH reads from the DUT the OptOutState", + "Value has to be 0x00 (NoOptOut)"), + TestStep("5", "TH sends TestEventTrigger command to General Diagnostics Cluster on Endpoint 0 with EnableKey field set to PIXIT.DEM.TEST_EVENT_TRIGGER_KEY and EventTrigger field set to PIXIT.DEM.TEST_EVENT_TRIGGER for User Opt-out Local Optimization Test Event", + "Verify DUT responds w/ status SUCCESS(0x00)"), + TestStep("5a", "TH reads from the DUT the ESAState", + "Value has to be 0x01 (Online)"), + TestStep("5b", "TH reads from the DUT the OptOutState", + "Value has to be 0x01 (LocalOptOut)"), + TestStep("6", "TH sends command StartTimeAdjustRequest with RequestedStartTime=EarliestStartTime from Forecast, Cause=LocalOptimization", + "Verify DUT responds w/ status CONSTRAINT_ERROR(0x87)"), + TestStep("6a", "TH reads from the DUT the ESAState", + "Value has to be 0x01 (Online)"), + TestStep("6b", "TH reads from the DUT the Forecast", "Value has to be unchanged from step 3b"), - TestStep("6", "TH sends TestEventTrigger command to General Diagnostics Cluster on Endpoint 0 with EnableKey field set to PIXIT.DEM.TEST_EVENT_TRIGGER_KEY and EventTrigger field set to PIXIT.DEM.TEST_EVENT_TRIGGER for User Opt-out Test Event Clear", - "Verify DUT responds with status SUCCESS(0x00)"), - TestStep("6a", "TH reads ESAState attribute.", - "Verify value is 0x01 (Online)"), - TestStep("6b", "TH reads OptOutState attribute.", - "Verify value is 0x00 (NoOptOut)"), - TestStep("7", "TH sends StartTimeAdjustRequest with RequestedStartTime=EarliestStartTime from Forecast, Cause=LocalOptimization.", - "Verify DUT responds with status SUCCESS(0x00)"), - TestStep("7a", "TH reads ESAState attribute.", - "Verify value is 0x01 (Online)"), - TestStep("7b", "TH reads Forecast attribute.", + TestStep("7", "TH sends TestEventTrigger command to General Diagnostics Cluster on Endpoint 0 with EnableKey field set to PIXIT.DEM.TEST_EVENT_TRIGGER_KEY and EventTrigger field set to PIXIT.DEM.TEST_EVENT_TRIGGER for User Opt-out Test Event Clear", + "Verify DUT responds w/ status SUCCESS(0x00)"), + TestStep("7a", "TH reads from the DUT the ESAState", + "Value has to be 0x01 (Online)"), + TestStep("7b", "TH reads from the DUT the OptOutState", + "Value has to be 0x00 (NoOptOut)"), + TestStep("8", "TH sends command StartTimeAdjustRequest with RequestedStartTime=EarliestStartTime from Forecast, Cause=LocalOptimization", + "Verify DUT responds w/ status SUCCESS(0x00)"), + TestStep("8a", "TH reads from the DUT the ESAState", + "Value has to be 0x01 (Online)"), + TestStep("8b", "TH reads from the DUT the Forecast", "Value has to include EarliestStartTime=StartTime, LatestEndTime>=EndTime, and ForecastUpdateReason=Local Optimization"), - TestStep("8", "TH sends TestEventTrigger command to General Diagnostics Cluster on Endpoint 0 with EnableKey field set to PIXIT.DEM.TEST_EVENT_TRIGGER_KEY and EventTrigger field set to PIXIT.DEM.TEST_EVENT_TRIGGER for User Opt-out Local Optimization Test Event", - "Verify DUT responds with status SUCCESS(0x00)"), - TestStep("8a", "TH reads ESAState attribute.", - "Verify value is 0x01 (Online)"), - TestStep("8b", "TH reads OptOutState attribute.", - "Verify value is 0x01 (LocalOptOut)"), - TestStep("8c", "TH reads Forecast attribute.", + TestStep("9", "TH sends TestEventTrigger command to General Diagnostics Cluster on Endpoint 0 with EnableKey field set to PIXIT.DEM.TEST_EVENT_TRIGGER_KEY and EventTrigger field set to PIXIT.DEM.TEST_EVENT_TRIGGER for User Opt-out Local Optimization Test Event", + "Verify DUT responds w/ status SUCCESS(0x00)"), + TestStep("9a", "TH reads from the DUT the ESAState", + "Value has to be 0x01 (Online)"), + TestStep("9b", "TH reads from the DUT the OptOutState", + "Value has to be 0x01 (LocalOptOut)"), + TestStep("9c", "TH reads from the DUT the Forecast", "Value has to include EarliestStartTime<=StartTime, LatestEndTime>=EndTime, and ForecastUpdateReason=Internal Optimization"), - TestStep("9", "TH sends StartTimeAdjustRequest with RequestedStartTime=StartTime+(LatestEndTime-EndTime) from Forecast, Cause=GridOptimization.", - "Verify DUT responds with status SUCCESS(0x00)"), - TestStep("9a", "TH reads ESAState attribute.", - "Verify value is 0x01 (Online)"), - TestStep("9b", "TH reads Forecast attribute.", + TestStep("10", "TH sends command StartTimeAdjustRequest with RequestedStartTime=StartTime+(LatestEndTime-EndTime) from Forecast, Cause=GridOptimization", + "Verify DUT responds w/ status SUCCESS(0x00)"), + TestStep("10a", "TH reads from the DUT the ESAState", + "Value has to be 0x01 (Online)"), + TestStep("10b", "TH reads from the DUT the Forecast", "Value has to include EarliestStartTime<=StartTime, LatestEndTime=EndTime, and ForecastUpdateReason=Grid Optimization"), - TestStep("10", "TH sends CancelRequest.", - "Verify DUT responds with status SUCCESS(0x00)"), - TestStep("10a", "TH reads ESAState attribute.", - "Verify value is 0x01 (Online)"), - TestStep("10b", "TH reads Forecast attribute.", + TestStep("11", "TH sends command CancelRequest", + "Verify DUT responds w/ status SUCCESS(0x00)"), + TestStep("11a", "TH reads from the DUT the ESAState", + "Value has to be 0x01 (Online)"), + TestStep("11b", "TH reads from the DUT the Forecast", "Value has to include EarliestStartTime<=StartTime, LatestEndTime>=EndTime, and ForecastUpdateReason=Internal Optimization"), - TestStep("11", "TH sends StartTimeAdjustRequest with RequestedStartTime=EarliestStartTime-1 from Forecast, Cause=LocalOptimization.", - "Verify DUT responds with status CONSTRAINT_ERROR(0x87)"), - TestStep("11a", "TH reads ESAState attribute.", - "Verify value is 0x01 (Online)"), - TestStep("11b", "TH reads Forecast attribute.", + TestStep("12", "TH sends command StartTimeAdjustRequest with RequestedStartTime=EarliestStartTime-1 from Forecast, Cause=LocalOptimization", + "Verify DUT responds w/ status CONSTRAINT_ERROR(0x87)"), + TestStep("12a", "TH reads from the DUT the ESAState", + "Value has to be 0x01 (Online)"), + TestStep("12b", "TH reads from the DUT the Forecast", "Value has to include StartTime and EndTime unchanged from step 10b"), - TestStep("12", "TH sends StartTimeAdjustRequest with RequestedStartTime=StartTime+(LatestEndTime-EndTime)+1 from Forecast, Cause=LocalOptimization.", - "Verify DUT responds with status CONSTRAINT_ERROR(0x87)"), - TestStep("12a", "TH reads ESAState attribute.", - "Verify value is 0x01 (Online)"), - TestStep("12b", "TH reads Forecast attribute.", + TestStep("13", "TH sends command StartTimeAdjustRequest with RequestedStartTime=StartTime+(LatestEndTime-EndTime)+1 from Forecast, Cause=LocalOptimization", + "Verify DUT responds w/ status CONSTRAINT_ERROR(0x87)"), + TestStep("13a", "TH reads from the DUT the ESAState", + "Value has to be 0x01 (Online)"), + TestStep("13b", "TH reads from the DUT the Forecast", "Value has to include StartTime and EndTime unchanged from step 10b"), - TestStep("13", "TH sends CancelRequest.", - "Verify DUT responds with status INVALID_IN_STATE(0xcb)"), - TestStep("14", "TH sends TestEventTrigger command to General Diagnostics Cluster on Endpoint 0 with EnableKey field set to PIXIT.DEM.TEST_EVENT_TRIGGER_KEY and EventTrigger field set to PIXIT.DEM.TEST_EVENT_TRIGGER for Start Time Adjustment Test Event Clear", - "Verify DUT responds with status SUCCESS(0x00)"), + TestStep("14", "TH sends command CancelRequest", + "Verify DUT responds w/ status INVALID_IN_STATE(0xcb)"), + TestStep("15", "TH sends TestEventTrigger command to General Diagnostics Cluster on Endpoint 0 with EnableKey field set to PIXIT.DEM.TEST_EVENT_TRIGGER_KEY and EventTrigger field set to PIXIT.DEM.TEST_EVENT_TRIGGER for Start Time Adjustment Test Event Clear", + "Verify DUT responds w/ status SUCCESS(0x00)"), ] return steps @@ -138,25 +139,20 @@ async def test_TC_DEM_2_3(self): self.step("1") # Commission DUT - already done + self.step("2") await self.validate_feature_map([Clusters.DeviceEnergyManagement.Bitmaps.Feature.kStartTimeAdjustment], []) await self.validate_pfr_or_sfr_in_feature_map() - # Subscribe to Events and when they are sent push them to a queue for checking later - events_callback = EventChangeCallback(Clusters.DeviceEnergyManagement) - await events_callback.start(self.default_controller, - self.dut_node_id, - self.matter_test_config.endpoint) - - self.step("2") + self.step("3") await self.check_test_event_triggers_enabled() - self.step("3") + self.step("4") await self.send_test_event_trigger_start_time_adjustment() - self.step("3a") + self.step("4a") await self.check_dem_attribute("ESAState", Clusters.DeviceEnergyManagement.Enums.ESAStateEnum.kOnline) - self.step("3b") + self.step("4b") forecast = await self.read_dem_attribute_expect_success(attribute="Forecast") asserts.assert_not_equal(forecast, NullValue) @@ -169,48 +165,48 @@ async def test_TC_DEM_2_3(self): self.print_forecast(forecast) - self.step("3c") + self.step("4c") await self.check_dem_attribute("OptOutState", Clusters.DeviceEnergyManagement.Enums.OptOutStateEnum.kNoOptOut) - self.step("4") + self.step("5") await self.send_test_event_trigger_user_opt_out_local() - self.step("4a") + self.step("5a") await self.check_dem_attribute("ESAState", Clusters.DeviceEnergyManagement.Enums.ESAStateEnum.kOnline) - self.step("4b") + self.step("5b") await self.check_dem_attribute("OptOutState", Clusters.DeviceEnergyManagement.Enums.OptOutStateEnum.kLocalOptOut) - self.step("5") + self.step("6") await self.send_start_time_adjust_request_command(requestedStartTime=forecast.earliestStartTime, cause=Clusters.DeviceEnergyManagement.Enums.AdjustmentCauseEnum.kLocalOptimization, expected_status=Status.ConstraintError) - self.step("5a") + self.step("6a") await self.check_dem_attribute("ESAState", Clusters.DeviceEnergyManagement.Enums.ESAStateEnum.kOnline) - self.step("5b") + self.step("6b") forecast2 = await self.read_dem_attribute_expect_success(attribute="Forecast") asserts.assert_equal(forecast, forecast2, f"Expected same forcast {forecast} to be == {forecast2}") - self.step("6") + self.step("7") await self.send_test_event_trigger_user_opt_out_clear_all() - self.step("6a") + self.step("7a") await self.check_dem_attribute("ESAState", Clusters.DeviceEnergyManagement.Enums.ESAStateEnum.kOnline) - self.step("6b") + self.step("7b") await self.check_dem_attribute("OptOutState", Clusters.DeviceEnergyManagement.Enums.OptOutStateEnum.kNoOptOut) - self.step("7") + self.step("8") await self.send_start_time_adjust_request_command(requestedStartTime=forecast.earliestStartTime, cause=Clusters.DeviceEnergyManagement.Enums.AdjustmentCauseEnum.kLocalOptimization) - self.step("7a") + self.step("8a") await self.check_dem_attribute("ESAState", Clusters.DeviceEnergyManagement.Enums.ESAStateEnum.kOnline) - self.step("7b") + self.step("8b") forecast3 = await self.read_dem_attribute_expect_success(attribute="Forecast") asserts.assert_equal(forecast3.earliestStartTime, forecast3.startTime, f"Expected earliestStartTime {forecast3.earliestStartTime} to be == startTime {forecast3.startTime}") @@ -219,16 +215,16 @@ async def test_TC_DEM_2_3(self): asserts.assert_equal(forecast3.forecastUpdateReason, Clusters.DeviceEnergyManagement.Enums.ForecastUpdateReasonEnum.kLocalOptimization, f"Expected forecastUpdateReason {forecast3.forecastUpdateReason} to be == LocalOptimization {Clusters.DeviceEnergyManagement.Enums.ForecastUpdateReasonEnum.kLocalOptimization}") - self.step("8") + self.step("9") await self.send_test_event_trigger_user_opt_out_local() - self.step("8a") + self.step("9a") await self.check_dem_attribute("ESAState", Clusters.DeviceEnergyManagement.Enums.ESAStateEnum.kOnline) - self.step("8b") + self.step("9b") await self.check_dem_attribute("OptOutState", Clusters.DeviceEnergyManagement.Enums.OptOutStateEnum.kLocalOptOut) - self.step("8c") + self.step("9c") forecast4 = await self.read_dem_attribute_expect_success(attribute="Forecast") asserts.assert_less_equal(forecast4.earliestStartTime, forecast4.startTime, f"Expected earliestStartTime {forecast4.earliestStartTime} to be <= startTime {forecast4.startTime}") @@ -237,14 +233,14 @@ async def test_TC_DEM_2_3(self): asserts.assert_equal(forecast4.forecastUpdateReason, Clusters.DeviceEnergyManagement.Enums.ForecastUpdateReasonEnum.kInternalOptimization, f"Expected forecastUpdateReason {forecast4.forecastUpdateReason} to be == InternalOptimization {Clusters.DeviceEnergyManagement.Enums.ForecastUpdateReasonEnum.kInternalOptimization}") - self.step("9") + self.step("10") await self.send_start_time_adjust_request_command(requestedStartTime=forecast4.startTime+forecast4.latestEndTime - forecast4.endTime, cause=Clusters.DeviceEnergyManagement.Enums.AdjustmentCauseEnum.kGridOptimization) - self.step("9a") + self.step("10a") await self.check_dem_attribute("ESAState", Clusters.DeviceEnergyManagement.Enums.ESAStateEnum.kOnline) - self.step("9b") + self.step("10b") forecast5 = await self.read_dem_attribute_expect_success(attribute="Forecast") asserts.assert_less_equal(forecast5.earliestStartTime, forecast5.startTime, f"Expected earliestStartTime {forecast5.earliestStartTime} to be <= startTime {forecast5.startTime}") @@ -253,13 +249,13 @@ async def test_TC_DEM_2_3(self): asserts.assert_equal(forecast5.forecastUpdateReason, Clusters.DeviceEnergyManagement.Enums.ForecastUpdateReasonEnum.kGridOptimization, f"Expected forecastUpdateReason {forecast5.forecastUpdateReason} to be == GridOptimization {Clusters.DeviceEnergyManagement.Enums.ForecastUpdateReasonEnum.kGridOptimization}") - self.step("10") + self.step("11") await self.send_cancel_request_command() - self.step("10a") + self.step("11a") await self.check_dem_attribute("ESAState", Clusters.DeviceEnergyManagement.Enums.ESAStateEnum.kOnline) - self.step("10b") + self.step("11b") forecast6 = await self.read_dem_attribute_expect_success(attribute="Forecast") asserts.assert_less_equal(forecast6.earliestStartTime, forecast6.startTime, f"Expected earliestStartTime {forecast6.earliestStartTime} to be <= startTime {forecast6.startTime}") @@ -268,38 +264,38 @@ async def test_TC_DEM_2_3(self): asserts.assert_equal(forecast6.forecastUpdateReason, Clusters.DeviceEnergyManagement.Enums.ForecastUpdateReasonEnum.kInternalOptimization, f"Expected forecastUpdateReason {forecast6.forecastUpdateReason} to be == InternalOptimization {Clusters.DeviceEnergyManagement.Enums.ForecastUpdateReasonEnum.kInternalOptimization}") - self.step("11") + self.step("12") await self.send_start_time_adjust_request_command(requestedStartTime=forecast6.earliestStartTime - 1, cause=Clusters.DeviceEnergyManagement.Enums.AdjustmentCauseEnum.kLocalOptimization, expected_status=Status.ConstraintError) - self.step("11a") + self.step("12a") await self.check_dem_attribute("ESAState", Clusters.DeviceEnergyManagement.Enums.ESAStateEnum.kOnline) - self.step("11b") + self.step("12b") forecast7 = await self.read_dem_attribute_expect_success(attribute="Forecast") asserts.assert_equal(forecast6.startTime, forecast7.startTime, f"Expected old startTime {forecast6.startTime} to be == startTime {forecast7.startTime}") asserts.assert_equal(forecast6.endTime, forecast7.endTime, f"Expected old endTime {forecast6.endTime} to be == endTime {forecast7.endTime}") - self.step("12") + self.step("13") await self.send_start_time_adjust_request_command(requestedStartTime=forecast7.startTime+(forecast7.latestEndTime-forecast7.endTime)+1, cause=Clusters.DeviceEnergyManagement.Enums.AdjustmentCauseEnum.kLocalOptimization, expected_status=Status.ConstraintError) - self.step("12a") + self.step("13a") await self.check_dem_attribute("ESAState", Clusters.DeviceEnergyManagement.Enums.ESAStateEnum.kOnline) - self.step("12b") + self.step("13b") forecast8 = await self.read_dem_attribute_expect_success(attribute="Forecast") asserts.assert_equal(forecast7.startTime, forecast8.startTime, f"Expected old startTime {forecast7.startTime} to be == startTime {forecast8.startTime}") asserts.assert_equal(forecast7.endTime, forecast8.endTime, f"Expected old endTime {forecast7.endTime} to be == endTime {forecast8.endTime}") - self.step("13") + self.step("14") await self.send_cancel_request_command(expected_status=Status.InvalidInState) - self.step("14") + self.step("15") await self.send_test_event_trigger_start_time_adjustment_clear() diff --git a/src/python_testing/TC_DEM_2_4.py b/src/python_testing/TC_DEM_2_4.py index 2528b646014d65..dc63e4b21a25a4 100644 --- a/src/python_testing/TC_DEM_2_4.py +++ b/src/python_testing/TC_DEM_2_4.py @@ -55,98 +55,100 @@ def pics_TC_DEM_2_4(self): def steps_TC_DEM_2_4(self) -> list[TestStep]: steps = [ - TestStep("1", "Commissioning, already done", - is_commissioning=True), - TestStep("2", "TH reads TestEventTriggersEnabled attribute from General Diagnostics Cluster.", - "Verify that TestEventTriggersEnabled attribute has a value of 1 (True)"), - TestStep("3", "TH sends TestEventTrigger command to General Diagnostics Cluster on Endpoint 0 with EnableKey field set to PIXIT.DEM.TEST_EVENT_TRIGGER_KEY and EventTrigger field set to PIXIT.DEM.TEST_EVENT_TRIGGER for Pausable Test Event", - "Verify DUT responds with status SUCCESS(0x00)"), - TestStep("3a", "TH reads ESAState.", - "Verify value is 0x01 (Online)"), - TestStep("3b", "TH reads Forecast.", - "Value has to include IsPausable=True, slot[0].SlotIsPausable=True, slot[0].MinPauseDuration>1, slot[0].MaxPauseDuration>1, slot[1].SlotIsPausable=False, ActiveSlotNumber=0, and ForecastUpdateReason=Internal Optimization"), - TestStep("3c", "TH reads OptOutState.", - "Verify value is 0x00 (NoOptOut)"), - TestStep("4", "TH sends PauseRequest with Duration=Forecast.slots[0].MinPauseDuration-1, Cause=LocalOptimization.", - "Verify DUT responds with status CONSTRAINT_ERROR(0x87)"), - TestStep("4a", "TH reads ESAState.", - "Verify value is 0x01 (Online)"), - TestStep("5", "TH sends PauseRequest with Duration=Forecast.slots[0].MaxPauseDuration+1, Cause=LocalOptimization.", - "Verify DUT responds with status CONSTRAINT_ERROR(0x87)"), - TestStep("5a", "TH reads ESAState.", - "Verify value is 0x01 (Online)"), - TestStep("6", "TH sends TestEventTrigger command to General Diagnostics Cluster on Endpoint 0 with EnableKey field set to PIXIT.DEM.TEST_EVENT_TRIGGER_KEY and EventTrigger field set to PIXIT.DEM.TEST_EVENT_TRIGGER for User Opt-out Grid Optimization Test Event", - "Verify DUT responds with status SUCCESS(0x00)"), - TestStep("6a", "TH reads ESAState.", - "Verify value is 0x01 (Online)"), - TestStep("6b", "TH reads OptOutState.", - "Verify value is 0x02 (GridOptOut)"), - TestStep("7", "TH sends PauseRequest with Duration=Forecast.slots[0].MinPauseDuration, Cause=GridOptimization.", - "Verify DUT responds with status CONSTRAINT_ERROR(0x87)"), - TestStep("7a", "TH reads ESAState.", - "Verify value is 0x01 (Online)"), - TestStep("8", "TH sends PauseRequest with Duration=Forecast.slots[0].MinPauseDuration, Cause=LocalOptimization.", - "Verify DUT responds with status SUCCESS(0x00) and event DEM.S.E02(Paused) sent"), - TestStep("8a", "TH reads ESAState.", - "Verify value is 0x05 (Paused)"), - TestStep("9", "TH sends TestEventTrigger command to General Diagnostics Cluster on Endpoint 0 with EnableKey field set to PIXIT.DEM.TEST_EVENT_TRIGGER_KEY and EventTrigger field set to PIXIT.DEM.TEST_EVENT_TRIGGER for User Opt-out Local Optimization Test Event.", - "Verify DUT responds with status SUCCESS(0x00) and event DEM.S.E03(Resumed) sent with Cause=3 (UserOptOut)"), - TestStep("9a", "TH reads ESAState.", - "Verify value is 0x01 (Online)"), - TestStep("9b", "TH reads OptOutState.", - "Verify value is 0x03 (OptOut)"), - TestStep("9c", "TH reads Forecast.", - "Value has to include ForecastUpdateReason=Internal Optimization"), - TestStep("10", "TH sends TestEventTrigger command to General Diagnostics Cluster on Endpoint 0 with EnableKey field set to PIXIT.DEM.TEST_EVENT_TRIGGER_KEY and EventTrigger field set to PIXIT.DEM.TEST_EVENT_TRIGGER for User Opt-out Test Event Clear", - "Verify DUT responds with status SUCCESS(0x00)"), - TestStep("10a", "TH reads ESAState.", - "Verify value is 0x01 (Online)"), - TestStep("10b", "TH reads OptOutState.", - "Verify value is 0x00 (NoOptOut)"), - TestStep("11", "TH sends PauseRequest with Duration=Forecast.slots[0].MinPauseDuration, Cause=LocalOptimization.", - "Verify DUT responds with status SUCCESS(0x00) and event DEM.S.E02(Paused) sent"), - TestStep("11a", "TH reads ESAState.", - "Verify value is 0x05 (Paused)"), - TestStep("11b", "TH reads Forecast.", + TestStep("1", "Commission DUT to TH (can be skipped if done in a preceding test)"), + TestStep("2", "TH reads from the DUT the _Featuremap_ attribute", + "Verify that the DUT response contains the _Featuremap_ attribute. Verify Pausable is supported."), + TestStep("3", "Set up a subscription to all DeviceEnergyManagement cluster events"), + TestStep("4", "TH reads TestEventTriggersEnabled attribute from General Diagnostics Cluster", + "Value has to be 1 (True)"), + TestStep("5", "TH sends TestEventTrigger command to General Diagnostics Cluster on Endpoint 0 with EnableKey field set to PIXIT.DEM.TEST_EVENT_TRIGGER_KEY and EventTrigger field set to PIXIT.DEM.TEST_EVENT_TRIGGER for Pausable Test Event", + "Verify DUT responds w/ status SUCCESS(0x00)"), + TestStep("5a", "TH reads from the DUT the ESAState", + "Value has to be 0x01 (Online)"), + TestStep("5b", "TH reads from the DUT the Forecast", + "Value has to include IsPausable=True, slots[0].SlotIsPausable=True, slots[0].MinPauseDuration>1, slots[0].MaxPauseDuration>1, slots[1].SlotIsPausable=False, ActiveSlotNumber=0, and ForecastUpdateReason=Internal Optimization"), + TestStep("5c", "TH reads from the DUT the OptOutState", + "Value has to be 0x00 (NoOptOut)"), + TestStep("6", "TH sends command PauseRequest with Duration=Forecast.slots[0].MinPauseDuration-1, Cause=LocalOptimization", + "Verify DUT responds w/ status CONSTRAINT_ERROR(0x87)"), + TestStep("6a", "TH reads from the DUT the ESAState", + "Value has to be 0x01 (Online)"), + TestStep("7", "TH sends command PauseRequest with Duration=Forecast.slots[0].MaxPauseDuration+1, Cause=LocalOptimization", + "Verify DUT responds w/ status CONSTRAINT_ERROR(0x87)"), + TestStep("7a", "TH reads from the DUT the ESAState", + "Value has to be 0x01 (Online)"), + TestStep("8", "TH sends TestEventTrigger command to General Diagnostics Cluster on Endpoint 0 with EnableKey field set to PIXIT.DEM.TEST_EVENT_TRIGGER_KEY and EventTrigger field set to PIXIT.DEM.TEST_EVENT_TRIGGER for User Opt-out Grid Optimization Test Event", + "Verify DUT responds w/ status SUCCESS(0x00)"), + TestStep("8a", "TH reads from the DUT the ESAState", + "Value has to be 0x01 (Online)"), + TestStep("8b", "TH reads from the DUT the OptOutState", + "Value has to be 0x02 (GridOptOut)"), + TestStep("9", "TH sends command PauseRequest with Duration=Forecast.slots[0].MinPauseDuration, Cause=GridOptimization", + "Verify DUT responds w/ status CONSTRAINT_ERROR(0x87)"), + TestStep("9a", "TH reads from the DUT the ESAState", + "Value has to be 0x01 (Online)"), + TestStep("10", "TH sends command PauseRequest with Duration=Forecast.slots[0].MinPauseDuration, Cause=LocalOptimization", + "Verify DUT responds w/ status SUCCESS(0x00) and Event DEM.S.E02(Paused) sent"), + TestStep("10a", "TH reads from the DUT the ESAState", + "Value has to be 0x05 (Paused)"), + TestStep("11", "TH sends TestEventTrigger command to General Diagnostics Cluster on Endpoint 0 with EnableKey field set to PIXIT.DEM.TEST_EVENT_TRIGGER_KEY and EventTrigger field set to PIXIT.DEM.TEST_EVENT_TRIGGER for User Opt-out Local Optimization Test Event", + "Verify DUT responds w/ status SUCCESS(0x00) and Event DEM.S.E03(Resumed) sent with Cause=3 (UserOptOut)"), + TestStep("11a", "TH reads from the DUT the ESAState", + "Value has to be 0x01 (Online)"), + TestStep("11b", "TH reads from the DUT the OptOutState", + "Value has to be 0x03 (OptOut)"), + TestStep("11c", "TH reads from the DUT the Forecast", + "Value has to include ForecastUpdateReason=Internal Optimization"), + TestStep("12", "TH sends TestEventTrigger command to General Diagnostics Cluster on Endpoint 0 with EnableKey field set to PIXIT.DEM.TEST_EVENT_TRIGGER_KEY and EventTrigger field set to PIXIT.DEM.TEST_EVENT_TRIGGER for User Opt-out Test Event Clear", + "Verify DUT responds w/ status SUCCESS(0x00)"), + TestStep("12a", "TH reads from the DUT the ESAState", + "Value has to be 0x01 (Online)"), + TestStep("12b", "TH reads from the DUT the OptOutState", + "Value has to be 0x00 (NoOptOut)"), + TestStep("13", "TH sends command PauseRequest with Duration=Forecast.slots[0].MinPauseDuration, Cause=LocalOptimization", + "Verify DUT responds w/ status SUCCESS(0x00) and Event DEM.S.E02(Paused) sent"), + TestStep("13a", "TH reads from the DUT the ESAState", + "Value has to be 0x05 (Paused)"), + TestStep("13b", "TH reads from the DUT the Forecast", "Value has to include ForecastUpdateReason=Local Optimization"), - TestStep("12", "TH sends ResumeRequest.", - "Verify DUT responds with status SUCCESS(0x00) and event DEM.S.E03(Resumed) sent with Cause=4 (Cancelled)"), - TestStep("12a", "TH reads ESAState.", - "Verify value is 0x01 (Online)"), - TestStep("12b", "TH reads Forecast.", - "Value has to include IsPausable=True, slots[0].SlotIsPausable=True, slots[0].MinPauseDuration>1, slots[0].MaxPauseDuration>1, slots[1].SlotIsPausable=False, ActiveSlotNumber=0, ForecastUpdateReason=Internal Optimization"), - TestStep("13", "TH sends PauseRequest with Duration=Forecast.slots[0].MinPauseDuration, Cause=LocalOptimization.", - "Verify DUT responds with status SUCCESS(0x00) and event DEM.S.E02(Paused) sent"), - TestStep("13a", "TH reads ESAState.", - "Verify value is 0x05 (Paused)"), - TestStep("13b", "TH reads Forecast.", + TestStep("14", "TH sends command ResumeRequest", + "Verify DUT responds w/ status SUCCESS(0x00) and Event DEM.S.E03(Resumed) sent with Cause=4 (Cancelled)"), + TestStep("14a", "TH reads from the DUT the ESAState", + "Value has to be 0x01 (Online)"), + TestStep("14b", "TH reads from the DUT the Forecast", + "Value has to include IsPausable=True, slots[0].SlotIsPausable=True, slots[0].MinPauseDuration>1, slots[0].MaxPauseDuration>1, slots[1].SlotIsPausable=False, ActiveSlotNumber=0, ForecastUpdateReason=InternalOptimization"), + TestStep("15", "TH sends command PauseRequest with Duration=Forecast.slots[0].MinPauseDuration, Cause=LocalOptimization", + "Verify DUT responds w/ status SUCCESS(0x00) and Event DEM.S.E02(Paused) sent"), + TestStep("15a", "TH reads from the DUT the ESAState", + "Value has to be 0x05 (Paused)"), + TestStep("15b", "TH reads from the DUT the Forecast", "Value has to include ForecastUpdateReason=Local Optimization"), - TestStep("14", "TH sends ResumeRequest.", - "Verify DUT responds with status SUCCESS(0x00) and event DEM.S.E03(Resumed) sent with Cause=4 (Cancelled)"), - TestStep("14a", "TH reads ESAState.", - "Verify value is 0x01 (Online)"), - TestStep("15", "TH sends PauseRequest with Duration=Forecast.slots[0].MinPauseDuration, Cause=LocalOptimization.", - "Verify DUT responds with status SUCCESS(0x00) and event DEM.S.E02(Paused) sent"), - TestStep("15a", "TH reads ESAState.", - "Verify value is 0x05 (Paused)"), - TestStep("16", "Wait for minPauseDuration.", + TestStep("16", "TH sends command ResumeRequest", + "Verify DUT responds w/ status SUCCESS(0x00) and Event DEM.S.E03(Resumed) sent with Cause=4 (Cancelled)"), + TestStep("16a", "TH reads from the DUT the ESAState", + "Value has to be 0x01 (Online)"), + TestStep("17", "TH sends command PauseRequest with Duration=Forecast.slots[0].MinPauseDuration, Cause=LocalOptimization", + "Verify DUT responds w/ status SUCCESS(0x00) and Event DEM.S.E02(Paused) sent"), + TestStep("17a", "TH reads from the DUT the ESAState", + "Value has to be 0x05 (Paused)"), + TestStep("18", "", "Event DEM.S.E03(Resumed) sent with Cause=0 (NormalCompletion)"), - TestStep("16a", "TH reads ESAState.", - "Verify value is 0x01 (Online)"), - TestStep("17", "TH sends TestEventTrigger command to General Diagnostics Cluster on Endpoint 0 with EnableKey field set to PIXIT.DEM.TEST_EVENT_TRIGGER_KEY and EventTrigger field set to PIXIT.DEM.TEST_EVENT_TRIGGER for Pausable Test Event Next Slot.", - "Verify DUT responds with status SUCCESS(0x00)"), - TestStep("17a", "TH reads ESAState.", - "Verify value is 0x01 (Online)"), - TestStep("17b", "TH reads Forecast.", + TestStep("18a", "TH reads from the DUT the ESAState", + "Value has to be 0x01 (Online)"), + TestStep("19", "TH sends TestEventTrigger command to General Diagnostics Cluster on Endpoint 0 with EnableKey field set to PIXIT.DEM.TEST_EVENT_TRIGGER_KEY and EventTrigger field set to PIXIT.DEM.TEST_EVENT_TRIGGER for Pausable Test Event Next Slot", + "Verify DUT responds w/ status SUCCESS(0x00)"), + TestStep("19a", "TH reads from the DUT the ESAState", + "Value has to be 0x01 (Online)"), + TestStep("19b", "TH reads from the DUT the Forecast", "Value has to include ActiveSlotNumber=1"), - TestStep("18", "TH sends PauseRequest with Duration=Forecast.slots[0].MinPauseDuration, Cause=LocalOptimization.", - "Verify DUT responds with status FAILURE(0x01)"), - TestStep("18a", "TH reads ESAState.", - "Verify value is 0x01 (Online)"), - TestStep("19", "TH sends ResumeRequest.", - "Verify DUT responds with status INVALID_IN_STATE(0xcb)"), - TestStep("20", "TH sends TestEventTrigger command to General Diagnostics Cluster on Endpoint 0 with EnableKey field set to PIXIT.DEM.TEST_EVENT_TRIGGER_KEY and EventTrigger field set to PIXIT.DEM.TEST_EVENT_TRIGGER for Pausable Test Event Clear.", - "Verify DUT responds with status SUCCESS(0x00)"), + TestStep("20", "TH sends command PauseRequest with Duration=Forecast.slots[0].MinPauseDuration, Cause=LocalOptimization", + "Verify DUT responds w/ status FAILURE(0x01)"), + TestStep("20a", "TH reads from the DUT the ESAState", + "Value has to be 0x01 (Online)"), + TestStep("21", "TH sends command ResumeRequest", + "Verify DUT responds w/ status INVALID_IN_STATE(0xcb)"), + TestStep("22", "TH sends TestEventTrigger command to General Diagnostics Cluster on Endpoint 0 with EnableKey field set to PIXIT.DEM.TEST_EVENT_TRIGGER_KEY and EventTrigger field set to PIXIT.DEM.TEST_EVENT_TRIGGER for Pausable Test Event Clear", + "Verify DUT responds w/ status SUCCESS(0x00)"), ] return steps @@ -159,25 +161,27 @@ async def test_TC_DEM_2_4(self): self.step("1") # Commission DUT - already done + self.step("2") await self.validate_feature_map([Clusters.DeviceEnergyManagement.Bitmaps.Feature.kPausable], []) await self.validate_pfr_or_sfr_in_feature_map() + self.step("3") # Subscribe to Events and when they are sent push them to a queue for checking later events_callback = EventChangeCallback(Clusters.DeviceEnergyManagement) await events_callback.start(self.default_controller, self.dut_node_id, self.matter_test_config.endpoint) - self.step("2") + self.step("4") await self.check_test_event_triggers_enabled() - self.step("3") + self.step("5") await self.send_test_event_trigger_pausable() - self.step("3a") + self.step("5a") await self.check_dem_attribute("ESAState", Clusters.DeviceEnergyManagement.Enums.ESAStateEnum.kOnline) - self.step("3b") + self.step("5b") forecast = await self.read_dem_attribute_expect_success(attribute="Forecast") asserts.assert_not_equal(forecast, NullValue) @@ -196,100 +200,100 @@ async def test_TC_DEM_2_4(self): f"Expected forecast forecastUpdateReason {forecast.forecastUpdateReason} to be == Clusters.DeviceEnergyManagement.Enums.ForecastUpdateReasonEnum.kInternalOptimization") self.print_forecast(forecast) - self.step("3c") + self.step("5c") await self.check_dem_attribute("OptOutState", Clusters.DeviceEnergyManagement.Enums.OptOutStateEnum.kNoOptOut) - self.step("4") + self.step("6") await self.send_pause_request_command(forecast.slots[0].minPauseDuration - 1, Clusters.DeviceEnergyManagement.Enums.AdjustmentCauseEnum.kLocalOptimization, expected_status=Status.ConstraintError) - self.step("4a") + self.step("6a") await self.check_dem_attribute("ESAState", Clusters.DeviceEnergyManagement.Enums.ESAStateEnum.kOnline) - self.step("5") + self.step("7") await self.send_pause_request_command(forecast.slots[0].maxPauseDuration + 1, Clusters.DeviceEnergyManagement.Enums.AdjustmentCauseEnum.kLocalOptimization, expected_status=Status.ConstraintError) - self.step("5a") + self.step("7a") await self.check_dem_attribute("ESAState", Clusters.DeviceEnergyManagement.Enums.ESAStateEnum.kOnline) - self.step("6") + self.step("8") await self.send_test_event_trigger_user_opt_out_grid() - self.step("6a") + self.step("8a") await self.check_dem_attribute("ESAState", Clusters.DeviceEnergyManagement.Enums.ESAStateEnum.kOnline) - self.step("6b") + self.step("8b") await self.check_dem_attribute("OptOutState", Clusters.DeviceEnergyManagement.Enums.OptOutStateEnum.kGridOptOut) - self.step("7") + self.step("9") await self.send_pause_request_command(forecast.slots[0].minPauseDuration, Clusters.DeviceEnergyManagement.Enums.AdjustmentCauseEnum.kGridOptimization, expected_status=Status.ConstraintError) - self.step("7a") + self.step("9a") await self.check_dem_attribute("ESAState", Clusters.DeviceEnergyManagement.Enums.ESAStateEnum.kOnline) - self.step("8") + self.step("10") await self.send_pause_request_command(forecast.slots[0].minPauseDuration, Clusters.DeviceEnergyManagement.Enums.AdjustmentCauseEnum.kLocalOptimization) event_data = events_callback.wait_for_event_report(Clusters.DeviceEnergyManagement.Events.Paused) - self.step("8a") + self.step("10a") await self.check_dem_attribute("ESAState", Clusters.DeviceEnergyManagement.Enums.ESAStateEnum.kPaused) - self.step("9") + self.step("11") await self.send_test_event_trigger_user_opt_out_local() event_data = events_callback.wait_for_event_report(Clusters.DeviceEnergyManagement.Events.Resumed) asserts.assert_equal(event_data.cause, Clusters.DeviceEnergyManagement.Enums.CauseEnum.kUserOptOut) - self.step("9a") + self.step("11a") await self.check_dem_attribute("ESAState", Clusters.DeviceEnergyManagement.Enums.ESAStateEnum.kOnline) - self.step("9b") + self.step("11b") await self.check_dem_attribute("OptOutState", Clusters.DeviceEnergyManagement.Enums.OptOutStateEnum.kOptOut) - self.step("9c") + self.step("11c") forecast = await self.read_dem_attribute_expect_success(attribute="Forecast") asserts.assert_not_equal(forecast, NullValue) asserts.assert_equal(forecast.forecastUpdateReason, Clusters.DeviceEnergyManagement.Enums.ForecastUpdateReasonEnum.kInternalOptimization) - self.step("10") + self.step("12") await self.send_test_event_trigger_user_opt_out_clear_all() - self.step("10a") + self.step("12a") await self.check_dem_attribute("ESAState", Clusters.DeviceEnergyManagement.Enums.ESAStateEnum.kOnline) - self.step("10b") + self.step("12b") await self.check_dem_attribute("OptOutState", Clusters.DeviceEnergyManagement.Enums.OptOutStateEnum.kNoOptOut) - self.step("11") + self.step("13") await self.send_pause_request_command(forecast.slots[0].minPauseDuration, Clusters.DeviceEnergyManagement.Enums.AdjustmentCauseEnum.kLocalOptimization) event_data = events_callback.wait_for_event_report(Clusters.DeviceEnergyManagement.Events.Paused) - self.step("11a") + self.step("13a") await self.check_dem_attribute("ESAState", Clusters.DeviceEnergyManagement.Enums.ESAStateEnum.kPaused) - self.step("11b") + self.step("13b") forecast = await self.read_dem_attribute_expect_success(attribute="Forecast") asserts.assert_equal(forecast.forecastUpdateReason, Clusters.DeviceEnergyManagement.Enums.ForecastUpdateReasonEnum.kLocalOptimization) - self.step("12") + self.step("14") await self.send_resume_request_command() event_data = events_callback.wait_for_event_report(Clusters.DeviceEnergyManagement.Events.Resumed) asserts.assert_equal(event_data.cause, Clusters.DeviceEnergyManagement.Enums.CauseEnum.kCancelled) - self.step("12a") + self.step("14a") await self.check_dem_attribute("ESAState", Clusters.DeviceEnergyManagement.Enums.ESAStateEnum.kOnline) - self.step("12b") + self.step("14b") forecast = await self.read_dem_attribute_expect_success(attribute="Forecast") asserts.assert_equal(forecast.isPausable, True) asserts.assert_greater(forecast.slots[0].minPauseDuration, 1) @@ -300,66 +304,66 @@ async def test_TC_DEM_2_4(self): asserts.assert_equal(forecast.forecastUpdateReason, Clusters.DeviceEnergyManagement.Enums.ForecastUpdateReasonEnum.kInternalOptimization) - self.step("13") + self.step("15") await self.send_pause_request_command(forecast.slots[0].minPauseDuration, Clusters.DeviceEnergyManagement.Enums.AdjustmentCauseEnum.kLocalOptimization) event_data = events_callback.wait_for_event_report(Clusters.DeviceEnergyManagement.Events.Paused) - self.step("13a") + self.step("15a") await self.check_dem_attribute("ESAState", Clusters.DeviceEnergyManagement.Enums.ESAStateEnum.kPaused) - self.step("13b") + self.step("15b") forecast = await self.read_dem_attribute_expect_success(attribute="Forecast") asserts.assert_equal(forecast.forecastUpdateReason, Clusters.DeviceEnergyManagement.Enums.ForecastUpdateReasonEnum.kLocalOptimization) - self.step("14") + self.step("16") await self.send_resume_request_command() event_data = events_callback.wait_for_event_report(Clusters.DeviceEnergyManagement.Events.Resumed) asserts.assert_equal(event_data.cause, Clusters.DeviceEnergyManagement.Enums.CauseEnum.kCancelled) - self.step("14a") + self.step("16a") await self.check_dem_attribute("ESAState", Clusters.DeviceEnergyManagement.Enums.ESAStateEnum.kOnline) - self.step("15") + self.step("17") await self.send_pause_request_command(forecast.slots[0].minPauseDuration, Clusters.DeviceEnergyManagement.Enums.AdjustmentCauseEnum.kLocalOptimization) event_data = events_callback.wait_for_event_report(Clusters.DeviceEnergyManagement.Events.Paused) - self.step("15a") + self.step("17a") await self.check_dem_attribute("ESAState", Clusters.DeviceEnergyManagement.Enums.ESAStateEnum.kPaused) - self.step("16") + self.step("18") logging.info(f"Sleeping for forecast.slots[0].minPauseDuration {forecast.slots[0].minPauseDuration}s") time.sleep(forecast.slots[0].minPauseDuration) event_data = events_callback.wait_for_event_report(Clusters.DeviceEnergyManagement.Events.Resumed) asserts.assert_equal(event_data.cause, Clusters.DeviceEnergyManagement.Enums.CauseEnum.kNormalCompletion) - self.step("16a") + self.step("18a") await self.check_dem_attribute("ESAState", Clusters.DeviceEnergyManagement.Enums.ESAStateEnum.kOnline) - self.step("17") + self.step("19") await self.send_test_event_trigger_pausable_next_slot() - self.step("17a") + self.step("19a") await self.check_dem_attribute("ESAState", Clusters.DeviceEnergyManagement.Enums.ESAStateEnum.kOnline) - self.step("17b") + self.step("19b") forecast = await self.read_dem_attribute_expect_success(attribute="Forecast") asserts.assert_equal(forecast.activeSlotNumber, 1) - self.step("18") + self.step("20") await self.send_pause_request_command(forecast.slots[0].minPauseDuration, Clusters.DeviceEnergyManagement.Enums.AdjustmentCauseEnum.kLocalOptimization, expected_status=Status.Failure) - self.step("18a") + self.step("20a") await self.check_dem_attribute("ESAState", Clusters.DeviceEnergyManagement.Enums.ESAStateEnum.kOnline) - self.step("19") + self.step("21") await self.send_resume_request_command(expected_status=Status.InvalidInState) - self.step("20") + self.step("22") await self.send_test_event_trigger_user_opt_out_clear_all() diff --git a/src/python_testing/TC_DEM_2_5.py b/src/python_testing/TC_DEM_2_5.py index d7ab0521e678ab..f1cc81660e7ab5 100644 --- a/src/python_testing/TC_DEM_2_5.py +++ b/src/python_testing/TC_DEM_2_5.py @@ -34,7 +34,7 @@ import chip.clusters as Clusters from chip.interaction_model import Status -from matter_testing_support import EventChangeCallback, MatterBaseTest, TestStep, async_test_body, default_matter_test_main +from matter_testing_support import MatterBaseTest, TestStep, async_test_body, default_matter_test_main from mobly import asserts from TC_DEMTestBase import DEMTestBase @@ -59,80 +59,81 @@ def pics_TC_DEM_2_5(self): def steps_TC_DEM_2_5(self) -> list[TestStep]: """Execute the test steps.""" steps = [ - TestStep("1", "Commissioning, already done", - is_commissioning=True), - TestStep("2", "TH reads TestEventTriggersEnabled attribute from General Diagnostics Cluster.", - "Verify that TestEventTriggersEnabled attribute has a value of 1 (True)"), - TestStep("3", "TH sends TestEventTrigger command to General Diagnostics Cluster on Endpoint 0 with EnableKey field set to PIXIT.DEM.TEST_EVENT_TRIGGER_KEY and EventTrigger field set to PIXIT.DEM.TEST_EVENT_TRIGGER for Forecast Adjustment Test Event", - "Verify DUT responds with status SUCCESS(0x00)"), - TestStep("3a", "TH reads ESAState attribute.", - "Verify value is 0x01 (Online)"), - TestStep("3b", "TH reads Forecast attribute.", + TestStep("1", "Commission DUT to TH (can be skipped if done in a preceding test)"), + TestStep("2", "TH reads from the DUT the _Featuremap_ attribute", + "Verify that the DUT response contains the _Featuremap_ attribute. Verify ForecastAdjustment and PowerForecastReporting is supported. . Verify StateForecastReporting is not supported."), + TestStep("3", "TH reads TestEventTriggersEnabled attribute from General Diagnostics Cluster", + "Value has to be 1 (True)"), + TestStep("4", "TH sends TestEventTrigger command to General Diagnostics Cluster on Endpoint 0 with EnableKey field set to PIXIT.DEM.TEST_EVENT_TRIGGER_KEY and EventTrigger field set to PIXIT.DEM.TEST_EVENT_TRIGGER for Forecast Adjustment Test Event", + "Verify DUT responds w/ status SUCCESS(0x00)"), + TestStep("4a", "TH reads from the DUT the ESAState", + "Value has to be 0x01 (Online)"), + TestStep("4b", "TH reads from the DUT the Forecast", "Value has to include slots[0].MinPowerAdjustment, slots[0].MaxPowerAdjustment, slots[0].MinDurationAdjustment, slots[0].MaxDurationAdjustment"), - TestStep("3c", "TH reads OptOutState attribute.", - "Verify value is 0x00 (NoOptOut)"), - TestStep("4", "TH sends ModifyForecastRequest with ForecastID=Forecast.ForecastID+1, SlotAdjustments[0].{SlotIndex=0, NominalPower=Forecast.Slots[0].MinPowerAdjustment, Duration=Forecast.Slots[0].MaxDurationAdjustment}, Cause=GridOptimization.", - "Verify DUT responds with status FAILURE(0x01)"), - TestStep("5", "TH sends ModifyForecastRequest with ForecastID=Forecast.ForecastID, SlotAdjustments[0].{SlotIndex=4, NominalPower=Forecast.Slots[0].MinPowerAdjustment, Duration=Forecast.Slots[0].MaxDurationAdjustment}, Cause=GridOptimization.", - "Verify DUT responds with status FAILURE(0x01)"), - TestStep("6", "TH sends ModifyForecastRequest with ForecastID=Forecast.ForecastID, SlotAdjustments[0].{SlotIndex=0, NominalPower=Forecast.Slots[0].MinPowerAdjustment-1, Duration=Forecast.Slots[0].MaxDurationAdjustment}, Cause=GridOptimization.", - "Verify DUT responds with status CONSTRAINT_ERROR(0x87)"), - TestStep("7", "TH sends ModifyForecastRequest with ForecastID=Forecast.ForecastID, SlotAdjustments[0].{SlotIndex=0, NominalPower=Forecast.Slots[0].MaxPowerAdjustment+1, Duration=Forecast.Slots[0].MinDurationAdjustment}, Cause=GridOptimization.", - "Verify DUT responds with status CONSTRAINT_ERROR(0x87)"), - TestStep("8", "TH sends ModifyForecastRequest with ForecastID=Forecast.ForecastID, SlotAdjustments[0].{SlotIndex=0, NominalPower=Forecast.Slots[0].MinPowerAdjustment, Duration=Forecast.Slots[0].MaxDurationAdjustment+1}, Cause=GridOptimization.", - "Verify DUT responds with status CONSTRAINT_ERROR(0x87)"), - TestStep("9", "TH sends ModifyForecastRequest with ForecastID=Forecast.ForecastID, SlotAdjustments[0].{SlotIndex=0, NominalPower=Forecast.Slots[0].MaxPowerAdjustment, Duration=Forecast.Slots[0].MinDurationAdjustment-1}, Cause=GridOptimization.", - "Verify DUT responds with status CONSTRAINT_ERROR(0x87)"), - TestStep("10", "TH sends ModifyForecastRequest with ForecastID=Forecast.ForecastID, SlotAdjustments[0].{SlotIndex=0, NominalPower=Forecast.Slots[0].MinPowerAdjustment, Duration=Forecast.Slots[0].MaxDurationAdjustment}, SlotAdjustments[1].{SlotIndex=4, NominalPower=Forecast.Slots[0].MinPowerAdjustment, Duration=Forecast.Slots[0].MaxDurationAdjustment}, Cause=GridOptimization.", - "Verify DUT responds with status FAILURE(0x01)"), - TestStep("11", "TH sends TestEventTrigger command to General Diagnostics Cluster on Endpoint 0 with EnableKey field set to PIXIT.DEM.TEST_EVENT_TRIGGER_KEY and EventTrigger field set to PIXIT.DEM.TEST_EVENT_TRIGGER for User Opt-out Local Optimization Test Event", - "Verify DUT responds with status SUCCESS(0x00)"), - TestStep("11a", "TH reads ESAState attribute.", - "Verify value is 0x01 (Online)"), - TestStep("11b", "TH reads OptOutState attribute.", - "Verify value is 0x02 (LocalOptOut)"), - TestStep("12", "TH sends ModifyForecastRequest with ForecastID=Forecast.ForecastID, SlotAdjustments[0].{SlotIndex=0, NominalPower=Forecast.Slots[0].MinPowerAdjustment, Duration=Forecast.Slots[0].MaxDurationAdjustment}, Cause=LocalOptimization.", - "Verify DUT responds with status CONSTRAINT_ERROR(0x87)"), - TestStep("13", "TH sends ModifyForecastRequest with ForecastID=Forecast.ForecastID, SlotAdjustments[0].{SlotIndex=0, NominalPower=Forecast.Slots[0].MinPowerAdjustment, Duration=Forecast.Slots[0].MaxDurationAdjustment}, Cause=GridOptimization.", - "Verify DUT responds with status SUCCESS(0x00)"), - TestStep("13a", "TH reads Forecast attribute.", + TestStep("4c", "TH reads from the DUT the OptOutState", + "Value has to be 0x00 (NoOptOut)"), + TestStep("5", "TH sends command ModifyForecastRequest with ForecastID=Forecast.ForecastID+1, SlotAdjustments[0].{SlotIndex=0, NominalPower=Forecast.Slots[0].MinPowerAdjustment, Duration=Forecast.Slots[0].MaxDurationAdjustment}, Cause=GridOptimization", + "Verify DUT responds w/ status FAILURE(0x01)"), + TestStep("6", "TH sends command ModifyForecastRequest with ForecastID=Forecast.ForecastID, SlotAdjustments[0].{SlotIndex=4, NominalPower=Forecast.Slots[0].MinPowerAdjustment, Duration=Forecast.Slots[0].MaxDurationAdjustment}, Cause=GridOptimization", + "Verify DUT responds w/ status FAILURE(0x01)"), + TestStep("7", "TH sends command ModifyForecastRequest with ForecastID=Forecast.ForecastID, SlotAdjustments[0].{SlotIndex=0, NominalPower=Forecast.Slots[0].MinPowerAdjustment-1, Duration=Forecast.Slots[0].MaxDurationAdjustment}, Cause=GridOptimization", + "Verify DUT responds w/ status CONSTRAINT_ERROR(0x87)"), + TestStep("8", "TH sends command ModifyForecastRequest with ForecastID=Forecast.ForecastID, SlotAdjustments[0].{SlotIndex=0, NominalPower=Forecast.Slots[0].MaxPowerAdjustment+1, Duration=Forecast.Slots[0].MinDurationAdjustment}, Cause=GridOptimization", + "Verify DUT responds w/ status CONSTRAINT_ERROR(0x87)"), + TestStep("9", "TH sends command ModifyForecastRequest with ForecastID=Forecast.ForecastID, SlotAdjustments[0].{SlotIndex=0, NominalPower=Forecast.Slots[0].MinPowerAdjustment, Duration=Forecast.Slots[0].MaxDurationAdjustment+1}, Cause=GridOptimization", + "Verify DUT responds w/ status CONSTRAINT_ERROR(0x87)"), + TestStep("10", "TH sends command ModifyForecastRequest with ForecastID=Forecast.ForecastID, SlotAdjustments[0].{SlotIndex=0, NominalPower=Forecast.Slots[0].MaxPowerAdjustment, Duration=Forecast.Slots[0].MinDurationAdjustment-1}, Cause=GridOptimization", + "Verify DUT responds w/ status CONSTRAINT_ERROR(0x87)"), + TestStep("11", "TH sends command ModifyForecastRequest with ForecastID=Forecast.ForecastID, SlotAdjustments[0].{SlotIndex=0, NominalPower=Forecast.Slots[0].MinPowerAdjustment, Duration=Forecast.Slots[0].MaxDurationAdjustment}, SlotAdjustments[1].{SlotIndex=4, NominalPower=Forecast.Slots[0].MinPowerAdjustment, Duration=Forecast.Slots[0].MaxDurationAdjustment}, Cause=GridOptimization", + "Verify DUT responds w/ status FAILURE(0x01)"), + TestStep("12", "TH sends TestEventTrigger command to General Diagnostics Cluster on Endpoint 0 with EnableKey field set to PIXIT.DEM.TEST_EVENT_TRIGGER_KEY and EventTrigger field set to PIXIT.DEM.TEST_EVENT_TRIGGER for User Opt-out Local Optimization Test Event", + "Verify DUT responds w/ status SUCCESS(0x00)"), + TestStep("12a", "TH reads from the DUT the ESAState", + "Value has to be 0x01 (Online)"), + TestStep("12b", "TH reads from the DUT the OptOutState", + "Value has to be 0x02 (LocalOptOut)"), + TestStep("13", "TH sends command ModifyForecastRequest with ForecastID=Forecast.ForecastID, SlotAdjustments[0].{SlotIndex=0, NominalPower=Forecast.Slots[0].MinPowerAdjustment, Duration=Forecast.Slots[0].MaxDurationAdjustment}, Cause=LocalOptimization", + "Verify DUT responds w/ status CONSTRAINT_ERROR(0x87)"), + TestStep("14", "TH sends command ModifyForecastRequest with ForecastID=Forecast.ForecastID, SlotAdjustments[0].{SlotIndex=0, NominalPower=Forecast.Slots[0].MinPowerAdjustment, Duration=Forecast.Slots[0].MaxDurationAdjustment}, Cause=GridOptimization", + "Verify DUT responds w/ status SUCCESS(0x00)"), + TestStep("14a", "TH reads from the DUT the Forecast", "Value has to include ForecastUpdateReason=GridOptimization"), - TestStep("14", "TH sends CancelRequest.", - "Verify DUT responds with status SUCCESS(0x00)"), - TestStep("14a", "TH reads Forecast attribute.", + TestStep("15", "TH sends command CancelRequest", + "Verify DUT responds w/ status SUCCESS(0x00)"), + TestStep("15a", "TH reads from the DUT the Forecast", "Value has to include ForecastUpdateReason=InternalOptimization"), - TestStep("15", "TH sends ModifyForecastRequest with ForecastID=Forecast.ForecastID, SlotAdjustments[0].{SlotIndex=0, NominalPower=Forecast.Slots[0].MinPowerAdjustment, Duration=Forecast.Slots[0].MaxDurationAdjustment}, Cause=GridOptimization.", - "Verify DUT responds with status SUCCESS(0x00)"), - TestStep("15a", "TH reads Forecast attribute.", + TestStep("16", "TH sends command ModifyForecastRequest with ForecastID=Forecast.ForecastID, SlotAdjustments[0].{SlotIndex=0, NominalPower=Forecast.Slots[0].MinPowerAdjustment, Duration=Forecast.Slots[0].MaxDurationAdjustment}, Cause=GridOptimization", + "Verify DUT responds w/ status SUCCESS(0x00)"), + TestStep("16a", "TH reads from the DUT the Forecast", "Value has to include ForecastUpdateReason=GridOptimization"), - TestStep("16", "TH sends TestEventTrigger command to General Diagnostics Cluster on Endpoint 0 with EnableKey field set to PIXIT.DEM.TEST_EVENT_TRIGGER_KEY and EventTrigger field set to PIXIT.DEM.TEST_EVENT_TRIGGER for User Opt-out Grid Optimization Test Event", - "Verify DUT responds with status SUCCESS(0x00)"), - TestStep("16a", "TH reads OptOutState attribute.", - "Verify value is 0x03 (OptOut)"), - TestStep("16b", "TH reads Forecast attribute.", + TestStep("17", "TH sends TestEventTrigger command to General Diagnostics Cluster on Endpoint 0 with EnableKey field set to PIXIT.DEM.TEST_EVENT_TRIGGER_KEY and EventTrigger field set to PIXIT.DEM.TEST_EVENT_TRIGGER for User Opt-out Grid Optimization Test Event", + "Verify DUT responds w/ status SUCCESS(0x00)"), + TestStep("17a", "TH reads from the DUT the OptOutState", + "Value has to be 0x03 (OptOut)"), + TestStep("17b", "TH reads from the DUT the Forecast", "Value has to include ForecastUpdateReason=Internal Optimization"), - TestStep("17", "TH sends ModifyForecastRequest with ForecastID=Forecast.ForecastID, SlotAdjustments[0].{SlotIndex=0, NominalPower=Forecast.Slots[0].MinPowerAdjustment, Duration=Forecast.Slots[0].MaxDurationAdjustment}, Cause=GridOptimization.", - "Verify DUT responds with status CONSTRAINT_ERROR(0x87)"), - TestStep("18", "TH sends TestEventTrigger command to General Diagnostics Cluster on Endpoint 0 with EnableKey field set to PIXIT.DEM.TEST_EVENT_TRIGGER_KEY and EventTrigger field set to PIXIT.DEM.TEST_EVENT_TRIGGER for User Opt-out Test Event Clear", - "Verify DUT responds with status SUCCESS(0x00)"), - TestStep("18a", "TH reads OptOutState attribute.", - "Verify value is 0x00 (NoOptOut)"), - TestStep("19", "TH sends ModifyForecastRequest with ForecastID=Forecast.ForecastID, SlotAdjustments[0].{SlotIndex=0, NominalPower=Forecast.Slots[0].MaxPowerAdjustment, Duration=Forecast.Slots[0].MinDurationAdjustment}, Cause=LocalOptimization.", - "Verify DUT responds with status SUCCESS(0x00)"), - TestStep("19a", "TH reads Forecast attribute.", + TestStep("18", "TH sends command ModifyForecastRequest with ForecastID=Forecast.ForecastID, SlotAdjustments[0].{SlotIndex=0, NominalPower=Forecast.Slots[0].MinPowerAdjustment, Duration=Forecast.Slots[0].MaxDurationAdjustment}, Cause=GridOptimization", + "Verify DUT responds w/ status CONSTRAINT_ERROR(0x87)"), + TestStep("19", "TH sends TestEventTrigger command to General Diagnostics Cluster on Endpoint 0 with EnableKey field set to PIXIT.DEM.TEST_EVENT_TRIGGER_KEY and EventTrigger field set to PIXIT.DEM.TEST_EVENT_TRIGGER for User Opt-out Test Event Clear", + "Verify DUT responds w/ status SUCCESS(0x00)"), + TestStep("19a", "TH reads from the DUT the OptOutState", + "Value has to be 0x00 (NoOptOut)"), + TestStep("20", "TH sends command ModifyForecastRequest with ForecastID=Forecast.ForecastID, SlotAdjustments[0].{SlotIndex=0, NominalPower=Forecast.Slots[0].MaxPowerAdjustment, Duration=Forecast.Slots[0].MinDurationAdjustment}, Cause=LocalOptimization", + "Verify DUT responds w/ status SUCCESS(0x00)"), + TestStep("20a", "TH reads from the DUT the Forecast", "Value has to include ForecastUpdateReason=LocalOptimization"), - TestStep("20", "TH sends CancelRequest.", - "Verify DUT responds with status SUCCESS(0x00)"), - TestStep("20a", "TH reads Forecast attribute.", + TestStep("21", "TH sends command CancelRequest", + "Verify DUT responds w/ status SUCCESS(0x00)"), + TestStep("21a", "TH reads from the DUT the Forecast", "Value has to include ForecastUpdateReason=InternalOptimization"), - TestStep("21", "TH sends TestEventTrigger command to General Diagnostics Cluster on Endpoint 0 with EnableKey field set to PIXIT.DEM.TEST_EVENT_TRIGGER_KEY and EventTrigger field set to PIXIT.DEM.TEST_EVENT_TRIGGER for Forecast Adjustment Test Event Next Slot", - "Verify DUT responds with status SUCCESS(0x00)"), - TestStep("22", "TH sends ModifyForecastRequest with ForecastID=Forecast.ForecastID, SlotAdjustments[0].{SlotIndex=0, NominalPower=Forecast.Slots[0].MaxPowerAdjustment, Duration=Forecast.Slots[0].MinDurationAdjustment}, Cause=LocalOptimization.", - "Verify DUT responds with status CONSTRAINT_ERROR(0x87)"), - TestStep("23", "TH sends CancelRequest.", - "Verify DUT responds with status INVALID_IN_STATE(0xcb)"), - TestStep("24", "TH sends TestEventTrigger command to General Diagnostics Cluster on Endpoint 0 with EnableKey field set to PIXIT.DEM.TEST_EVENT_TRIGGER_KEY and EventTrigger field set to PIXIT.DEM.TEST_EVENT_TRIGGER for Forecast Adjustment Test Event Clear", - "Verify DUT responds with status SUCCESS(0x00)"), + TestStep("22", "TH sends TestEventTrigger command to General Diagnostics Cluster on Endpoint 0 with EnableKey field set to PIXIT.DEM.TEST_EVENT_TRIGGER_KEY and EventTrigger field set to PIXIT.DEM.TEST_EVENT_TRIGGER for Forecast Adjustment Test Event Next Slot", + "Verify DUT responds w/ status SUCCESS(0x00)"), + TestStep("23", "TH sends command ModifyForecastRequest with ForecastID=Forecast.ForecastID, SlotAdjustments[0].{SlotIndex=0, NominalPower=Forecast.Slots[0].MaxPowerAdjustment, Duration=Forecast.Slots[0].MinDurationAdjustment}, Cause=LocalOptimization", + "Verify DUT responds w/ status CONSTRAINT_ERROR(0x87)"), + TestStep("24", "TH sends command CancelRequest", + "Verify DUT responds w/ status INVALID_IN_STATE(0xcb)"), + TestStep("25", "TH sends TestEventTrigger command to General Diagnostics Cluster on Endpoint 0 with EnableKey field set to PIXIT.DEM.TEST_EVENT_TRIGGER_KEY and EventTrigger field set to PIXIT.DEM.TEST_EVENT_TRIGGER for Forecast Adjustment Test Event Clear", + "Verify DUT responds w/ status SUCCESS(0x00)"), ] return steps @@ -144,26 +145,21 @@ async def test_TC_DEM_2_5(self): self.step("1") # Commission DUT - already done + self.step("2") await self.validate_feature_map([Clusters.DeviceEnergyManagement.Bitmaps.Feature.kForecastAdjustment, Clusters.DeviceEnergyManagement.Bitmaps.Feature.kPowerForecastReporting], - []) - - # Subscribe to Events and when they are sent push them to a queue for checking later - events_callback = EventChangeCallback(Clusters.DeviceEnergyManagement) - await events_callback.start(self.default_controller, - self.dut_node_id, - self.matter_test_config.endpoint) + [Clusters.DeviceEnergyManagement.Bitmaps.Feature.kStateForecastReporting]) - self.step("2") + self.step("3") await self.check_test_event_triggers_enabled() - self.step("3") + self.step("4") await self.send_test_event_trigger_forecast_adjustment() - self.step("3a") + self.step("4a") await self.check_dem_attribute("ESAState", Clusters.DeviceEnergyManagement.Enums.ESAStateEnum.kOnline) - self.step("3b") + self.step("4b") forecast = await self.read_dem_attribute_expect_success(attribute="Forecast") asserts.assert_is_not_none(forecast.slots[0].minPowerAdjustment) @@ -171,138 +167,138 @@ async def test_TC_DEM_2_5(self): asserts.assert_is_not_none(forecast.slots[0].minDurationAdjustment) asserts.assert_is_not_none(forecast.slots[0].maxDurationAdjustment) - self.step("3c") + self.step("4c") await self.check_dem_attribute("OptOutState", Clusters.DeviceEnergyManagement.Enums.OptOutStateEnum.kNoOptOut) - self.step("4") + self.step("5") slotAdjustments = [Clusters.DeviceEnergyManagement.Structs.SlotAdjustmentStruct( slotIndex=0, nominalPower=forecast.slots[0].minPowerAdjustment, duration=forecast.slots[0].maxDurationAdjustment)] await self.send_modify_forecast_request_command(forecast.forecastID + 1, slotAdjustments, Clusters.DeviceEnergyManagement.Enums.AdjustmentCauseEnum.kGridOptimization, expected_status=Status.Failure) - self.step("5") + self.step("6") slotAdjustments = [Clusters.DeviceEnergyManagement.Structs.SlotAdjustmentStruct( slotIndex=4, nominalPower=forecast.slots[0].minPowerAdjustment, duration=forecast.slots[0].maxDurationAdjustment)] await self.send_modify_forecast_request_command(forecast.forecastID, slotAdjustments, Clusters.DeviceEnergyManagement.Enums.AdjustmentCauseEnum.kGridOptimization, expected_status=Status.Failure) - self.step("6") + self.step("7") slotAdjustments = [Clusters.DeviceEnergyManagement.Structs.SlotAdjustmentStruct( slotIndex=0, nominalPower=forecast.slots[0].minPowerAdjustment - 1, duration=forecast.slots[0].maxDurationAdjustment)] await self.send_modify_forecast_request_command(forecast.forecastID, slotAdjustments, Clusters.DeviceEnergyManagement.Enums.AdjustmentCauseEnum.kGridOptimization, expected_status=Status.ConstraintError) - self.step("7") + self.step("8") slotAdjustments = [Clusters.DeviceEnergyManagement.Structs.SlotAdjustmentStruct( slotIndex=0, nominalPower=forecast.slots[0].maxPowerAdjustment + 1, duration=forecast.slots[0].minDurationAdjustment)] await self.send_modify_forecast_request_command(forecast.forecastID, slotAdjustments, Clusters.DeviceEnergyManagement.Enums.AdjustmentCauseEnum.kGridOptimization, expected_status=Status.ConstraintError) - self.step("8") + self.step("9") slotAdjustments = [Clusters.DeviceEnergyManagement.Structs.SlotAdjustmentStruct( slotIndex=0, nominalPower=forecast.slots[0].minPowerAdjustment, duration=forecast.slots[0].maxDurationAdjustment + 1)] await self.send_modify_forecast_request_command(forecast.forecastID, slotAdjustments, Clusters.DeviceEnergyManagement.Enums.AdjustmentCauseEnum.kGridOptimization, expected_status=Status.ConstraintError) - self.step("9") + self.step("10") slotAdjustments = [Clusters.DeviceEnergyManagement.Structs.SlotAdjustmentStruct( slotIndex=0, nominalPower=forecast.slots[0].maxPowerAdjustment, duration=forecast.slots[0].minDurationAdjustment - 1)] await self.send_modify_forecast_request_command(forecast.forecastID, slotAdjustments, Clusters.DeviceEnergyManagement.Enums.AdjustmentCauseEnum.kGridOptimization, expected_status=Status.ConstraintError) - self.step("10") + self.step("11") slotAdjustments = [Clusters.DeviceEnergyManagement.Structs.SlotAdjustmentStruct(slotIndex=0, nominalPower=forecast.slots[0].minPowerAdjustment, duration=forecast.slots[0].maxDurationAdjustment), Clusters.DeviceEnergyManagement.Structs.SlotAdjustmentStruct(slotIndex=4, nominalPower=forecast.slots[0].minPowerAdjustment, duration=forecast.slots[0].maxDurationAdjustment)] await self.send_modify_forecast_request_command(forecast.forecastID, slotAdjustments, Clusters.DeviceEnergyManagement.Enums.AdjustmentCauseEnum.kGridOptimization, expected_status=Status.Failure) - self.step("11") + self.step("12") await self.send_test_event_trigger_user_opt_out_local() - self.step("11a") + self.step("12a") await self.check_dem_attribute("ESAState", Clusters.DeviceEnergyManagement.Enums.ESAStateEnum.kOnline) - self.step("11b") + self.step("12b") await self.check_dem_attribute("OptOutState", Clusters.DeviceEnergyManagement.Enums.OptOutStateEnum.kLocalOptOut) - self.step("12") + self.step("13") slotAdjustments = [Clusters.DeviceEnergyManagement.Structs.SlotAdjustmentStruct( slotIndex=0, nominalPower=forecast.slots[0].minPowerAdjustment, duration=forecast.slots[0].maxDurationAdjustment)] await self.send_modify_forecast_request_command(forecast.forecastID, slotAdjustments, Clusters.DeviceEnergyManagement.Enums.AdjustmentCauseEnum.kLocalOptimization, expected_status=Status.ConstraintError) - self.step("13") + self.step("14") slotAdjustments = [Clusters.DeviceEnergyManagement.Structs.SlotAdjustmentStruct( slotIndex=0, nominalPower=forecast.slots[0].minPowerAdjustment, duration=forecast.slots[0].maxDurationAdjustment)] await self.send_modify_forecast_request_command(forecast.forecastID, slotAdjustments, Clusters.DeviceEnergyManagement.Enums.AdjustmentCauseEnum.kGridOptimization, expected_status=Status.Success) - self.step("13a") + self.step("14a") forecast = await self.read_dem_attribute_expect_success(attribute="Forecast") asserts.assert_equal(forecast.forecastUpdateReason, Clusters.DeviceEnergyManagement.Enums.ForecastUpdateReasonEnum.kGridOptimization) - self.step("14") + self.step("15") await self.send_cancel_request_command() - self.step("14a") + self.step("15a") forecast = await self.read_dem_attribute_expect_success(attribute="Forecast") asserts.assert_equal(forecast.forecastUpdateReason, Clusters.DeviceEnergyManagement.Enums.ForecastUpdateReasonEnum.kInternalOptimization) - self.step("15") + self.step("16") slotAdjustments = [Clusters.DeviceEnergyManagement.Structs.SlotAdjustmentStruct( slotIndex=0, nominalPower=forecast.slots[0].minPowerAdjustment, duration=forecast.slots[0].maxDurationAdjustment)] await self.send_modify_forecast_request_command(forecast.forecastID, slotAdjustments, Clusters.DeviceEnergyManagement.Enums.AdjustmentCauseEnum.kGridOptimization, expected_status=Status.Success) - self.step("15a") + self.step("16a") forecast = await self.read_dem_attribute_expect_success(attribute="Forecast") asserts.assert_equal(forecast.forecastUpdateReason, Clusters.DeviceEnergyManagement.Enums.ForecastUpdateReasonEnum.kGridOptimization) - self.step("16") + self.step("17") await self.send_test_event_trigger_user_opt_out_grid() - self.step("16a") + self.step("17a") await self.check_dem_attribute("OptOutState", Clusters.DeviceEnergyManagement.Enums.OptOutStateEnum.kOptOut) - self.step("16b") + self.step("17b") forecast = await self.read_dem_attribute_expect_success(attribute="Forecast") asserts.assert_equal(forecast.forecastUpdateReason, Clusters.DeviceEnergyManagement.Enums.ForecastUpdateReasonEnum.kInternalOptimization) - self.step("17") + self.step("18") slotAdjustments = [Clusters.DeviceEnergyManagement.Structs.SlotAdjustmentStruct( slotIndex=0, nominalPower=forecast.slots[0].minPowerAdjustment, duration=forecast.slots[0].maxDurationAdjustment)] await self.send_modify_forecast_request_command(forecast.forecastID, slotAdjustments, Clusters.DeviceEnergyManagement.Enums.AdjustmentCauseEnum.kGridOptimization, expected_status=Status.ConstraintError) - self.step("18") + self.step("19") await self.send_test_event_trigger_user_opt_out_clear_all() - self.step("18a") + self.step("19a") await self.check_dem_attribute("OptOutState", Clusters.DeviceEnergyManagement.Enums.OptOutStateEnum.kNoOptOut) - self.step("19") + self.step("20") slotAdjustments = [Clusters.DeviceEnergyManagement.Structs.SlotAdjustmentStruct( slotIndex=0, nominalPower=forecast.slots[0].minPowerAdjustment, duration=forecast.slots[0].minDurationAdjustment)] await self.send_modify_forecast_request_command(forecast.forecastID, slotAdjustments, Clusters.DeviceEnergyManagement.Enums.AdjustmentCauseEnum.kLocalOptimization, expected_status=Status.Success) - self.step("19a") + self.step("20a") forecast = await self.read_dem_attribute_expect_success(attribute="Forecast") asserts.assert_equal(forecast.forecastUpdateReason, Clusters.DeviceEnergyManagement.Enums.ForecastUpdateReasonEnum.kLocalOptimization) - self.step("20") + self.step("21") await self.send_cancel_request_command() - self.step("20a") + self.step("21a") forecast = await self.read_dem_attribute_expect_success(attribute="Forecast") asserts.assert_equal(forecast.forecastUpdateReason, Clusters.DeviceEnergyManagement.Enums.ForecastUpdateReasonEnum.kInternalOptimization) - self.step("21") + self.step("22") await self.send_test_event_trigger_forecast_adjustment_next_slot() - self.step("22") + self.step("23") slotAdjustments = [Clusters.DeviceEnergyManagement.Structs.SlotAdjustmentStruct( slotIndex=0, nominalPower=forecast.slots[0].minPowerAdjustment, duration=forecast.slots[0].minDurationAdjustment)] await self.send_modify_forecast_request_command(forecast.forecastID, slotAdjustments, Clusters.DeviceEnergyManagement.Enums.AdjustmentCauseEnum.kLocalOptimization, expected_status=Status.ConstraintError) - self.step("23") + self.step("24") await self.send_cancel_request_command(expected_status=Status.InvalidInState) - self.step("24") + self.step("25") await self.send_test_event_trigger_forecast_adjustment_clear() diff --git a/src/python_testing/TC_DEM_2_6.py b/src/python_testing/TC_DEM_2_6.py index 2bc52e6b6f1cb9..dda744d699f70c 100644 --- a/src/python_testing/TC_DEM_2_6.py +++ b/src/python_testing/TC_DEM_2_6.py @@ -34,7 +34,7 @@ import chip.clusters as Clusters from chip.interaction_model import Status -from matter_testing_support import EventChangeCallback, MatterBaseTest, TestStep, async_test_body, default_matter_test_main +from matter_testing_support import MatterBaseTest, TestStep, async_test_body, default_matter_test_main from mobly import asserts from TC_DEMTestBase import DEMTestBase @@ -59,76 +59,77 @@ def pics_TC_DEM_2_6(self): def steps_TC_DEM_2_6(self) -> list[TestStep]: """Execute the test steps.""" steps = [ - TestStep("1", "Commissioning, already done", - is_commissioning=True), - TestStep("2", "TH reads TestEventTriggersEnabled attribute from General Diagnostics Cluster.", - "Verify that TestEventTriggersEnabled attribute has a value of 1 (True)"), - TestStep("3", "TH sends TestEventTrigger command to General Diagnostics Cluster on Endpoint 0 with EnableKey field set to PIXIT.DEM.TEST_EVENT_TRIGGER_KEY and EventTrigger field set to PIXIT.DEM.TEST_EVENT_TRIGGER for Forecast Adjustment Test Event", - "Verify DUT responds with status SUCCESS(0x00)"), - TestStep("3a", "TH reads ESAState attribute.", - "Verify value is 0x01 (Online)"), - TestStep("3b", "TH reads Forecast attribute.", + TestStep("1", "Commission DUT to TH (can be skipped if done in a preceding test)"), + TestStep("2", "TH reads from the DUT the _Featuremap_ attribute", + "Verify that the DUT response contains the _Featuremap_ attribute. Verify ForecastAdjustment and StateForecastReporting is supported. Verify PowerForecastReporting is not supported."), + TestStep("3", "TH reads TestEventTriggersEnabled attribute from General Diagnostics Cluster", + "Value has to be 1 (True)"), + TestStep("4", "TH sends TestEventTrigger command to General Diagnostics Cluster on Endpoint 0 with EnableKey field set to PIXIT.DEM.TEST_EVENT_TRIGGER_KEY and EventTrigger field set to PIXIT.DEM.TEST_EVENT_TRIGGER for Forecast Adjustment Test Event", + "Verify DUT responds w/ status SUCCESS(0x00)"), + TestStep("4a", "TH reads from the DUT the ESAState", + "Value has to be 0x01 (Online)"), + TestStep("4b", "TH reads from the DUT the Forecast", "Value has to include slots[0].MinDurationAdjustment, slots[0].MaxDurationAdjustment"), - TestStep("3c", "TH reads OptOutState attribute.", - "Verify value is 0x00 (NoOptOut)"), - TestStep("4", "TH sends ModifyForecastRequest with ForecastID=Forecast.ForecastID+1, SlotAdjustments[0].{SlotIndex=0, Duration=Forecast.Slots[0].MaxDurationAdjustment}, Cause=GridOptimization.", - "Verify DUT responds with status FAILURE(0x01)"), - TestStep("5", "TH sends ModifyForecastRequest with ForecastID=Forecast.ForecastID, SlotAdjustments[0].{SlotIndex=4, Duration=Forecast.Slots[0].MaxDurationAdjustment}, Cause=GridOptimization.", - "Verify DUT responds with status FAILURE(0x01)"), - TestStep("6", "TH sends ModifyForecastRequest with ForecastID=Forecast.ForecastID, SlotAdjustments[0].{SlotIndex=0, Duration=Forecast.Slots[0].MaxDurationAdjustment+1}, Cause=GridOptimization.", - "Verify DUT responds with status CONSTRAINT_ERROR(0x87)"), - TestStep("7", "TH sends ModifyForecastRequest with ForecastID=Forecast.ForecastID, SlotAdjustments[0].{SlotIndex=0, Duration=Forecast.Slots[0].MinDurationAdjustment-1}, Cause=GridOptimization.", - "Verify DUT responds with status CONSTRAINT_ERROR(0x87)"), - TestStep("8", "TH sends ModifyForecastRequest with ForecastID=Forecast.ForecastID, SlotAdjustments[0].{SlotIndex=0, Duration=Forecast.Slots[0].MaxDurationAdjustment}, SlotAdjustments[1].{SlotIndex=4, Duration=Forecast.Slots[0].MaxDurationAdjustment}, Cause=GridOptimization.", - "Verify DUT responds with status FAILURE(0x01)"), - TestStep("9", "TH sends TestEventTrigger command to General Diagnostics Cluster on Endpoint 0 with EnableKey field set to PIXIT.DEM.TEST_EVENT_TRIGGER_KEY and EventTrigger field set to PIXIT.DEM.TEST_EVENT_TRIGGER for User Opt-out Local Optimization Test Event", - "Verify DUT responds with status SUCCESS(0x00)"), - TestStep("9a", "TH reads ESAState attribute.", - "Verify value is 0x01 (Online)"), - TestStep("9b", "TH reads OptOutState attribute.", - "Verify value is 0x02 (LocalOptOut)"), - TestStep("10", "TH sends ModifyForecastRequest with ForecastID=Forecast.ForecastID, SlotAdjustments[0].{SlotIndex=0, Duration=Forecast.Slots[0].MaxDurationAdjustment}, Cause=LocalOptimization.", - "Verify DUT responds with status CONSTRAINT_ERROR(0x87)"), - TestStep("11", "TH sends ModifyForecastRequest with ForecastID=Forecast.ForecastID, SlotAdjustments[0].{SlotIndex=0, Duration=Forecast.Slots[0].MaxDurationAdjustment}, Cause=GridOptimization.", - "Verify DUT responds with status SUCCESS(0x00)"), - TestStep("11a", "TH reads Forecast attribute.", + TestStep("4c", "TH reads from the DUT the OptOutState", + "Value has to be 0x00 (NoOptOut)"), + TestStep("5", "TH sends command ModifyForecastRequest with ForecastID=Forecast.ForecastID+1, SlotAdjustments[0].{SlotIndex=0, Duration=Forecast.Slots[0].MaxDurationAdjustment}, Cause=GridOptimization", + "Verify DUT responds w/ status FAILURE(0x01)"), + TestStep("6", "TH sends command ModifyForecastRequest with ForecastID=Forecast.ForecastID, SlotAdjustments[0].{SlotIndex=4, Duration=Forecast.Slots[0].MaxDurationAdjustment}, Cause=GridOptimization", + "Verify DUT responds w/ status FAILURE(0x01)"), + TestStep("7", "TH sends command ModifyForecastRequest with ForecastID=Forecast.ForecastID, SlotAdjustments[0].{SlotIndex=0, Duration=Forecast.Slots[0].MaxDurationAdjustment+1}, Cause=GridOptimization", + "Verify DUT responds w/ status CONSTRAINT_ERROR(0x87)"), + TestStep("8", "TH sends command ModifyForecastRequest with ForecastID=Forecast.ForecastID, SlotAdjustments[0].{SlotIndex=0, Duration=Forecast.Slots[0].MinDurationAdjustment-1}, Cause=GridOptimization", + "Verify DUT responds w/ status CONSTRAINT_ERROR(0x87)"), + TestStep("9", "TH sends command ModifyForecastRequest with ForecastID=Forecast.ForecastID, SlotAdjustments[0].{SlotIndex=0, Duration=Forecast.Slots[0].MaxDurationAdjustment}, SlotAdjustments[1].{SlotIndex=4, Duration=Forecast.Slots[0].MaxDurationAdjustment}, Cause=GridOptimization", + "Verify DUT responds w/ status FAILURE(0x01)"), + TestStep("10", "TH sends TestEventTrigger command to General Diagnostics Cluster on Endpoint 0 with EnableKey field set to PIXIT.DEM.TEST_EVENT_TRIGGER_KEY and EventTrigger field set to PIXIT.DEM.TEST_EVENT_TRIGGER for User Opt-out Local Optimization Test Event", + "Verify DUT responds w/ status SUCCESS(0x00)"), + TestStep("10a", "TH reads from the DUT the ESAState", + "Value has to be 0x01 (Online)"), + TestStep("10b", "TH reads from the DUT the OptOutState", + "Value has to be 0x02 (LocalOptOut)"), + TestStep("11", "TH sends command ModifyForecastRequest with ForecastID=Forecast.ForecastID, SlotAdjustments[0].{SlotIndex=0, Duration=Forecast.Slots[0].MaxDurationAdjustment}, Cause=LocalOptimization", + "Verify DUT responds w/ status CONSTRAINT_ERROR(0x87)"), + TestStep("12", "TH sends command ModifyForecastRequest with ForecastID=Forecast.ForecastID, SlotAdjustments[0].{SlotIndex=0, Duration=Forecast.Slots[0].MaxDurationAdjustment}, Cause=GridOptimization", + "Verify DUT responds w/ status SUCCESS(0x00)"), + TestStep("12a", "TH reads from the DUT the Forecast", "Value has to include ForecastUpdateReason=GridOptimization"), - TestStep("12", "TH sends CancelRequest.", - "Verify DUT responds with status SUCCESS(0x00)"), - TestStep("12a", "TH reads Forecast attribute.", + TestStep("13", "TH sends command CancelRequest", + "Verify DUT responds w/ status SUCCESS(0x00)"), + TestStep("13a", "TH reads from the DUT the Forecast", "Value has to include ForecastUpdateReason=InternalOptimization"), - TestStep("13", "TH sends ModifyForecastRequest with ForecastID=Forecast.ForecastID, SlotAdjustments[0].{SlotIndex=0, Duration=Forecast.Slots[0].MaxDurationAdjustment}, Cause=GridOptimization.", - "Verify DUT responds with status SUCCESS(0x00)"), - TestStep("13a", "TH reads Forecast attribute.", + TestStep("14", "TH sends command ModifyForecastRequest with ForecastID=Forecast.ForecastID, SlotAdjustments[0].{SlotIndex=0, Duration=Forecast.Slots[0].MaxDurationAdjustment}, Cause=GridOptimization", + "Verify DUT responds w/ status SUCCESS(0x00)"), + TestStep("14a", "TH reads from the DUT the Forecast", "Value has to include ForecastUpdateReason=GridOptimization"), - TestStep("14", "TH sends TestEventTrigger command to General Diagnostics Cluster on Endpoint 0 with EnableKey field set to PIXIT.DEM.TEST_EVENT_TRIGGER_KEY and EventTrigger field set to PIXIT.DEM.TEST_EVENT_TRIGGER for User Opt-out Grid Optimization Test Event", - "Verify DUT responds with status SUCCESS(0x00)"), - TestStep("14a", "TH reads OptOutState attribute.", - "Verify value is 0x03 (OptOut)"), - TestStep("14b", "TH reads Forecast attribute.", + TestStep("15", "TH sends TestEventTrigger command to General Diagnostics Cluster on Endpoint 0 with EnableKey field set to PIXIT.DEM.TEST_EVENT_TRIGGER_KEY and EventTrigger field set to PIXIT.DEM.TEST_EVENT_TRIGGER for User Opt-out Grid Optimization Test Event", + "Verify DUT responds w/ status SUCCESS(0x00)"), + TestStep("15a", "TH reads from the DUT the OptOutState", + "Value has to be 0x03 (OptOut)"), + TestStep("15b", "TH reads from the DUT the Forecast", "Value has to include ForecastUpdateReason=Internal Optimization"), - TestStep("15", "TH sends ModifyForecastRequest with ForecastID=Forecast.ForecastID, SlotAdjustments[0].{SlotIndex=0, Duration=Forecast.Slots[0].MaxDurationAdjustment}, Cause=GridOptimization.", - "Verify DUT responds with status CONSTRAINT_ERROR(0x87)"), - TestStep("16", "TH sends TestEventTrigger command to General Diagnostics Cluster on Endpoint 0 with EnableKey field set to PIXIT.DEM.TEST_EVENT_TRIGGER_KEY and EventTrigger field set to PIXIT.DEM.TEST_EVENT_TRIGGER for User Opt-out Test Event Clear", - "Verify DUT responds with status SUCCESS(0x00)"), - TestStep("16a", "TH reads OptOutState attribute.", - "Verify value is 0x00 (NoOptOut)"), - TestStep("17", "TH sends ModifyForecastRequest with ForecastID=Forecast.ForecastID, SlotAdjustments[0].{SlotIndex=0, Duration=Forecast.Slots[0].MinDurationAdjustment}, Cause=LocalOptimization.", - "Verify DUT responds with status SUCCESS(0x00)"), - TestStep("17a", "TH reads Forecast attribute.", + TestStep("16", "TH sends command ModifyForecastRequest with ForecastID=Forecast.ForecastID, SlotAdjustments[0].{SlotIndex=0, Duration=Forecast.Slots[0].MaxDurationAdjustment}, Cause=GridOptimization", + "Verify DUT responds w/ status CONSTRAINT_ERROR(0x87)"), + TestStep("17", "TH sends TestEventTrigger command to General Diagnostics Cluster on Endpoint 0 with EnableKey field set to PIXIT.DEM.TEST_EVENT_TRIGGER_KEY and EventTrigger field set to PIXIT.DEM.TEST_EVENT_TRIGGER for User Opt-out Test Event Clear", + "Verify DUT responds w/ status SUCCESS(0x00)"), + TestStep("17a", "TH reads from the DUT the OptOutState", + "Value has to be 0x00 (NoOptOut)"), + TestStep("18", "TH sends command ModifyForecastRequest with ForecastID=Forecast.ForecastID, SlotAdjustments[0].{SlotIndex=0, Duration=Forecast.Slots[0].MinDurationAdjustment}, Cause=LocalOptimization", + "Verify DUT responds w/ status SUCCESS(0x00)"), + TestStep("18a", "TH reads from the DUT the Forecast", "Value has to include ForecastUpdateReason=LocalOptimization"), - TestStep("18", "TH sends CancelRequest.", - "Verify DUT responds with status SUCCESS(0x00)"), - TestStep("18a", "TH reads Forecast attribute.", + TestStep("19", "TH sends command CancelRequest", + "Verify DUT responds w/ status SUCCESS(0x00)"), + TestStep("19a", "TH reads from the DUT the Forecast", "Value has to include ForecastUpdateReason=InternalOptimization"), - TestStep("19", "TH sends TestEventTrigger command to General Diagnostics Cluster on Endpoint 0 with EnableKey field set to PIXIT.DEM.TEST_EVENT_TRIGGER_KEY and EventTrigger field set to PIXIT.DEM.TEST_EVENT_TRIGGER for Forecast Adjustment Test Event Next Slot", - "Verify DUT responds with status SUCCESS(0x00)"), - TestStep("20", "TH sends ModifyForecastRequest with ForecastID=Forecast.ForecastID, SlotAdjustments[0].{SlotIndex=0, Duration=Forecast.Slots[0].MinDurationAdjustment}, Cause=LocalOptimization.", - "Verify DUT responds with status CONSTRAINT_ERROR(0x87)"), - TestStep("21", "TH sends CancelRequest.", - "Verify DUT responds with status INVALID_IN_STATE(0xcb)"), - TestStep("22", "TH sends TestEventTrigger command to General Diagnostics Cluster on Endpoint 0 with EnableKey field set to PIXIT.DEM.TEST_EVENT_TRIGGER_KEY and EventTrigger field set to PIXIT.DEM.TEST_EVENT_TRIGGER for Forecast Adjustment Test Event Clear", - "Verify DUT responds with status SUCCESS(0x00)"), + TestStep("20", "TH sends TestEventTrigger command to General Diagnostics Cluster on Endpoint 0 with EnableKey field set to PIXIT.DEM.TEST_EVENT_TRIGGER_KEY and EventTrigger field set to PIXIT.DEM.TEST_EVENT_TRIGGER for Forecast Adjustment Test Event Next Slot", + "Verify DUT responds w/ status SUCCESS(0x00)"), + TestStep("21", "TH sends command ModifyForecastRequest with ForecastID=Forecast.ForecastID, SlotAdjustments[0].{SlotIndex=0, Duration=Forecast.Slots[0].MinDurationAdjustment}, Cause=LocalOptimization", + "Verify DUT responds w/ status CONSTRAINT_ERROR(0x87)"), + TestStep("22", "TH sends command CancelRequest", + "Verify DUT responds w/ status INVALID_IN_STATE(0xcb)"), + TestStep("23", "TH sends TestEventTrigger command to General Diagnostics Cluster on Endpoint 0 with EnableKey field set to PIXIT.DEM.TEST_EVENT_TRIGGER_KEY and EventTrigger field set to PIXIT.DEM.TEST_EVENT_TRIGGER for Forecast Adjustment Test Event Clear", + "Verify DUT responds w/ status SUCCESS(0x00)"), ] return steps @@ -140,153 +141,148 @@ async def test_TC_DEM_2_6(self): self.step("1") # Commission DUT - already done + self.step("2") await self.validate_feature_map([Clusters.DeviceEnergyManagement.Bitmaps.Feature.kForecastAdjustment, Clusters.DeviceEnergyManagement.Bitmaps.Feature.kStateForecastReporting], [Clusters.DeviceEnergyManagement.Bitmaps.Feature.kPowerForecastReporting]) - # Subscribe to Events and when they are sent push them to a queue for checking later - events_callback = EventChangeCallback(Clusters.DeviceEnergyManagement) - await events_callback.start(self.default_controller, - self.dut_node_id, - self.matter_test_config.endpoint) - - self.step("2") + self.step("3") await self.check_test_event_triggers_enabled() - self.step("3") + self.step("4") await self.send_test_event_trigger_forecast_adjustment() - self.step("3a") + self.step("4a") await self.check_dem_attribute("ESAState", Clusters.DeviceEnergyManagement.Enums.ESAStateEnum.kOnline) - self.step("3b") + self.step("4b") forecast = await self.read_dem_attribute_expect_success(attribute="Forecast") asserts.assert_is_not_none(forecast.slots[0].minDurationAdjustment) asserts.assert_is_not_none(forecast.slots[0].maxDurationAdjustment) - self.step("3c") + self.step("4c") await self.check_dem_attribute("OptOutState", Clusters.DeviceEnergyManagement.Enums.OptOutStateEnum.kNoOptOut) - self.step("4") + self.step("5") slotAdjustments = [Clusters.DeviceEnergyManagement.Structs.SlotAdjustmentStruct( slotIndex=0, duration=forecast.slots[0].maxDurationAdjustment)] await self.send_modify_forecast_request_command(forecast.forecastID + 1, slotAdjustments, Clusters.DeviceEnergyManagement.Enums.AdjustmentCauseEnum.kGridOptimization, expected_status=Status.Failure) - self.step("5") + self.step("6") slotAdjustments = [Clusters.DeviceEnergyManagement.Structs.SlotAdjustmentStruct( slotIndex=4, duration=forecast.slots[0].maxDurationAdjustment)] await self.send_modify_forecast_request_command(forecast.forecastID, slotAdjustments, Clusters.DeviceEnergyManagement.Enums.AdjustmentCauseEnum.kGridOptimization, expected_status=Status.Failure) - self.step("6") + self.step("7") slotAdjustments = [Clusters.DeviceEnergyManagement.Structs.SlotAdjustmentStruct( slotIndex=0, duration=forecast.slots[0].maxDurationAdjustment + 1)] await self.send_modify_forecast_request_command(forecast.forecastID, slotAdjustments, Clusters.DeviceEnergyManagement.Enums.AdjustmentCauseEnum.kGridOptimization, expected_status=Status.ConstraintError) - self.step("7") + self.step("8") slotAdjustments = [Clusters.DeviceEnergyManagement.Structs.SlotAdjustmentStruct( slotIndex=0, duration=forecast.slots[0].minDurationAdjustment - 1)] await self.send_modify_forecast_request_command(forecast.forecastID, slotAdjustments, Clusters.DeviceEnergyManagement.Enums.AdjustmentCauseEnum.kGridOptimization, expected_status=Status.ConstraintError) - self.step("8") + self.step("9") slotAdjustments = [Clusters.DeviceEnergyManagement.Structs.SlotAdjustmentStruct(slotIndex=0, duration=forecast.slots[0].maxDurationAdjustment), Clusters.DeviceEnergyManagement.Structs.SlotAdjustmentStruct(slotIndex=4, duration=forecast.slots[0].maxDurationAdjustment)] await self.send_modify_forecast_request_command(forecast.forecastID, slotAdjustments, Clusters.DeviceEnergyManagement.Enums.AdjustmentCauseEnum.kGridOptimization, expected_status=Status.Failure) - self.step("9") + self.step("10") await self.send_test_event_trigger_user_opt_out_local() - self.step("9a") + self.step("10a") await self.check_dem_attribute("ESAState", Clusters.DeviceEnergyManagement.Enums.ESAStateEnum.kOnline) - self.step("9b") + self.step("10b") await self.check_dem_attribute("OptOutState", Clusters.DeviceEnergyManagement.Enums.OptOutStateEnum.kLocalOptOut) - self.step("10") + self.step("11") slotAdjustments = [Clusters.DeviceEnergyManagement.Structs.SlotAdjustmentStruct( slotIndex=0, duration=forecast.slots[0].maxDurationAdjustment)] await self.send_modify_forecast_request_command(forecast.forecastID, slotAdjustments, Clusters.DeviceEnergyManagement.Enums.AdjustmentCauseEnum.kLocalOptimization, expected_status=Status.ConstraintError) - self.step("11") + self.step("12") slotAdjustments = [Clusters.DeviceEnergyManagement.Structs.SlotAdjustmentStruct( slotIndex=0, duration=forecast.slots[0].maxDurationAdjustment)] await self.send_modify_forecast_request_command(forecast.forecastID, slotAdjustments, Clusters.DeviceEnergyManagement.Enums.AdjustmentCauseEnum.kGridOptimization, expected_status=Status.Success) - self.step("11a") + self.step("12a") forecast = await self.read_dem_attribute_expect_success(attribute="Forecast") logging.info(forecast) asserts.assert_equal(forecast.forecastUpdateReason, Clusters.DeviceEnergyManagement.Enums.ForecastUpdateReasonEnum.kGridOptimization) - self.step("12") + self.step("13") await self.send_cancel_request_command() - self.step("12a") + self.step("13a") forecast = await self.read_dem_attribute_expect_success(attribute="Forecast") asserts.assert_equal(forecast.forecastUpdateReason, Clusters.DeviceEnergyManagement.Enums.ForecastUpdateReasonEnum.kInternalOptimization) - self.step("13") + self.step("14") slotAdjustments = [Clusters.DeviceEnergyManagement.Structs.SlotAdjustmentStruct( slotIndex=0, duration=forecast.slots[0].maxDurationAdjustment)] await self.send_modify_forecast_request_command(forecast.forecastID, slotAdjustments, Clusters.DeviceEnergyManagement.Enums.AdjustmentCauseEnum.kGridOptimization, expected_status=Status.Success) - self.step("13a") + self.step("14a") forecast = await self.read_dem_attribute_expect_success(attribute="Forecast") asserts.assert_equal(forecast.forecastUpdateReason, Clusters.DeviceEnergyManagement.Enums.ForecastUpdateReasonEnum.kGridOptimization) - self.step("14") + self.step("15") await self.send_test_event_trigger_user_opt_out_grid() - self.step("14a") + self.step("15a") await self.check_dem_attribute("OptOutState", Clusters.DeviceEnergyManagement.Enums.OptOutStateEnum.kOptOut) - self.step("14b") + self.step("15b") forecast = await self.read_dem_attribute_expect_success(attribute="Forecast") asserts.assert_equal(forecast.forecastUpdateReason, Clusters.DeviceEnergyManagement.Enums.ForecastUpdateReasonEnum.kInternalOptimization) - self.step("15") + self.step("16") slotAdjustments = [Clusters.DeviceEnergyManagement.Structs.SlotAdjustmentStruct( slotIndex=0, duration=forecast.slots[0].maxDurationAdjustment)] await self.send_modify_forecast_request_command(forecast.forecastID, slotAdjustments, Clusters.DeviceEnergyManagement.Enums.AdjustmentCauseEnum.kGridOptimization, expected_status=Status.ConstraintError) - self.step("16") + self.step("17") await self.send_test_event_trigger_user_opt_out_clear_all() - self.step("16a") + self.step("17a") await self.check_dem_attribute("OptOutState", Clusters.DeviceEnergyManagement.Enums.OptOutStateEnum.kNoOptOut) - self.step("17") + self.step("18") slotAdjustments = [Clusters.DeviceEnergyManagement.Structs.SlotAdjustmentStruct( slotIndex=0, duration=forecast.slots[0].minDurationAdjustment)] await self.send_modify_forecast_request_command(forecast.forecastID, slotAdjustments, Clusters.DeviceEnergyManagement.Enums.AdjustmentCauseEnum.kLocalOptimization, expected_status=Status.Success) - self.step("17a") + self.step("18a") forecast = await self.read_dem_attribute_expect_success(attribute="Forecast") asserts.assert_equal(forecast.forecastUpdateReason, Clusters.DeviceEnergyManagement.Enums.ForecastUpdateReasonEnum.kLocalOptimization) - self.step("18") + self.step("19") await self.send_cancel_request_command() - self.step("18a") + self.step("19a") forecast = await self.read_dem_attribute_expect_success(attribute="Forecast") asserts.assert_equal(forecast.forecastUpdateReason, Clusters.DeviceEnergyManagement.Enums.ForecastUpdateReasonEnum.kInternalOptimization) - self.step("19") + self.step("20") await self.send_test_event_trigger_forecast_adjustment_next_slot() - self.step("20") + self.step("21") slotAdjustments = [Clusters.DeviceEnergyManagement.Structs.SlotAdjustmentStruct( slotIndex=0, duration=forecast.slots[0].minDurationAdjustment)] await self.send_modify_forecast_request_command(forecast.forecastID, slotAdjustments, Clusters.DeviceEnergyManagement.Enums.AdjustmentCauseEnum.kLocalOptimization, expected_status=Status.ConstraintError) - self.step("21") + self.step("22") await self.send_cancel_request_command(expected_status=Status.InvalidInState) - self.step("22") + self.step("23") await self.send_test_event_trigger_forecast_adjustment_clear() diff --git a/src/python_testing/TC_DEM_2_7.py b/src/python_testing/TC_DEM_2_7.py index 16b974d3ff58f6..b749299c537557 100644 --- a/src/python_testing/TC_DEM_2_7.py +++ b/src/python_testing/TC_DEM_2_7.py @@ -34,7 +34,7 @@ import chip.clusters as Clusters from chip.interaction_model import Status -from matter_testing_support import EventChangeCallback, MatterBaseTest, TestStep, async_test_body, default_matter_test_main +from matter_testing_support import MatterBaseTest, TestStep, async_test_body, default_matter_test_main from mobly import asserts from TC_DEMTestBase import DEMTestBase @@ -59,84 +59,85 @@ def pics_TC_DEM_2_7(self): def steps_TC_DEM_2_7(self) -> list[TestStep]: """Execute the test steps.""" steps = [ - TestStep("1", "Commissioning, already done", - is_commissioning=True), - TestStep("2", "TH reads TestEventTriggersEnabled attribute from General Diagnostics Cluster.", - "Verify value is 1 (True)"), - TestStep("3", "TH sends TestEventTrigger command to General Diagnostics Cluster on Endpoint 0 with EnableKey field set to PIXIT.DEM.TEST_EVENT_TRIGGER_KEY and EventTrigger field set to PIXIT.DEM.TEST_EVENT_TRIGGER for Constraints-based Adjustment Test Event.", - "Verify DUT responds with status SUCCESS(0x00)"), - TestStep("3a", "TH reads ESAState attribute.", - "Verify value is 0x01 (Online)"), - TestStep("3b", "TH reads Forecast attribute.", + TestStep("1", "Commission DUT to TH (can be skipped if done in a preceding test)"), + TestStep("2", "TH reads from the DUT the _Featuremap_ attribute", + "Verify that the DUT response contains the _Featuremap_ attribute. Verify ConstraintBasedAdjustment and PowerForecastReporting is supported. Verify StateForecastReporting is not supported."), + TestStep("3", "TH reads TestEventTriggersEnabled attribute from General Diagnostics Cluster", + "Value has to be 1 (True)"), + TestStep("4", "TH sends TestEventTrigger command to General Diagnostics Cluster on Endpoint 0 with EnableKey field set to PIXIT.DEM.TEST_EVENT_TRIGGER_KEY and EventTrigger field set to PIXIT.DEM.TEST_EVENT_TRIGGER for Constraints-based Adjustment Test Event", + "Verify DUT responds w/ status SUCCESS(0x00)"), + TestStep("4a", "TH reads from the DUT the ESAState", + "Value has to be 0x01 (Online)"), + TestStep("4b", "TH reads from the DUT the Forecast", "Value has to include valid slots[0].NominalPower, slots[0].MinPower, slots[0].MaxPower, slots[0].NominalEnergy"), - TestStep("3c", "TH reads OptOutState attribute.", - "Verify value is 0x00 (NoOptOut)"), - TestStep("4", "TH sends RequestConstraintBasedPowerForecast with constraints[0].{StartTime=now()-10, Duration=20, NominalPower=Forecast.Slots[0].NominalPower, MaximumEnergy=Forecast.Slots[0].NominalEnergy}, Cause=LocalOptimization.", - "Verify DUT responds with status CONSTRAINT_ERROR(0x87)"), - TestStep("5", "TH sends RequestConstraintBasedPowerForecast with constraints[0].{StartTime=now()+10, Duration=20, NominalPower=Forecast.Slots[0].NominalPower, MaximumEnergy=Forecast.Slots[0].NominalEnergy}, constraints[1].{StartTime=now()+20, Duration=20, NominalPower=Forecast.Slots[0].NominalPower, MaximumEnergy=Forecast.Slots[0].NominalEnergy}, constraints[2].{StartTime=now()+40, Duration=20, NominalPower=Forecast.Slots[0].NominalPower, MaximumEnergy=Forecast.Slots[0].NominalEnergy}, Cause=LocalOptimization.", - "Verify DUT responds with status CONSTRAINT_ERROR(0x87)"), - TestStep("6", "TH sends RequestConstraintBasedPowerForecast with constraints[0].{StartTime=now()+10, Duration=20, NominalPower=Forecast.Slots[0].NominalPower, MaximumEnergy=Forecast.Slots[0].NominalEnergy}, constraints[1].{StartTime=now()+30, Duration=20, NominalPower=Forecast.Slots[0].NominalPower, MaximumEnergy=Forecast.Slots[0].NominalEnergy}, constraints[2].{StartTime=now()+40, Duration=20, NominalPower=Forecast.Slots[0].NominalPower, MaximumEnergy=Forecast.Slots[0].NominalEnergy}, Cause=LocalOptimization.", - "Verify DUT responds with status CONSTRAINT_ERROR(0x87)"), - TestStep("7", "TH sends RequestConstraintBasedPowerForecast with constraints[0].{StartTime=now()+30, Duration=20, NominalPower=Forecast.Slots[0].NominalPower, MaximumEnergy=Forecast.Slots[0].NominalEnergy}, constraints[1].{StartTime=now()+10, Duration=20, NominalPower=Forecast.Slots[0].NominalPower, MaximumEnergy=Forecast.Slots[0].NominalEnergy}, constraints[2].{StartTime=now()+50, Duration=20, NominalPower=Forecast.Slots[0].NominalPower, MaximumEnergy=Forecast.Slots[0].NominalEnergy}, Cause=LocalOptimization.", - "Verify DUT responds with status CONSTRAINT_ERROR(0x87)"), - TestStep("8", "TH sends RequestConstraintBasedPowerForecast with constraints[0].{StartTime=now()+10, Duration=20, NominalPower=Forecast.Slots[0].NominalPower, MaximumEnergy=Forecast.Slots[0].NominalEnergy}, constraints[1].{StartTime=now()+50, Duration=20, NominalPower=Forecast.Slots[0].NominalPower, MaximumEnergy=Forecast.Slots[0].NominalEnergy}, constraints[2].{StartTime=now()+30, Duration=20, NominalPower=Forecast.Slots[0].NominalPower, MaximumEnergy=Forecast.Slots[0].NominalEnergy}, Cause=LocalOptimization.", - "Verify DUT responds with status CONSTRAINT_ERROR(0x87)"), - TestStep("9", "TH reads AbsMaxPower attribute attribute.", + TestStep("4c", "TH reads from the DUT the OptOutState", + "Value has to be 0x00 (NoOptOut)"), + TestStep("5", "TH sends command RequestConstraintBasedPowerForecast with constraints[0].{StartTime=now()-10, Duration=20, NominalPower=Forecast.Slots[0].NominalPower, MaximumEnergy=Forecast.Slots[0].NominalEnergy}, Cause=LocalOptimization", + "Verify DUT responds w/ status CONSTRAINT_ERROR(0x87)"), + TestStep("6", "TH sends command RequestConstraintBasedPowerForecast with constraints[0].{StartTime=now()+10, Duration=20, NominalPower=Forecast.Slots[0].NominalPower, MaximumEnergy=Forecast.Slots[0].NominalEnergy}, constraints[1].{StartTime=now()+20, Duration=20, NominalPower=Forecast.Slots[0].NominalPower, MaximumEnergy=Forecast.Slots[0].NominalEnergy}, constraints[2].{StartTime=now()+40, Duration=20, NominalPower=Forecast.Slots[0].NominalPower, MaximumEnergy=Forecast.Slots[0].NominalEnergy}, Cause=LocalOptimization", + "Verify DUT responds w/ status CONSTRAINT_ERROR(0x87)"), + TestStep("7", "TH sends command RequestConstraintBasedPowerForecast with constraints[0].{StartTime=now()+10, Duration=20, NominalPower=Forecast.Slots[0].NominalPower, MaximumEnergy=Forecast.Slots[0].NominalEnergy}, constraints[1].{StartTime=now()+30, Duration=20, NominalPower=Forecast.Slots[0].NominalPower, MaximumEnergy=Forecast.Slots[0].NominalEnergy}, constraints[2].{StartTime=now()+40, Duration=20, NominalPower=Forecast.Slots[0].NominalPower, MaximumEnergy=Forecast.Slots[0].NominalEnergy}, Cause=LocalOptimization", + "Verify DUT responds w/ status CONSTRAINT_ERROR(0x87)"), + TestStep("8", "TH sends command RequestConstraintBasedPowerForecast with constraints[0].{StartTime=now()+30, Duration=20, NominalPower=Forecast.Slots[0].NominalPower, MaximumEnergy=Forecast.Slots[0].NominalEnergy}, constraints[1].{StartTime=now()+10, Duration=20, NominalPower=Forecast.Slots[0].NominalPower, MaximumEnergy=Forecast.Slots[0].NominalEnergy}, constraints[2].{StartTime=now()+50, Duration=20, NominalPower=Forecast.Slots[0].NominalPower, MaximumEnergy=Forecast.Slots[0].NominalEnergy}, Cause=LocalOptimization", + "Verify DUT responds w/ status CONSTRAINT_ERROR(0x87)"), + TestStep("9", "TH sends command RequestConstraintBasedPowerForecast with constraints[0].{StartTime=now()+10, Duration=20, NominalPower=Forecast.Slots[0].NominalPower, MaximumEnergy=Forecast.Slots[0].NominalEnergy}, constraints[1].{StartTime=now()+50, Duration=20, NominalPower=Forecast.Slots[0].NominalPower, MaximumEnergy=Forecast.Slots[0].NominalEnergy}, constraints[2].{StartTime=now()+30, Duration=20, NominalPower=Forecast.Slots[0].NominalPower, MaximumEnergy=Forecast.Slots[0].NominalEnergy}, Cause=LocalOptimization", + "Verify DUT responds w/ status CONSTRAINT_ERROR(0x87)"), + TestStep("10", "TH reads from the DUT the AbsMaxPower attribute.", "Save the value"), - TestStep("9a", "TH sends RequestConstraintBasedPowerForecast with constraints[0].{StartTime=Forecast.StartTime, Duration=Forecast.Slots[0].DefaultDuration, NominalPower=AbsMaxPower+1, MaximumEnergy=Forecast.Slots[0].NominalEnergy}, Cause=LocalOptimization.", - "Verify DUT responds with status CONSTRAINT_ERROR(0x87)"), - TestStep("10", "TH reads AbsMinPower attribute attribute.", + TestStep("10a", "TH sends command RequestConstraintBasedPowerForecast with constraints[0].{StartTime=Forecast.StartTime, Duration=Forecast.Slots[0].DefaultDuration, NominalPower=AbsMaxPower+1, MaximumEnergy=Forecast.Slots[0].NominalEnergy}, Cause=LocalOptimization", + "Verify DUT responds w/ status CONSTRAINT_ERROR(0x87)"), + TestStep("11", "TH reads from the DUT the AbsMinPower attribute.", "Save the value"), - TestStep("10a", "TH sends RequestConstraintBasedPowerForecast with constraints[0].{StartTime=Forecast.StartTime, Duration=Forecast.Slots[0].DefaultDuration, NominalPower=AbsMinPower-1, MaximumEnergy=Forecast.Slots[0].NominalEnergy}, Cause=LocalOptimization.", - "Verify DUT responds with status CONSTRAINT_ERROR(0x87)"), - TestStep("11", "TH sends RequestConstraintBasedPowerForecast with constraints[0].{StartTime=Forecast.StartTime, Duration=Forecast.Slots[0].DefaultDuration, NominalPower=Forecast.Slots[0].NominalPower}, Cause=LocalOptimization.", - "Verify DUT responds with status InvalidCommand"), - TestStep("12", "TH sends RequestConstraintBasedPowerForecast with constraints[0].{StartTime=Forecast.StartTime, Duration=Forecast.Slots[0].DefaultDuration, MaximumEnergy=Forecast.Slots[0].NominalEnergy}, Cause=LocalOptimization.", - "Verify DUT responds with status InvalidCommand"), - TestStep("13", "TH sends TestEventTrigger command to General Diagnostics Cluster on Endpoint 0 with EnableKey field set to PIXIT.DEM.TEST_EVENT_TRIGGER_KEY and EventTrigger field set to PIXIT.DEM.TEST_EVENT_TRIGGER for User Opt-out Local Optimization Test Event.", - "Verify DUT responds with status SUCCESS(0x00)"), - TestStep("13a", "TH reads ESAState attribute.", - "Verify value is 0x01 (Online)"), - TestStep("13b", "TH reads OptOutState attribute.", - "Verify value is 0x02 (LocalOptOut)"), - TestStep("14", "TH sends RequestConstraintBasedPowerForecast with constraints[0].{StartTime=Forecast.StartTime, Duration=Forecast.Slots[0].DefaultDuration, NominalPower=Forecast.Slots[0].NominalPower, MaximumEnergy=Forecast.Slots[0].NominalEnergy}, Cause=LocalOptimization.", - "Verify DUT responds with status CONSTRAINT_ERROR(0x87)"), - TestStep("15", "TH sends RequestConstraintBasedPowerForecast with constraints[0].{StartTime=Forecast.StartTime, Duration=Forecast.Slots[0].DefaultDuration, NominalPower=Forecast.Slots[0].NominalPower, MaximumEnergy=Forecast.Slots[0].NominalEnergy}, Cause=GridOptimization.", - "Verify DUT responds with status SUCCESS(0x00)"), - TestStep("15a", "TH reads Forecast attribute.", + TestStep("11a", "TH sends command RequestConstraintBasedPowerForecast with constraints[0].{StartTime=Forecast.StartTime, Duration=Forecast.Slots[0].DefaultDuration, NominalPower=AbsMinPower-1, MaximumEnergy=Forecast.Slots[0].NominalEnergy}, Cause=LocalOptimization", + "Verify DUT responds w/ status CONSTRAINT_ERROR(0x87)"), + TestStep("12", "TH sends command RequestConstraintBasedPowerForecast with constraints[0].{StartTime=Forecast.StartTime, Duration=Forecast.Slots[0].DefaultDuration, NominalPower=Forecast.Slots[0].NominalPower}, Cause=LocalOptimization", + "Verify DUT responds w/ status INVALID_COMMAND(0x85)"), + TestStep("13", "TH sends command RequestConstraintBasedPowerForecast with constraints[0].{StartTime=Forecast.StartTime, Duration=Forecast.Slots[0].DefaultDuration, MaximumEnergy=Forecast.Slots[0].NominalEnergy}, Cause=LocalOptimization", + "Verify DUT responds w/ status INVALID_COMMAND(0x85)"), + TestStep("14", "TH sends TestEventTrigger command to General Diagnostics Cluster on Endpoint 0 with EnableKey field set to PIXIT.DEM.TEST_EVENT_TRIGGER_KEY and EventTrigger field set to PIXIT.DEM.TEST_EVENT_TRIGGER for User Opt-out Local Optimization Test Event", + "Verify DUT responds w/ status SUCCESS(0x00)"), + TestStep("14a", "TH reads from the DUT the ESAState", + "Value has to be 0x01 (Online)"), + TestStep("14b", "TH reads from the DUT the OptOutState", + "Value has to be 0x02 (LocalOptOut)"), + TestStep("15", "TH sends command RequestConstraintBasedPowerForecast with constraints[0].{StartTime=Forecast.StartTime, Duration=Forecast.Slots[0].DefaultDuration, NominalPower=Forecast.Slots[0].NominalPower, MaximumEnergy=Forecast.Slots[0].NominalEnergy}, Cause=LocalOptimization", + "Verify DUT responds w/ status CONSTRAINT_ERROR(0x87)"), + TestStep("16", "TH sends command RequestConstraintBasedPowerForecast with constraints[0].{StartTime=Forecast.StartTime, Duration=Forecast.Slots[0].DefaultDuration, NominalPower=Forecast.Slots[0].NominalPower, MaximumEnergy=Forecast.Slots[0].NominalEnergy}, Cause=GridOptimization", + "Verify DUT responds w/ status SUCCESS(0x00)"), + TestStep("16a", "TH reads from the DUT the Forecast", "Value has to include ForecastUpdateReason=GridOptimization"), - TestStep("16", "TH sends CancelRequest.", - "Verify DUT responds with status SUCCESS(0x00)"), - TestStep("16a", "TH reads Forecast attribute.", + TestStep("17", "TH sends command CancelRequest", + "Verify DUT responds w/ status SUCCESS(0x00)"), + TestStep("17a", "TH reads from the DUT the Forecast", "Value has to include ForecastUpdateReason=InternalOptimization"), - TestStep("17", "TH sends RequestConstraintBasedPowerForecast with constraints[0].{StartTime=Forecast.StartTime, Duration=Forecast.Slots[0].DefaultDuration, NominalPower=Forecast.Slots[0].NominalPower, MaximumEnergy=Forecast.Slots[0].NominalEnergy}, Cause=GridOptimization.", - "Verify DUT responds with status SUCCESS(0x00)"), - TestStep("17a", "TH reads Forecast attribute.", + TestStep("18", "TH sends command RequestConstraintBasedPowerForecast with constraints[0].{StartTime=Forecast.StartTime, Duration=Forecast.Slots[0].DefaultDuration, NominalPower=Forecast.Slots[0].NominalPower, MaximumEnergy=Forecast.Slots[0].NominalEnergy}, Cause=GridOptimization", + "Verify DUT responds w/ status SUCCESS(0x00)"), + TestStep("18a", "TH reads from the DUT the Forecast", "Value has to include ForecastUpdateReason=GridOptimization"), - TestStep("18", "TH sends TestEventTrigger command to General Diagnostics Cluster on Endpoint 0 with EnableKey field set to PIXIT.DEM.TEST_EVENT_TRIGGER_KEY and EventTrigger field set to PIXIT.DEM.TEST_EVENT_TRIGGER for User Opt-out Grid Optimization Test Event.", - "Verify DUT responds with status SUCCESS(0x00)"), - TestStep("18a", "TH reads OptOutState attribute.", - "Verify value is 0x03 (OptOut)"), - TestStep("18b", "TH reads Forecast attribute.", + TestStep("19", "TH sends TestEventTrigger command to General Diagnostics Cluster on Endpoint 0 with EnableKey field set to PIXIT.DEM.TEST_EVENT_TRIGGER_KEY and EventTrigger field set to PIXIT.DEM.TEST_EVENT_TRIGGER for User Opt-out Grid Optimization Test Event", + "Verify DUT responds w/ status SUCCESS(0x00)"), + TestStep("19a", "TH reads from the DUT the OptOutState", + "Value has to be 0x03 (OptOut)"), + TestStep("19b", "TH reads from the DUT the Forecast", "Value has to include ForecastUpdateReason=InternalOptimization"), - TestStep("19", "TH sends RequestConstraintBasedPowerForecast with constraints[0].{StartTime=Forecast.StartTime, Duration=Forecast.Slots[0].DefaultDuration, NominalPower=Forecast.Slots[0].NominalPower, MaximumEnergy=Forecast.Slots[0].NominalEnergy}, Cause=GridOptimization.", - "Verify DUT responds with status CONSTRAINT_ERROR(0x87)"), - TestStep("20", "TH sends TestEventTrigger command to General Diagnostics Cluster on Endpoint 0 with EnableKey field set to PIXIT.DEM.TEST_EVENT_TRIGGER_KEY and EventTrigger field set to PIXIT.DEM.TEST_EVENT_TRIGGER for User Opt-out Test Event Clear.", - "Verify DUT responds with status SUCCESS(0x00)"), - TestStep("20a", "TH reads OptOutState attribute.", - "Verify value is 0x00 (NoOptOut)"), - TestStep("21", "TH sends RequestConstraintBasedPowerForecast with constraints[0].{StartTime=Forecast.StartTime, Duration=Forecast.Slots[0].DefaultDuration, NominalPower=Forecast.Slots[0].NominalPower, MaximumEnergy=Forecast.Slots[0].NominalEnergy}, Cause=LocalOptimization.", - "Verify DUT responds with status SUCCESS(0x00)"), - TestStep("21a", "TH reads Forecast attribute.", + TestStep("20", "TH sends command RequestConstraintBasedPowerForecast with constraints[0].{StartTime=Forecast.StartTime, Duration=Forecast.Slots[0].DefaultDuration, NominalPower=Forecast.Slots[0].NominalPower, MaximumEnergy=Forecast.Slots[0].NominalEnergy}, Cause=GridOptimization", + "Verify DUT responds w/ status CONSTRAINT_ERROR(0x87)"), + TestStep("21", "TH sends TestEventTrigger command to General Diagnostics Cluster on Endpoint 0 with EnableKey field set to PIXIT.DEM.TEST_EVENT_TRIGGER_KEY and EventTrigger field set to PIXIT.DEM.TEST_EVENT_TRIGGER for User Opt-out Test Event Clear", + "Verify DUT responds w/ status SUCCESS(0x00)"), + TestStep("21a", "TH reads from the DUT the OptOutState", + "Value has to be 0x00 (NoOptOut)"), + TestStep("22", "TH sends command RequestConstraintBasedPowerForecast with constraints[0].{StartTime=Forecast.StartTime, Duration=Forecast.Slots[0].DefaultDuration, NominalPower=Forecast.Slots[0].NominalPower, MaximumEnergy=Forecast.Slots[0].NominalEnergy}, Cause=LocalOptimization", + "Verify DUT responds w/ status SUCCESS(0x00)"), + TestStep("22a", "TH reads from the DUT the Forecast", "Value has to include ForecastUpdateReason=LocalOptimization"), - TestStep("22", "TH sends CancelRequest.", - "Verify DUT responds with status SUCCESS(0x00)"), - TestStep("22a", "TH reads Forecast attribute.", + TestStep("23", "TH sends command CancelRequest", + "Verify DUT responds w/ status SUCCESS(0x00)"), + TestStep("23a", "TH reads from the DUT the Forecast", "Value has to include ForecastUpdateReason=InternalOptimization"), - TestStep("23", "TH sends CancelRequest.", - "Verify DUT responds with status INVALID_IN_STATE(0xcb)"), - TestStep("24", "TH sends TestEventTrigger command to General Diagnostics Cluster on Endpoint 0 with EnableKey field set to PIXIT.DEM.TEST_EVENT_TRIGGER_KEY and EventTrigger field set to PIXIT.DEM.TEST_EVENT_TRIGGER for Constraints-based Adjustment Adjustment Test Event Clear.", - "Verify DUT responds with status SUCCESS(0x00)"), + TestStep("24", "TH sends command CancelRequest", + "Verify DUT responds w/ status INVALID_IN_STATE(0xcb)"), + TestStep("25", "TH sends TestEventTrigger command to General Diagnostics Cluster on Endpoint 0 with EnableKey field set to PIXIT.DEM.TEST_EVENT_TRIGGER_KEY and EventTrigger field set to PIXIT.DEM.TEST_EVENT_TRIGGER for Constraints-based Adjustment Adjustment Test Event Clear", + "Verify DUT responds w/ status SUCCESS(0x00)"), ] return steps @@ -148,26 +149,21 @@ async def test_TC_DEM_2_7(self): self.step("1") # Commission DUT - already done + self.step("2") await self.validate_feature_map([Clusters.DeviceEnergyManagement.Bitmaps.Feature.kConstraintBasedAdjustment, Clusters.DeviceEnergyManagement.Bitmaps.Feature.kPowerForecastReporting], [Clusters.DeviceEnergyManagement.Bitmaps.Feature.kStateForecastReporting]) - # Subscribe to Events and when they are sent push them to a queue for checking later - events_callback = EventChangeCallback(Clusters.DeviceEnergyManagement) - await events_callback.start(self.default_controller, - self.dut_node_id, - self.matter_test_config.endpoint) - - self.step("2") + self.step("3") await self.check_test_event_triggers_enabled() - self.step("3") + self.step("4") await self.send_test_event_trigger_constraint_based_adjustment() - self.step("3a") + self.step("4a") await self.check_dem_attribute("ESAState", Clusters.DeviceEnergyManagement.Enums.ESAStateEnum.kOnline) - self.step("3b") + self.step("4b") forecast = await self.read_dem_attribute_expect_success(attribute="Forecast") logging.info(forecast) asserts.assert_greater(forecast.slots[0].nominalPower, 0) @@ -175,10 +171,10 @@ async def test_TC_DEM_2_7(self): asserts.assert_greater(forecast.slots[0].maxPower, 0) asserts.assert_greater(forecast.slots[0].nominalEnergy, 0) - self.step("3c") + self.step("4c") await self.check_dem_attribute("OptOutState", Clusters.DeviceEnergyManagement.Enums.OptOutStateEnum.kNoOptOut) - self.step("4") + self.step("5") # Matter UTC is time since 00:00:00 1/1/2000 now = self.get_current_utc_time_in_seconds() @@ -186,7 +182,7 @@ async def test_TC_DEM_2_7(self): nominalPower=forecast.slots[0].nominalPower, maximumEnergy=forecast.slots[0].nominalEnergy)] await self.send_request_constraint_based_forecast(constraintList, cause=Clusters.DeviceEnergyManagement.Enums.AdjustmentCauseEnum.kLocalOptimization, expected_status=Status.ConstraintError) - self.step("5") + self.step("6") now = self.get_current_utc_time_in_seconds() constraintList = [Clusters.DeviceEnergyManagement.Structs.ConstraintsStruct(startTime=now + 10, duration=20, @@ -197,7 +193,7 @@ async def test_TC_DEM_2_7(self): nominalPower=forecast.slots[0].nominalPower, maximumEnergy=forecast.slots[0].nominalEnergy)] await self.send_request_constraint_based_forecast(constraintList, cause=Clusters.DeviceEnergyManagement.Enums.AdjustmentCauseEnum.kLocalOptimization, expected_status=Status.ConstraintError) - self.step("6") + self.step("7") now = self.get_current_utc_time_in_seconds() constraintList = [Clusters.DeviceEnergyManagement.Structs.ConstraintsStruct(startTime=now + 10, duration=20, @@ -208,7 +204,7 @@ async def test_TC_DEM_2_7(self): nominalPower=forecast.slots[0].nominalPower, maximumEnergy=forecast.slots[0].nominalEnergy)] await self.send_request_constraint_based_forecast(constraintList, cause=Clusters.DeviceEnergyManagement.Enums.AdjustmentCauseEnum.kLocalOptimization, expected_status=Status.ConstraintError) - self.step("7") + self.step("8") now = self.get_current_utc_time_in_seconds() constraintList = [Clusters.DeviceEnergyManagement.Structs.ConstraintsStruct(startTime=now + 30, duration=20, @@ -219,7 +215,7 @@ async def test_TC_DEM_2_7(self): nominalPower=forecast.slots[0].nominalPower, maximumEnergy=forecast.slots[0].nominalEnergy)] await self.send_request_constraint_based_forecast(constraintList, cause=Clusters.DeviceEnergyManagement.Enums.AdjustmentCauseEnum.kLocalOptimization, expected_status=Status.ConstraintError) - self.step("8") + self.step("9") now = self.get_current_utc_time_in_seconds() constraintList = [Clusters.DeviceEnergyManagement.Structs.ConstraintsStruct(startTime=now + 10, duration=20, @@ -230,118 +226,118 @@ async def test_TC_DEM_2_7(self): nominalPower=forecast.slots[0].nominalPower, maximumEnergy=forecast.slots[0].nominalEnergy)] await self.send_request_constraint_based_forecast(constraintList, cause=Clusters.DeviceEnergyManagement.Enums.AdjustmentCauseEnum.kLocalOptimization, expected_status=Status.ConstraintError) - self.step("9") + self.step("10") absMaxPower = await self.read_dem_attribute_expect_success(attribute="AbsMaxPower") - self.step("9a") + self.step("10a") constraintList = [Clusters.DeviceEnergyManagement.Structs.ConstraintsStruct( startTime=forecast.startTime, duration=forecast.slots[0].defaultDuration, nominalPower=absMaxPower + 1, maximumEnergy=forecast.slots[0].nominalEnergy)] await self.send_request_constraint_based_forecast(constraintList, cause=Clusters.DeviceEnergyManagement.Enums.AdjustmentCauseEnum.kLocalOptimization, expected_status=Status.ConstraintError) - self.step("10") + self.step("11") absMinPower = await self.read_dem_attribute_expect_success(attribute="AbsMinPower") - self.step("10a") + self.step("11a") constraintList = [Clusters.DeviceEnergyManagement.Structs.ConstraintsStruct( startTime=forecast.startTime, duration=forecast.slots[0].defaultDuration, nominalPower=absMinPower - 1, maximumEnergy=forecast.slots[0].nominalEnergy)] await self.send_request_constraint_based_forecast(constraintList, cause=Clusters.DeviceEnergyManagement.Enums.AdjustmentCauseEnum.kLocalOptimization, expected_status=Status.ConstraintError) - self.step("11") + self.step("12") constraintList = [Clusters.DeviceEnergyManagement.Structs.ConstraintsStruct( startTime=forecast.startTime, duration=forecast.slots[0].defaultDuration, nominalPower=forecast.slots[0].nominalPower)] await self.send_request_constraint_based_forecast(constraintList, cause=Clusters.DeviceEnergyManagement.Enums.AdjustmentCauseEnum.kLocalOptimization, expected_status=Status.InvalidCommand) - self.step("12") + self.step("13") constraintList = [Clusters.DeviceEnergyManagement.Structs.ConstraintsStruct( startTime=forecast.startTime, duration=forecast.slots[0].defaultDuration, maximumEnergy=forecast.slots[0].nominalEnergy)] await self.send_request_constraint_based_forecast(constraintList, cause=Clusters.DeviceEnergyManagement.Enums.AdjustmentCauseEnum.kLocalOptimization, expected_status=Status.InvalidCommand) - self.step("13") + self.step("14") await self.send_test_event_trigger_user_opt_out_local() - self.step("13a") + self.step("14a") await self.check_dem_attribute("ESAState", Clusters.DeviceEnergyManagement.Enums.ESAStateEnum.kOnline) - self.step("13b") + self.step("14b") await self.check_dem_attribute("OptOutState", Clusters.DeviceEnergyManagement.Enums.OptOutStateEnum.kLocalOptOut) - self.step("14") + self.step("15") constraintList = [Clusters.DeviceEnergyManagement.Structs.ConstraintsStruct( startTime=forecast.startTime, duration=forecast.slots[0].defaultDuration, nominalPower=forecast.slots[0].nominalPower, maximumEnergy=forecast.slots[0].nominalEnergy)] await self.send_request_constraint_based_forecast(constraintList, cause=Clusters.DeviceEnergyManagement.Enums.AdjustmentCauseEnum.kLocalOptimization, expected_status=Status.ConstraintError) - self.step("15") + self.step("16") constraintList = [Clusters.DeviceEnergyManagement.Structs.ConstraintsStruct( startTime=forecast.startTime, duration=forecast.slots[0].defaultDuration, nominalPower=forecast.slots[0].nominalPower, maximumEnergy=forecast.slots[0].nominalEnergy)] await self.send_request_constraint_based_forecast(constraintList, cause=Clusters.DeviceEnergyManagement.Enums.AdjustmentCauseEnum.kGridOptimization, expected_status=Status.Success) - self.step("15a") + self.step("16a") forecast = await self.read_dem_attribute_expect_success(attribute="Forecast") asserts.assert_equal(forecast.forecastUpdateReason, Clusters.DeviceEnergyManagement.Enums.ForecastUpdateReasonEnum.kGridOptimization) - self.step("16") + self.step("17") await self.send_cancel_request_command() - self.step("16a") + self.step("17a") forecast = await self.read_dem_attribute_expect_success(attribute="Forecast") asserts.assert_equal(forecast.forecastUpdateReason, Clusters.DeviceEnergyManagement.Enums.ForecastUpdateReasonEnum.kInternalOptimization) - self.step("17") + self.step("18") constraintList = [Clusters.DeviceEnergyManagement.Structs.ConstraintsStruct( startTime=forecast.startTime, duration=forecast.slots[0].defaultDuration, nominalPower=forecast.slots[0].nominalPower, maximumEnergy=forecast.slots[0].nominalEnergy)] await self.send_request_constraint_based_forecast(constraintList, cause=Clusters.DeviceEnergyManagement.Enums.AdjustmentCauseEnum.kGridOptimization, expected_status=Status.Success) - self.step("17a") + self.step("18a") forecast = await self.read_dem_attribute_expect_success(attribute="Forecast") asserts.assert_equal(forecast.forecastUpdateReason, Clusters.DeviceEnergyManagement.Enums.ForecastUpdateReasonEnum.kGridOptimization) - self.step("18") + self.step("19") await self.send_test_event_trigger_user_opt_out_grid() - self.step("18a") + self.step("19a") await self.check_dem_attribute("OptOutState", Clusters.DeviceEnergyManagement.Enums.OptOutStateEnum.kOptOut) - self.step("18b") + self.step("19b") forecast = await self.read_dem_attribute_expect_success(attribute="Forecast") asserts.assert_equal(forecast.forecastUpdateReason, Clusters.DeviceEnergyManagement.Enums.ForecastUpdateReasonEnum.kInternalOptimization) - self.step("19") + self.step("20") constraintList = [Clusters.DeviceEnergyManagement.Structs.ConstraintsStruct( startTime=forecast.startTime, duration=forecast.slots[0].defaultDuration, nominalPower=forecast.slots[0].nominalPower, maximumEnergy=forecast.slots[0].nominalEnergy)] await self.send_request_constraint_based_forecast(constraintList, cause=Clusters.DeviceEnergyManagement.Enums.AdjustmentCauseEnum.kGridOptimization, expected_status=Status.ConstraintError) - self.step("20") + self.step("21") await self.send_test_event_trigger_user_opt_out_clear_all() - self.step("20a") + self.step("21a") await self.check_dem_attribute("OptOutState", Clusters.DeviceEnergyManagement.Enums.OptOutStateEnum.kNoOptOut) - self.step("21") + self.step("22") constraintList = [Clusters.DeviceEnergyManagement.Structs.ConstraintsStruct( startTime=forecast.startTime, duration=forecast.slots[0].defaultDuration, nominalPower=forecast.slots[0].nominalPower, maximumEnergy=forecast.slots[0].nominalEnergy)] await self.send_request_constraint_based_forecast(constraintList, cause=Clusters.DeviceEnergyManagement.Enums.AdjustmentCauseEnum.kLocalOptimization, expected_status=Status.Success) - self.step("21a") + self.step("22a") forecast = await self.read_dem_attribute_expect_success(attribute="Forecast") asserts.assert_equal(forecast.forecastUpdateReason, Clusters.DeviceEnergyManagement.Enums.ForecastUpdateReasonEnum.kLocalOptimization) - self.step("22") + self.step("23") await self.send_cancel_request_command() - self.step("22a") + self.step("23a") forecast = await self.read_dem_attribute_expect_success(attribute="Forecast") asserts.assert_equal(forecast.forecastUpdateReason, Clusters.DeviceEnergyManagement.Enums.ForecastUpdateReasonEnum.kInternalOptimization) - self.step("23") + self.step("24") await self.send_cancel_request_command(expected_status=Status.InvalidInState) - self.step("24") + self.step("25") await self.send_test_event_trigger_constraint_based_adjustment_clear() diff --git a/src/python_testing/TC_DEM_2_8.py b/src/python_testing/TC_DEM_2_8.py index 1c081be96e63f3..ccb9554f50498b 100644 --- a/src/python_testing/TC_DEM_2_8.py +++ b/src/python_testing/TC_DEM_2_8.py @@ -34,7 +34,7 @@ import chip.clusters as Clusters from chip.interaction_model import Status -from matter_testing_support import EventChangeCallback, MatterBaseTest, TestStep, async_test_body, default_matter_test_main +from matter_testing_support import MatterBaseTest, TestStep, async_test_body, default_matter_test_main from mobly import asserts from TC_DEMTestBase import DEMTestBase @@ -59,76 +59,77 @@ def pics_TC_DEM_2_8(self): def steps_TC_DEM_2_8(self) -> list[TestStep]: """Execute the test steps.""" steps = [ - TestStep("1", "Commissioning, already done", - is_commissioning=True), - TestStep("2", "TH reads TestEventTriggersEnabled attribute from General Diagnostics Cluster.", - "Verify value is 1 (True)"), - TestStep("3", "TH sends TestEventTrigger command to General Diagnostics Cluster on Endpoint 0 with EnableKey field set to PIXIT.DEM.TEST_EVENT_TRIGGER_KEY and EventTrigger field set to PIXIT.DEM.TEST_EVENT_TRIGGER for Constraints-based Adjustment Test Event.", - "Verify DUT responds with status SUCCESS(0x00)"), - TestStep("3a", "TH reads ESAState attribute.", - "Verify value is 0x01 (Online)"), - TestStep("3b", "TH reads Forecast attribute.", + TestStep("1", "Commission DUT to TH (can be skipped if done in a preceding test)"), + TestStep("2", "TH reads from the DUT the _Featuremap_ attribute", + "Verify that the DUT response contains the _Featuremap_ attribute. Verify ConstraintBasedAdjustment and StateForecastReporting is supported. Verify PowerForecastReporting is not supported."), + TestStep("3", "TH reads TestEventTriggersEnabled attribute from General Diagnostics Cluster", + "Value has to be 1 (True)"), + TestStep("4", "TH sends TestEventTrigger command to General Diagnostics Cluster on Endpoint 0 with EnableKey field set to PIXIT.DEM.TEST_EVENT_TRIGGER_KEY and EventTrigger field set to PIXIT.DEM.TEST_EVENT_TRIGGER for Constraints-based Adjustment Test Event", + "Verify DUT responds w/ status SUCCESS(0x00)"), + TestStep("4a", "TH reads from the DUT the ESAState", + "Value has to be 0x01 (Online)"), + TestStep("4b", "TH reads from the DUT the Forecast", "Value has to include valid slots[0].ManufacturerESAState"), - TestStep("3c", "TH reads OptOutState attribute.", - "Verify value is 0x00 (NoOptOut)"), - TestStep("4", "TH sends RequestConstraintBasedPowerForecast with constraints[0].{StartTime=now()-10, Duration=20, LoadControl=0}, Cause=LocalOptimization.", - "Verify DUT responds with status CONSTRAINT_ERROR(0x87)"), - TestStep("5", "TH sends RequestConstraintBasedPowerForecast with constraints[0].{StartTime=now()+10, Duration=20, LoadControl=0}, constraints[1].{StartTime=now()+20, Duration=20, LoadControl=0}, constraints[2].{StartTime=now()+50, Duration=20, LoadControl=0}, Cause=LocalOptimization.", - "Verify DUT responds with status CONSTRAINT_ERROR(0x87)"), - TestStep("6", "TH sends RequestConstraintBasedPowerForecast with constraints[0].{StartTime=now()+10, Duration=20, LoadControl=0}, constraints[1].{StartTime=now()+30, Duration=20, LoadControl=0}, constraints[2].{StartTime=now()+40, Duration=20, LoadControl=0}, Cause=LocalOptimization.", - "Verify DUT responds with status CONSTRAINT_ERROR(0x87)"), - TestStep("7", "TH sends RequestConstraintBasedPowerForecast with constraints[0].{StartTime=now()+30, Duration=20, LoadControl=0}, constraints[1].{StartTime=now()+10, Duration=20, LoadControl=0}, constraints[2].{StartTime=now()+50, Duration=20, LoadControl=0}, Cause=LocalOptimization.", - "Verify DUT responds with status CONSTRAINT_ERROR(0x87)"), - TestStep("8", "TH sends RequestConstraintBasedPowerForecast with constraints[0].{StartTime=now()+10, Duration=20, LoadControl=0}, constraints[1].{StartTime=now()+50, Duration=20, LoadControl=0}, constraints[2].{StartTime=now()+30, Duration=20, LoadControl=0}, Cause=LocalOptimization.", - "Verify DUT responds with status CONSTRAINT_ERROR(0x87)"), - TestStep("9", "TH sends RequestConstraintBasedPowerForecast with constraints[0].{StartTime=Forecast.StartTime, Duration=Forecast.Slots[0].DefaultDuration, LoadControl=101}, Cause=LocalOptimization.", - "Verify DUT responds with status CONSTRAINT_ERROR(0x87)"), - TestStep("10", "TH sends RequestConstraintBasedPowerForecast with constraints[0].{StartTime=Forecast.StartTime, Duration=Forecast.Slots[0].DefaultDuration, LoadControl=-101}, Cause=LocalOptimization.", - "Verify DUT responds with status CONSTRAINT_ERROR(0x87)"), - TestStep("11", "TH sends TestEventTrigger command to General Diagnostics Cluster on Endpoint 0 with EnableKey field set to PIXIT.DEM.TEST_EVENT_TRIGGER_KEY and EventTrigger field set to PIXIT.DEM.TEST_EVENT_TRIGGER for User Opt-out Local Optimization Test Event.", - "Verify DUT responds with status SUCCESS(0x00)"), - TestStep("11a", "TH reads ESAState attribute.", - "Verify value is 0x01 (Online)"), - TestStep("11b", "TH reads OptOutState attribute.", - "Verify value is 0x02 (LocalOptOut)"), - TestStep("12", "TH sends RequestConstraintBasedPowerForecast with constraints[0].{StartTime=Forecast.StartTime, Duration=Forecast.Slots[0].DefaultDuration, LoadControl=1}, Cause=LocalOptimization.", - "Verify DUT responds with status CONSTRAINT_ERROR(0x87)"), - TestStep("13", "TH sends RequestConstraintBasedPowerForecast with constraints[0].{StartTime=Forecast.StartTime, Duration=Forecast.Slots[0].DefaultDuration, LoadControl=1}, Cause=GridOptimization.", - "Verify DUT responds with status SUCCESS(0x00)"), - TestStep("13a", "TH reads Forecast attribute.", + TestStep("4c", "TH reads from the DUT the OptOutState", + "Value has to be 0x00 (NoOptOut)"), + TestStep("5", "TH sends command RequestConstraintBasedPowerForecast with constraints[0].{StartTime=now()-10, Duration=20, LoadControl=0}, Cause=LocalOptimization", + "Verify DUT responds w/ status CONSTRAINT_ERROR(0x87)"), + TestStep("6", "TH sends command RequestConstraintBasedPowerForecast with constraints[0].{StartTime=now()+10, Duration=20, LoadControl=0}, constraints[1].{StartTime=now()+20, Duration=20, LoadControl=0}, constraints[2].{StartTime=now()+50, Duration=20, LoadControl=0}, Cause=LocalOptimization", + "Verify DUT responds w/ status CONSTRAINT_ERROR(0x87)"), + TestStep("7", "TH sends command RequestConstraintBasedPowerForecast with constraints[0].{StartTime=now()+10, Duration=20, LoadControl=0}, constraints[1].{StartTime=now()+30, Duration=20, LoadControl=0}, constraints[2].{StartTime=now()+40, Duration=20, LoadControl=0}, Cause=LocalOptimization", + "Verify DUT responds w/ status CONSTRAINT_ERROR(0x87)"), + TestStep("8", "TH sends command RequestConstraintBasedPowerForecast with constraints[0].{StartTime=now()+30, Duration=20, LoadControl=0}, constraints[1].{StartTime=now()+10, Duration=20, LoadControl=0}, constraints[2].{StartTime=now()+50, Duration=20, LoadControl=0}, Cause=LocalOptimization", + "Verify DUT responds w/ status CONSTRAINT_ERROR(0x87)"), + TestStep("9", "TH sends command RequestConstraintBasedPowerForecast with constraints[0].{StartTime=now()+10, Duration=20, LoadControl=0}, constraints[1].{StartTime=now()+50, Duration=20, LoadControl=0}, constraints[2].{StartTime=now()+30, Duration=20, LoadControl=0}, Cause=LocalOptimization", + "Verify DUT responds w/ status CONSTRAINT_ERROR(0x87)"), + TestStep("10", "TH sends command RequestConstraintBasedPowerForecast with constraints[0].{StartTime=Forecast.StartTime, Duration=Forecast.Slots[0].DefaultDuration, LoadControl=101}, Cause=LocalOptimization", + "Verify DUT responds w/ status CONSTRAINT_ERROR(0x87)"), + TestStep("11", "TH sends command RequestConstraintBasedPowerForecast with constraints[0].{StartTime=Forecast.StartTime, Duration=Forecast.Slots[0].DefaultDuration, LoadControl=-101}, Cause=LocalOptimization", + "Verify DUT responds w/ status CONSTRAINT_ERROR(0x87)"), + TestStep("12", "TH sends TestEventTrigger command to General Diagnostics Cluster on Endpoint 0 with EnableKey field set to PIXIT.DEM.TEST_EVENT_TRIGGER_KEY and EventTrigger field set to PIXIT.DEM.TEST_EVENT_TRIGGER for User Opt-out Local Optimization Test Event", + "Verify DUT responds w/ status SUCCESS(0x00)"), + TestStep("12a", "TH reads from the DUT the ESAState", + "Value has to be 0x01 (Online)"), + TestStep("12b", "TH reads from the DUT the OptOutState", + "Value has to be 0x02 (LocalOptOut)"), + TestStep("13", "TH sends command RequestConstraintBasedPowerForecast with constraints[0].{StartTime=Forecast.StartTime, Duration=Forecast.Slots[0].DefaultDuration, LoadControl=1}, Cause=LocalOptimization", + "Verify DUT responds w/ status CONSTRAINT_ERROR(0x87)"), + TestStep("14", "TH sends command RequestConstraintBasedPowerForecast with constraints[0].{StartTime=Forecast.StartTime, Duration=Forecast.Slots[0].DefaultDuration, LoadControl=1}, Cause=GridOptimization", + "Verify DUT responds w/ status SUCCESS(0x00)"), + TestStep("14a", "TH reads from the DUT the Forecast", "Value has to include ForecastUpdateReason=GridOptimization"), - TestStep("14", "TH sends CancelRequest.", - "Verify DUT responds with status SUCCESS(0x00)"), - TestStep("14a", "TH reads Forecast attribute.", + TestStep("15", "TH sends command CancelRequest", + "Verify DUT responds w/ status SUCCESS(0x00)"), + TestStep("15a", "TH reads from the DUT the Forecast", "Value has to include ForecastUpdateReason=InternalOptimization"), - TestStep("15", "TH sends RequestConstraintBasedPowerForecast with constraints[0].{StartTime=Forecast.StartTime, Duration=Forecast.Slots[0].DefaultDuration, LoadControl=1}, Cause=GridOptimization.", - "Verify DUT responds with status SUCCESS(0x00)"), - TestStep("15a", "TH reads Forecast attribute.", + TestStep("16", "TH sends command RequestConstraintBasedPowerForecast with constraints[0].{StartTime=Forecast.StartTime, Duration=Forecast.Slots[0].DefaultDuration, LoadControl=1}, Cause=GridOptimization", + "Verify DUT responds w/ status SUCCESS(0x00)"), + TestStep("16a", "TH reads from the DUT the Forecast", "Value has to include ForecastUpdateReason=GridOptimization"), - TestStep("16", "TH sends TestEventTrigger command to General Diagnostics Cluster on Endpoint 0 with EnableKey field set to PIXIT.DEM.TEST_EVENT_TRIGGER_KEY and EventTrigger field set to PIXIT.DEM.TEST_EVENT_TRIGGER for User Opt-out Grid Optimization Test Event.", - "Verify DUT responds with status SUCCESS(0x00)"), - TestStep("16a", "TH reads OptOutState attribute.", - "Verify value is 0x03 (OptOut)"), - TestStep("16b", "TH reads Forecast attribute.", + TestStep("17", "TH sends TestEventTrigger command to General Diagnostics Cluster on Endpoint 0 with EnableKey field set to PIXIT.DEM.TEST_EVENT_TRIGGER_KEY and EventTrigger field set to PIXIT.DEM.TEST_EVENT_TRIGGER for User Opt-out Grid Optimization Test Event", + "Verify DUT responds w/ status SUCCESS(0x00)"), + TestStep("17a", "TH reads from the DUT the OptOutState", + "Value has to be 0x03 (OptOut)"), + TestStep("17b", "TH reads from the DUT the Forecast", "Value has to include ForecastUpdateReason=InternalOptimization"), - TestStep("17", "TH sends RequestConstraintBasedPowerForecast with constraints[0].{StartTime=Forecast.StartTime, Duration=Forecast.Slots[0].DefaultDuration, LoadControl=1}, Cause=GridOptimization.", - "Verify DUT responds with status CONSTRAINT_ERROR(0x87)"), - TestStep("18", "TH sends TestEventTrigger command to General Diagnostics Cluster on Endpoint 0 with EnableKey field set to PIXIT.DEM.TEST_EVENT_TRIGGER_KEY and EventTrigger field set to PIXIT.DEM.TEST_EVENT_TRIGGER for User Opt-out Test Event Clear.", - "Verify DUT responds with status SUCCESS(0x00)"), - TestStep("18a", "TH reads OptOutState attribute.", - "Verify value is 0x00 (NoOptOut)"), - TestStep("19", "TH sends RequestConstraintBasedPowerForecast with constraints[0].{StartTime=Forecast.StartTime, Duration=Forecast.Slots[0].DefaultDuration, LoadControl=1}, Cause=LocalOptimization.", - "Verify DUT responds with status SUCCESS(0x00)"), - TestStep("19a", "TH reads Forecast attribute.", + TestStep("18", "TH sends command RequestConstraintBasedPowerForecast with constraints[0].{StartTime=Forecast.StartTime, Duration=Forecast.Slots[0].DefaultDuration, LoadControl=1}, Cause=GridOptimization", + "Verify DUT responds w/ status CONSTRAINT_ERROR(0x87)"), + TestStep("19", "TH sends TestEventTrigger command to General Diagnostics Cluster on Endpoint 0 with EnableKey field set to PIXIT.DEM.TEST_EVENT_TRIGGER_KEY and EventTrigger field set to PIXIT.DEM.TEST_EVENT_TRIGGER for User Opt-out Test Event Clear", + "Verify DUT responds w/ status SUCCESS(0x00)"), + TestStep("19a", "TH reads from the DUT the OptOutState", + "Value has to be 0x00 (NoOptOut)"), + TestStep("20", "TH sends command RequestConstraintBasedPowerForecast with constraints[0].{StartTime=Forecast.StartTime, Duration=Forecast.Slots[0].DefaultDuration, LoadControl=1}, Cause=LocalOptimization", + "Verify DUT responds w/ status SUCCESS(0x00)"), + TestStep("20a", "TH reads from the DUT the Forecast", "Value has to include ForecastUpdateReason=LocalOptimization"), - TestStep("20", "TH sends CancelRequest.", - "Verify DUT responds with status SUCCESS(0x00)"), - TestStep("20a", "TH reads Forecast attribute.", + TestStep("21", "TH sends command CancelRequest", + "Verify DUT responds w/ status SUCCESS(0x00)"), + TestStep("21a", "TH reads from the DUT the Forecast", "Value has to include ForecastUpdateReason=InternalOptimization"), - TestStep("21", "TH sends CancelRequest.", - "Verify DUT responds with status INVALID_IN_STATE(0xcb)"), - TestStep("22", "TH sends TestEventTrigger command to General Diagnostics Cluster on Endpoint 0 with EnableKey field set to PIXIT.DEM.TEST_EVENT_TRIGGER_KEY and EventTrigger field set to PIXIT.DEM.TEST_EVENT_TRIGGER for Constraints-based Adjustment Adjustment Test Event Clear.", - "Verify DUT responds with status SUCCESS(0x00)"), + TestStep("22", "TH sends command CancelRequest", + "Verify DUT responds w/ status INVALID_IN_STATE(0xcb)"), + TestStep("23", "TH sends TestEventTrigger command to General Diagnostics Cluster on Endpoint 0 with EnableKey field set to PIXIT.DEM.TEST_EVENT_TRIGGER_KEY and EventTrigger field set to PIXIT.DEM.TEST_EVENT_TRIGGER for Constraints-based Adjustment Adjustment Test Event Clear", + "Verify DUT responds w/ status SUCCESS(0x00)"), ] return steps @@ -140,33 +141,28 @@ async def test_TC_DEM_2_8(self): self.step("1") # Commission DUT - already done + self.step("2") await self.validate_feature_map([Clusters.DeviceEnergyManagement.Bitmaps.Feature.kConstraintBasedAdjustment, Clusters.DeviceEnergyManagement.Bitmaps.Feature.kStateForecastReporting], [Clusters.DeviceEnergyManagement.Bitmaps.Feature.kPowerForecastReporting]) - # Subscribe to Events and when they are sent push them to a queue for checking later - events_callback = EventChangeCallback(Clusters.DeviceEnergyManagement) - await events_callback.start(self.default_controller, - self.dut_node_id, - self.matter_test_config.endpoint) - - self.step("2") + self.step("3") await self.check_test_event_triggers_enabled() - self.step("3") + self.step("4") await self.send_test_event_trigger_constraint_based_adjustment() - self.step("3a") + self.step("4a") await self.check_dem_attribute("ESAState", Clusters.DeviceEnergyManagement.Enums.ESAStateEnum.kOnline) - self.step("3b") + self.step("4b") forecast = await self.read_dem_attribute_expect_success(attribute="Forecast") asserts.assert_is_not_none(forecast.slots[0].manufacturerESAState) - self.step("3c") + self.step("4c") await self.check_dem_attribute("OptOutState", Clusters.DeviceEnergyManagement.Enums.OptOutStateEnum.kNoOptOut) - self.step("4") + self.step("5") # Matter UTC is time since 00:00:00 1/1/2000 now = self.get_current_utc_time_in_seconds() @@ -174,7 +170,7 @@ async def test_TC_DEM_2_8(self): startTime=now - 10, duration=20, loadControl=0)] await self.send_request_constraint_based_forecast(constraintList, cause=Clusters.DeviceEnergyManagement.Enums.AdjustmentCauseEnum.kLocalOptimization, expected_status=Status.ConstraintError) - self.step("5") + self.step("6") # Matter UTC is time since 00:00:00 1/1/2000 now = self.get_current_utc_time_in_seconds() @@ -183,7 +179,7 @@ async def test_TC_DEM_2_8(self): Clusters.DeviceEnergyManagement.Structs.ConstraintsStruct(startTime=now + 50, duration=20, loadControl=0)] await self.send_request_constraint_based_forecast(constraintList, cause=Clusters.DeviceEnergyManagement.Enums.AdjustmentCauseEnum.kLocalOptimization, expected_status=Status.ConstraintError) - self.step("6") + self.step("7") # Matter UTC is time since 00:00:00 1/1/2000 now = self.get_current_utc_time_in_seconds() @@ -192,7 +188,7 @@ async def test_TC_DEM_2_8(self): Clusters.DeviceEnergyManagement.Structs.ConstraintsStruct(startTime=now + 40, duration=20, loadControl=0)] await self.send_request_constraint_based_forecast(constraintList, cause=Clusters.DeviceEnergyManagement.Enums.AdjustmentCauseEnum.kLocalOptimization, expected_status=Status.ConstraintError) - self.step("7") + self.step("8") now = self.get_current_utc_time_in_seconds() constraintList = [Clusters.DeviceEnergyManagement.Structs.ConstraintsStruct(startTime=now + 30, duration=20, loadControl=0), @@ -200,7 +196,7 @@ async def test_TC_DEM_2_8(self): Clusters.DeviceEnergyManagement.Structs.ConstraintsStruct(startTime=now + 50, duration=20, loadControl=0)] await self.send_request_constraint_based_forecast(constraintList, cause=Clusters.DeviceEnergyManagement.Enums.AdjustmentCauseEnum.kLocalOptimization, expected_status=Status.ConstraintError) - self.step("8") + self.step("9") now = self.get_current_utc_time_in_seconds() constraintList = [Clusters.DeviceEnergyManagement.Structs.ConstraintsStruct(startTime=now + 10, duration=20, loadControl=0), @@ -208,102 +204,102 @@ async def test_TC_DEM_2_8(self): Clusters.DeviceEnergyManagement.Structs.ConstraintsStruct(startTime=now + 30, duration=20, loadControl=0)] await self.send_request_constraint_based_forecast(constraintList, cause=Clusters.DeviceEnergyManagement.Enums.AdjustmentCauseEnum.kLocalOptimization, expected_status=Status.ConstraintError) - self.step("9") + self.step("10") constraintList = [Clusters.DeviceEnergyManagement.Structs.ConstraintsStruct( startTime=forecast.startTime, duration=forecast.slots[0].defaultDuration, loadControl=101)] await self.send_request_constraint_based_forecast(constraintList, cause=Clusters.DeviceEnergyManagement.Enums.AdjustmentCauseEnum.kLocalOptimization, expected_status=Status.ConstraintError) - self.step("10") + self.step("11") constraintList = [Clusters.DeviceEnergyManagement.Structs.ConstraintsStruct( startTime=forecast.startTime, duration=forecast.slots[0].defaultDuration, loadControl=-101)] await self.send_request_constraint_based_forecast(constraintList, cause=Clusters.DeviceEnergyManagement.Enums.AdjustmentCauseEnum.kLocalOptimization, expected_status=Status.ConstraintError) - self.step("11") + self.step("12") await self.send_test_event_trigger_user_opt_out_local() - self.step("11a") + self.step("12a") await self.check_dem_attribute("ESAState", Clusters.DeviceEnergyManagement.Enums.ESAStateEnum.kOnline) - self.step("11b") + self.step("12b") await self.check_dem_attribute("OptOutState", Clusters.DeviceEnergyManagement.Enums.OptOutStateEnum.kLocalOptOut) - self.step("12") + self.step("13") constraintList = [Clusters.DeviceEnergyManagement.Structs.ConstraintsStruct( startTime=forecast.startTime, duration=forecast.slots[0].defaultDuration, loadControl=1)] await self.send_request_constraint_based_forecast(constraintList, cause=Clusters.DeviceEnergyManagement.Enums.AdjustmentCauseEnum.kLocalOptimization, expected_status=Status.ConstraintError) - self.step("13") + self.step("14") constraintList = [Clusters.DeviceEnergyManagement.Structs.ConstraintsStruct( startTime=forecast.startTime, duration=forecast.slots[0].defaultDuration, loadControl=1)] await self.send_request_constraint_based_forecast(constraintList, cause=Clusters.DeviceEnergyManagement.Enums.AdjustmentCauseEnum.kGridOptimization, expected_status=Status.Success) - self.step("13a") + self.step("14a") forecast = await self.read_dem_attribute_expect_success(attribute="Forecast") asserts.assert_equal(forecast.forecastUpdateReason, Clusters.DeviceEnergyManagement.Enums.ForecastUpdateReasonEnum.kGridOptimization) - self.step("14") + self.step("15") await self.send_cancel_request_command() - self.step("14a") + self.step("15a") forecast = await self.read_dem_attribute_expect_success(attribute="Forecast") asserts.assert_equal(forecast.forecastUpdateReason, Clusters.DeviceEnergyManagement.Enums.ForecastUpdateReasonEnum.kInternalOptimization) - self.step("15") + self.step("16") constraintList = [Clusters.DeviceEnergyManagement.Structs.ConstraintsStruct( startTime=forecast.startTime, duration=forecast.slots[0].defaultDuration, loadControl=1)] await self.send_request_constraint_based_forecast(constraintList, cause=Clusters.DeviceEnergyManagement.Enums.AdjustmentCauseEnum.kGridOptimization, expected_status=Status.Success) - self.step("15a") + self.step("16a") forecast = await self.read_dem_attribute_expect_success(attribute="Forecast") asserts.assert_equal(forecast.forecastUpdateReason, Clusters.DeviceEnergyManagement.Enums.ForecastUpdateReasonEnum.kGridOptimization) - self.step("16") + self.step("17") await self.send_test_event_trigger_user_opt_out_grid() - self.step("16a") + self.step("17a") await self.check_dem_attribute("OptOutState", Clusters.DeviceEnergyManagement.Enums.OptOutStateEnum.kOptOut) - self.step("16b") + self.step("17b") forecast = await self.read_dem_attribute_expect_success(attribute="Forecast") asserts.assert_equal(forecast.forecastUpdateReason, Clusters.DeviceEnergyManagement.Enums.ForecastUpdateReasonEnum.kInternalOptimization) - self.step("17") + self.step("18") constraintList = [Clusters.DeviceEnergyManagement.Structs.ConstraintsStruct( startTime=forecast.startTime, duration=forecast.slots[0].defaultDuration, loadControl=1)] await self.send_request_constraint_based_forecast(constraintList, cause=Clusters.DeviceEnergyManagement.Enums.AdjustmentCauseEnum.kGridOptimization, expected_status=Status.ConstraintError) - self.step("18") + self.step("19") await self.send_test_event_trigger_user_opt_out_clear_all() - self.step("18a") + self.step("19a") await self.check_dem_attribute("OptOutState", Clusters.DeviceEnergyManagement.Enums.OptOutStateEnum.kNoOptOut) - self.step("19") + self.step("20") constraintList = [Clusters.DeviceEnergyManagement.Structs.ConstraintsStruct( startTime=forecast.startTime, duration=forecast.slots[0].defaultDuration, loadControl=1)] await self.send_request_constraint_based_forecast(constraintList, cause=Clusters.DeviceEnergyManagement.Enums.AdjustmentCauseEnum.kLocalOptimization, expected_status=Status.Success) - self.step("19a") + self.step("20a") forecast = await self.read_dem_attribute_expect_success(attribute="Forecast") asserts.assert_equal(forecast.forecastUpdateReason, Clusters.DeviceEnergyManagement.Enums.ForecastUpdateReasonEnum.kLocalOptimization) - self.step("20") + self.step("21") await self.send_cancel_request_command() - self.step("20a") + self.step("21a") forecast = await self.read_dem_attribute_expect_success(attribute="Forecast") asserts.assert_equal(forecast.forecastUpdateReason, Clusters.DeviceEnergyManagement.Enums.ForecastUpdateReasonEnum.kInternalOptimization) - self.step("21") + self.step("22") await self.send_cancel_request_command(expected_status=Status.InvalidInState) - self.step("22") + self.step("23") await self.send_test_event_trigger_constraint_based_adjustment_clear() diff --git a/src/python_testing/TC_DEM_2_9.py b/src/python_testing/TC_DEM_2_9.py index 5f033164cfad61..16e89f68cd9caa 100644 --- a/src/python_testing/TC_DEM_2_9.py +++ b/src/python_testing/TC_DEM_2_9.py @@ -33,7 +33,7 @@ import logging import chip.clusters as Clusters -from matter_testing_support import EventChangeCallback, MatterBaseTest, TestStep, async_test_body, default_matter_test_main +from matter_testing_support import MatterBaseTest, TestStep, async_test_body, default_matter_test_main from mobly import asserts from TC_DEMTestBase import DEMTestBase @@ -58,18 +58,19 @@ def pics_TC_DEM_2_9(self): def steps_TC_DEM_2_9(self) -> list[TestStep]: """Execute the test steps.""" steps = [ - TestStep("1", "Commissioning, already done", - is_commissioning=True), - TestStep("2", "TH reads TestEventTriggersEnabled attribute from General Diagnostics Cluster.", - "Verify that TestEventTriggersEnabled attribute has a value of 1 (True)"), - TestStep("3", "TH sends TestEventTrigger command to General Diagnostics Cluster on Endpoint 0 with EnableKey field set to PIXIT.DEM.TEST_EVENT_TRIGGER_KEY and EventTrigger field set to PIXIT.DEM.TEST_EVENT_TRIGGER for Forecast Test Event", - "Verify DUT responds with status SUCCESS(0x00)"), - TestStep("3a", "TH reads Forecast attribute.", + TestStep("1", "Commission DUT to TH (can be skipped if done in a preceding test)"), + TestStep("2", "TH reads from the DUT the _Featuremap_ attribute", + "Verify that the DUT response contains the _Featuremap_ attribute. Verify one of PowerForecastReporting or StateForecastReporting is supported but not both."), + TestStep("3", "TH reads TestEventTriggersEnabled attribute from General Diagnostics Cluster", + "Value has to be 1 (True)"), + TestStep("4", "TH sends TestEventTrigger command to General Diagnostics Cluster on Endpoint 0 with EnableKey field set to PIXIT.DEM.TEST_EVENT_TRIGGER_KEY and EventTrigger field set to PIXIT.DEM.TEST_EVENT_TRIGGER for Forecast Test Event", + "Verify DUT responds w/ status SUCCESS(0x00)"), + TestStep("4a", "TH reads from the DUT the Forecast", "Value has to include a valid slots[0].ManufacturerESAState"), - TestStep("3b", "TH reads Forecast attribute.", + TestStep("4b", "TH reads from the DUT the Forecast", "Value has to include valid slots[0].NominalPower, slots[0].MinPower, slots[0].MaxPower, slots[0].NominalEnergy"), - TestStep("4", "TH sends TestEventTrigger command to General Diagnostics Cluster on Endpoint 0 with EnableKey field set to PIXIT.DEM.TEST_EVENT_TRIGGER_KEY and EventTrigger field set to PIXIT.DEM.TEST_EVENT_TRIGGER for Forecast Test Event Clear", - "Verify DUT responds with status SUCCESS(0x00)"), + TestStep("5", "TH sends TestEventTrigger command to General Diagnostics Cluster on Endpoint 0 with EnableKey field set to PIXIT.DEM.TEST_EVENT_TRIGGER_KEY and EventTrigger field set to PIXIT.DEM.TEST_EVENT_TRIGGER for Forecast Test Event Clear", + "Verify DUT responds w/ status SUCCESS(0x00)"), ] return steps @@ -81,29 +82,24 @@ async def test_TC_DEM_2_9(self): self.step("1") # Commission DUT - already done + self.step("2") await self.validate_pfr_or_sfr_in_feature_map() - # Subscribe to Events and when they are sent push them to a queue for checking later - events_callback = EventChangeCallback(Clusters.DeviceEnergyManagement) - await events_callback.start(self.default_controller, - self.dut_node_id, - self.matter_test_config.endpoint) - - self.step("2") + self.step("3") await self.check_test_event_triggers_enabled() - self.step("3") + self.step("4") await self.send_test_event_trigger_forecast() - self.step("3a") + self.step("4a") feature_map = await self.read_dem_attribute_expect_success(attribute="FeatureMap") if feature_map & Clusters.DeviceEnergyManagement.Bitmaps.Feature.kStateForecastReporting: forecast = await self.read_dem_attribute_expect_success(attribute="Forecast") asserts.assert_is_not_none(forecast.slots[0].manufacturerESAState) else: - logging.info('Device does not support StateForecastReporting. Skipping step 3a') + logging.info('Device does not support StateForecastReporting. Skipping step 4a') - self.step("3b") + self.step("4b") if feature_map & Clusters.DeviceEnergyManagement.Bitmaps.Feature.kPowerForecastReporting: forecast = await self.read_dem_attribute_expect_success(attribute="Forecast") @@ -112,9 +108,9 @@ async def test_TC_DEM_2_9(self): asserts.assert_is_not_none(forecast.slots[0].maxPower) asserts.assert_is_not_none(forecast.slots[0].nominalEnergy) else: - logging.info('Device does not support StateForecastReporting. Skipping step 3b') + logging.info('Device does not support StateForecastReporting. Skipping step 4b') - self.step("4") + self.step("5") await self.send_test_event_trigger_forecast_clear()