From b9e2ba9157addb492ec5e2e47638ef9c73430b98 Mon Sep 17 00:00:00 2001 From: lpbeliveau-silabs Date: Thu, 25 Jul 2024 07:59:22 -0400 Subject: [PATCH] Converted CC_10_1 to python test --- .github/workflows/tests.yaml | 1 + .../suites/certification/Test_TC_CC_10_1.yaml | 975 ------------------ src/python_testing/TC_CC_10_1.py | 484 +++++++++ 3 files changed, 485 insertions(+), 975 deletions(-) delete mode 100644 src/app/tests/suites/certification/Test_TC_CC_10_1.yaml create mode 100644 src/python_testing/TC_CC_10_1.py diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index 53195008ba4222..e17bbe7e60f03c 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -501,6 +501,7 @@ jobs: scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --load-from-env /tmp/test_env.yaml --script src/python_testing/TC_ACE_1_4.py' scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --load-from-env /tmp/test_env.yaml --script src/python_testing/TC_ACE_1_5.py' scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --load-from-env /tmp/test_env.yaml --script src/python_testing/TC_AccessChecker.py' + scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --load-from-env /tmp/test_env.yaml --script src/python_testing/TC_CC_10_1.py' scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --load-from-env /tmp/test_env.yaml --script src/python_testing/TC_CGEN_2_4.py' scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --load-from-env /tmp/test_env.yaml --script src/python_testing/TC_DA_1_2.py' scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --load-from-env /tmp/test_env.yaml --script src/python_testing/TC_DA_1_5.py' diff --git a/src/app/tests/suites/certification/Test_TC_CC_10_1.yaml b/src/app/tests/suites/certification/Test_TC_CC_10_1.yaml deleted file mode 100644 index 0a9f9408f8a187..00000000000000 --- a/src/app/tests/suites/certification/Test_TC_CC_10_1.yaml +++ /dev/null @@ -1,975 +0,0 @@ -# Copyright (c) 2021 Project CHIP Authors -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -name: 4.2.4. [TC-LVL-10.1] Scenes Management Cluster Interaction (DUT as Server) - -PICS: - - CC.S - - S.S - -config: - nodeId: 0x12344321 - cluster: "Scenes Management" - endpoint: 1 - G1: - type: group_id - defaultValue: 0x0001 - -tests: - - label: "Wait for the commissioned device to be retrieved" - cluster: "DelayCommands" - command: "WaitForCommissionee" - arguments: - values: - - name: "nodeId" - value: nodeId - - - label: - "Step 0a :TH sends KeySetWrite command in the GroupKeyManagement - cluster to DUT using a key that is pre-installed on the TH. - GroupKeySet fields are as follows:" - cluster: "Group Key Management" - endpoint: 0 - command: "KeySetWrite" - arguments: - values: - - name: "GroupKeySet" - value: - { - GroupKeySetID: 0x01a1, - GroupKeySecurityPolicy: 0, - EpochKey0: "\xa0\xa1\xa2\xa3\xa4\xa5\xa6\xa7\xa8\xa9\xaa\xab\xac\xad\xae\xaf", - EpochStartTime0: 1110000, - EpochKey1: "\xb0\xb1\xb2\xb3\xb4\xb5\xb6\xb7\xb8\xb9\xba\xbb\xbc\xbd\xbe\xbf", - EpochStartTime1: 1110001, - EpochKey2: "\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf", - EpochStartTime2: 1110002, - } - - - label: - "Step 0b: TH binds GroupIds 0x0001 and 0x0002 with GroupKeySetID - 0x01a1 in the GroupKeyMap attribute list on GroupKeyManagement cluster - by writing the GroupKeyMap attribute with two entries as follows:" - cluster: "Group Key Management" - endpoint: 0 - command: "writeAttribute" - attribute: "GroupKeyMap" - arguments: - value: [{ FabricIndex: 1, GroupId: G1, GroupKeySetID: 0x01a1 }] - - - label: "Step 0c: TH sends a RemoveAllGroups command to DUT." - cluster: "Groups" - endpoint: endpoint - command: "RemoveAllGroups" - - - label: - "Step 1a: TH sends a AddGroup command to DUT with the GroupID field - set to G1." - cluster: "Groups" - command: "AddGroup" - arguments: - values: - - name: "GroupID" - value: G1 - - name: "GroupName" - value: "Group1" - response: - values: - - name: "Status" - value: 0 - - name: "GroupID" - value: G1 - - - label: - "Step 1b: TH sends a RemoveAllScenes command to DUT with the GroupID - field set to G1." - command: "RemoveAllScenes" - arguments: - values: - - name: "GroupID" - value: G1 - response: - values: - - name: "Status" - value: 0x00 - - name: "GroupID" - value: G1 - - label: - "Step 1c: TH sends a GetSceneMembership command to DUT with the - GroupID field set to G1." - command: "GetSceneMembership" - arguments: - values: - - name: "GroupID" - value: G1 - response: - values: - - name: "Status" - value: 0x00 - - name: "GroupID" - value: G1 - - name: "SceneList" - value: [] - - - label: "Step 1d: TH reads ColorTempPhysicalMinMireds attribute from DUT" - PICS: CC.S.A400b - cluster: "Color Control" - command: "readAttribute" - attribute: "ColorTempPhysicalMinMireds" - response: - saveAs: ColorTempPhysicalMinMiredsValue - constraints: - type: int16u - minValue: 0 - maxValue: 65279 - - - label: "Step 1e: TH reads ColorTempPhysicalMaxMireds attribute from DUT." - PICS: CC.S.A400c - cluster: "Color Control" - command: "readAttribute" - attribute: "ColorTempPhysicalMaxMireds" - response: - saveAs: ColorTempPhysicalMaxMiredsValue - constraints: - type: int16u - minValue: 0 - maxValue: 65279 - - - label: - "Step 2a: TH sends MoveToHueAndSaturation command to DUT with Hue=200, - Saturation=50 and TransitionTime=0 (immediately)" - PICS: CC.S.C06.Rsp - cluster: "Color Control" - command: "MoveToHueAndSaturation" - arguments: - values: - - name: "Hue" - value: 200 - - name: "Saturation" - value: 50 - - name: "TransitionTime" - value: 0 - - name: "OptionsMask" - value: 1 - - name: "OptionsOverride" - value: 1 - - - label: "Step 2b: TH reads CurrentHue attribute from DUT" - PICS: CC.S.A0000 - cluster: "Color Control" - command: "readAttribute" - attribute: "CurrentHue" - response: - constraints: - minValue: 170 - maxValue: 230 - - - label: "Step 2b1: TH reads CurrentSaturation attribute from DUT" - PICS: CC.S.A0001 - cluster: "Color Control" - command: "readAttribute" - attribute: "CurrentSaturation" - response: - constraints: - minValue: 42 - maxValue: 58 - - - label: - "Step 2c: TH sends MoveToColor command to DUT, with ColorX = - 32768/0x8000 ColorY = 19660/0x4CCC TransitionTime = 0 (immediate)" - PICS: CC.S.C07.Rsp - cluster: "Color Control" - command: "MoveToColor" - arguments: - values: - - name: "ColorX" - value: 32768 - - name: "ColorY" - value: 19660 - - name: "TransitionTime" - value: 0 - - name: "OptionsMask" - value: 1 - - name: "OptionsOverride" - value: 1 - - - label: "Step 2d: TH reads CurrentX attribute from DUT" - PICS: CC.S.A0003 - cluster: "Color Control" - command: "readAttribute" - attribute: "CurrentX" - response: - constraints: - minValue: 31000 - maxValue: 35000 - - - label: "Step 2d1: TH reads CurrentY attribute from DUT" - PICS: CC.S.A0004 - cluster: "Color Control" - command: "readAttribute" - attribute: "CurrentY" - response: - constraints: - minValue: 17000 - maxValue: 21000 - - - label: - "Step 2e: TH sends MoveToColorTemperature command to DUT with - ColorTemperatureMireds=(ColorTempPhysicalMinMireds + - ColorTempPhysicalMaxMireds)/2 and TransitionTime=0 (immediately)." - PICS: CC.S.F04 && CC.S.C0a.Rsp - cluster: "Color Control" - command: "MoveToColorTemperature" - arguments: - values: - - name: "ColorTemperatureMireds" - value: - ( ColorTempPhysicalMinMiredsValue + - ColorTempPhysicalMaxMiredsValue ) / 2 - - name: "TransitionTime" - value: 0 - - name: "OptionsMask" - value: 1 - - name: "OptionsOverride" - value: 1 - - - label: "Wait 100ms" - PICS: CC.S.F04 - cluster: "DelayCommands" - command: "WaitForMs" - arguments: - values: - - name: "ms" - value: 100 - - - label: - "Step 2f: TH sends MoveColorTemperature command to DUT with MoveMode = - 0x01 (up), Rate = (ColorTempPhysicalMaxMireds - - ColorTempPhysicalMinMireds)/40" - PICS: CC.S.F04 && CC.S.C4b.Rsp - cluster: "Color Control" - command: MoveColorTemperature - arguments: - values: - - name: "MoveMode" - value: 1 - - name: "Rate" - value: - ( ColorTempPhysicalMaxMiredsValue - - ColorTempPhysicalMinMiredsValue ) / 40 - - name: "ColorTemperatureMinimumMireds" - value: ColorTempPhysicalMinMiredsValue - - name: "ColorTemperatureMaximumMireds" - value: ColorTempPhysicalMaxMiredsValue - - name: "OptionsMask" - value: 1 - - name: "OptionsOverride" - value: 1 - - - label: "Wait 10s" - PICS: CC.S.F04 - cluster: "DelayCommands" - command: "WaitForMs" - arguments: - values: - - name: "ms" - value: 10000 - - - label: "Step 2g: TH reads ColorTemperatureMireds attribute from DUT." - PICS: CC.S.F04 && CC.S.A0007 && CC.S.C4b.Rsp - cluster: "Color Control" - command: "readAttribute" - attribute: "ColorTemperatureMireds" - response: - constraints: - minValue: ColorTempPhysicalMinMiredsValue - maxValue: ColorTempPhysicalMaxMiredsValue - - - label: - "Step 2h: TH sends EnhancedMoveToHueAndSaturation command to DUT with - EnhancedHue=20000, Saturation=50 and TransitionTime=0 (immediately)" - PICS: CC.S.F01 && CC.S.C43.Rsp - cluster: "Color Control" - command: "EnhancedMoveToHueAndSaturation" - arguments: - values: - - name: "EnhancedHue" - value: 20000 - - name: "Saturation" - value: 50 - - name: "TransitionTime" - value: 0 - - name: "OptionsMask" - value: 1 - - name: "OptionsOverride" - value: 1 - - - label: "Step 2b: TH reads EnhancedCurrentHue attribute from DUT" - PICS: CC.S.F01 && CC.S.A4000 - cluster: "Color Control" - command: "readAttribute" - attribute: "EnhancedCurrentHue" - response: - constraints: - minValue: 18200 - maxValue: 21800 - - - label: "Step 2b1: TH reads CurrentSaturation attribute from DUT" - PICS: CC.S.F01 && CC.S.A0001 - cluster: "Color Control" - command: "readAttribute" - attribute: "CurrentSaturation" - response: - constraints: - minValue: 42 - maxValue: 58 - - - label: - "Step 3: TH sends a StoreScene command to DUT with the GroupID field - set to G1 and the SceneID field set to 0x01." - command: "StoreScene" - arguments: - values: - - name: "GroupID" - value: G1 - - name: "SceneID" - value: 0x01 - response: - values: - - name: "Status" - value: 0x00 - - name: "GroupID" - value: G1 - - name: "SceneID" - value: 0x01 - - #Saturation - - label: - "Step 4: TH sends a _ViewScene_ command to DUT with the _GroupID_ - field set to _G~1~_ and the _SceneID_ field set to 0x01." - PICS: CC.S.C06.Rsp && CC.S.C07.Rsp && CC.S.C0a.Rsp && CC.S.C43.Rsp - command: "ViewScene" - arguments: - values: - - name: "GroupID" - value: G1 - - name: "SceneID" - value: 0x01 - response: - values: - - name: "Status" - value: 0x00 - - name: "GroupID" - value: G1 - - name: "SceneID" - value: 0x01 - - name: "TransitionTime" - value: 0 - - name: "ExtensionFieldSets" - constraints: - type: list - contains: - [ - { - ClusterID: 0x0300, - AttributeValueList: - [ - { - AttributeID: 0x0003, - ValueUnsigned16: 32768, - }, - { - AttributeID: 0x0004, - ValueUnsigned16: 19660, - }, - { - AttributeID: 0x4000, - ValueUnsigned16: 20000, - }, - { - AttributeID: 0x0001, - ValueUnsigned8: 50, - }, - { - AttributeID: 0x4002, - ValueUnsigned8: 0, - }, - { - AttributeID: 0x4003, - ValueUnsigned8: 0x00, - }, - { - AttributeID: 0x4004, - ValueUnsigned16: 25, - }, - { AttributeID: 0x0007 }, - { - AttributeID: 0x4001, - ValueUnsigned8: 0x03, - }, - ], - }, - ] - - # Note : There are too many possible combinations of the extension field sets depending on the supported features, so if they are not all supported, this step will be manual - - label: - "Step 4_1: TH sends a _ViewScene_ command to DUT with the _GroupID_ - field set to _G~1~_ and the _SceneID_ field set to 0x01." - PICS: - PICS_SKIP_SAMPLE_APP && !CC.S.C06.Rsp || !CC.S.C07.Rsp || - !CC.S.C0a.Rsp || !CC.S.C43.Rsp - verification: | - ./chip-tool scenesmanagement view-scene 0x0001 0x01 1 1 - - Verify DUT sends a ViewSceneResponse command to TH with the Status field set to 0x00 (SUCCESS), the GroupID field set to 1, the SceneID field set to 0x01, the TransitionTime field set to 0 and a set of extension fields appropriate to supported color control features. - Log and below is the sample log provided for the raspi platform: - - NOTE: The values below are expected to match the values from the specific AC tested - - [1707285444.028460][13682:13684] CHIP:DMG: }, - [1707285444.028553][13682:13684] CHIP:DMG: Received Command Response Data, Endpoint=1 Cluster=0x0000_0062 Command=0x0000_0001 - [1707285444.028579][13682:13684] CHIP:TOO: Endpoint: 1 Cluster: 0x0000_0062 Command 0x0000_0001 - [1707285444.028670][13682:13684] CHIP:TOO: ViewSceneResponse: { - [1707285444.028685][13682:13684] CHIP:TOO: status: 0 - [1707285444.028696][13682:13684] CHIP:TOO: groupID: 257 - [1707285444.028706][13682:13684] CHIP:TOO: sceneID: 3 - [1707285444.028717][13682:13684] CHIP:TOO: transitionTime: 1 - [1707285444.028728][13682:13684] CHIP:TOO: sceneName: scene name - [1707285444.028766][13682:13684] CHIP:TOO: extensionFieldSets: 1 entries - [1707285444.028814][13682:13684] CHIP:TOO: [1]: { - [1707285444.028828][13682:13684] CHIP:TOO: ClusterID: 768 - [1707285444.028853][13682:13684] CHIP:TOO: AttributeValueList: 9 entries - [1707285444.028882][13682:13684] CHIP:TOO: [1]: { - [1707285444.028925][13682:13684] CHIP:TOO: } - [1707285444.028937][13682:13684] CHIP:TOO: } - [1707285444.028950][13682:13684] CHIP:TOO: } - cluster: "LogCommands" - command: "UserPrompt" - arguments: - values: - - name: "message" - value: - "Please execute the view-scene command and verify that the - extensionfieldsets, status, groupID and SceneID are in - accordance with the suppored features on DUT and enter 'y' - if the command is successful" - - name: "expectedValue" - value: "y" - - #Saturation Scene - - label: - "Step 5a: TH sends a _AddScene_ command to DUT with the _GroupID_ - field set to _G~1~_, the _SceneID_ field set to 0x02, the - TransitionTime field set to 0 and the ExtensionFieldSets set to: '[{ - ClusterID: 0x0300, AttributeValueList: [{ AttributeID: 0x4001, - ValueUnsigned8: 0x00 }, { AttributeID: 0x0001, ValueUnsigned8: 0xFE - }]}]' " - PICS: CC.S.C03.Rsp - command: "AddScene" - arguments: - values: - - name: "GroupID" - value: G1 - - name: "SceneID" - value: 0x02 - - name: "TransitionTime" - value: 0 - - name: "SceneName" - value: "TestScene" - - name: "ExtensionFieldSets" - value: - [ - { - ClusterID: 0x0300, - AttributeValueList: - [ - { - AttributeID: 0x0001, - ValueUnsigned8: 0xFE, - }, - { - AttributeID: 0x0003, - ValueUnsigned16: 0x00, - }, - { - AttributeID: 0x0004, - ValueUnsigned16: 0x00, - }, - { - AttributeID: 0x0007, - ValueUnsigned16: 0x00, - }, - { - AttributeID: 0x4000, - ValueUnsigned16: 0x00, - }, - { - AttributeID: 0x4001, - ValueUnsigned8: 0x00, - }, - { - AttributeID: 0x4002, - ValueUnsigned8: 0x00, - }, - { - AttributeID: 0x4003, - ValueUnsigned8: 0x00, - }, - { - AttributeID: 0x4004, - ValueUnsigned16: 0x00, - }, - ], - }, - ] - response: - values: - - name: "Status" - value: 0x00 - - name: "GroupID" - value: G1 - - name: "SceneID" - value: 0x02 - - - label: - "Step 5b: TH sends a RecallScene command to DUT with the GroupID field - set to G1 and the SceneID field set to 0x02." - PICS: CC.S.C03.Rsp - command: "RecallScene" - arguments: - values: - - name: "GroupID" - value: G1 - - name: "SceneID" - value: 0x02 - - - label: "Step 5c: TH reads CurrentSaturation attribute from DUT." - PICS: CC.S.A0001 && CC.S.C03.Rsp - cluster: "Color Control" - command: "readAttribute" - attribute: "CurrentSaturation" - response: - constraints: - minValue: 0xF6 - maxValue: 0xFE - - # XY Scene (Blue) - - label: - "Step 6a: TH sends a _AddScene_ command to DUT with the _GroupID_ - field set to _G~1~_, the _SceneID_ field set to 0x03, the - TransitionTime field set to 0 and the ExtensionFieldSets set to: '[{ - ClusterID: 0x0300, AttributeValueList: [{ AttributeID: 0x4001, - ValueUnsigned8: 0x01 }, { AttributeID: 0x0003, ValueUnsigned16: 16334 - }, { AttributeID: 0x0004, ValueUnsigned16: 13067 }]}]'" - command: "AddScene" - PICS: CC.S.C07.Rsp - arguments: - values: - - name: "GroupID" - value: G1 - - name: "SceneID" - value: 0x03 - - name: "TransitionTime" - value: 0 - - name: "SceneName" - value: "TestScene" - - name: "ExtensionFieldSets" - value: - [ - { - ClusterID: 0x0300, - AttributeValueList: - [ - { - AttributeID: 0x0001, - ValueUnsigned8: 0x00, - }, - { - AttributeID: 0x0003, - ValueUnsigned16: 16334, - }, - { - AttributeID: 0x0004, - ValueUnsigned16: 13067, - }, - { - AttributeID: 0x0007, - ValueUnsigned16: 0x00, - }, - { - AttributeID: 0x4000, - ValueUnsigned16: 0x00, - }, - { - AttributeID: 0x4001, - ValueUnsigned8: 0x01, - }, - { - AttributeID: 0x4002, - ValueUnsigned8: 0x00, - }, - { - AttributeID: 0x4003, - ValueUnsigned8: 0x00, - }, - { - AttributeID: 0x4004, - ValueUnsigned16: 0x00, - }, - ], - }, - ] - response: - values: - - name: "Status" - value: 0x00 - - name: "GroupID" - value: G1 - - name: "SceneID" - value: 0x03 - - - label: - "Step 6b: TH sends a RecallScene command to DUT with the GroupID field - set to G1 and the SceneID field set to 0x02." - PICS: CC.S.C07.Rsp - command: "RecallScene" - arguments: - values: - - name: "GroupID" - value: G1 - - name: "SceneID" - value: 0x03 - - - label: "Step 6c: TH reads CurrentX attribute from DUT" - PICS: CC.S.A0003 && CC.S.C07.Rsp - cluster: "Color Control" - command: "readAttribute" - attribute: "CurrentX" - response: - constraints: - minValue: 14000 - maxValue: 18000 - - - label: "Step 6c1: TH reads CurrentY attribute from DUT" - PICS: CC.S.A0004 && CC.S.C07.Rsp - cluster: "Color Control" - command: "readAttribute" - attribute: "CurrentY" - response: - constraints: - minValue: 11000 - maxValue: 15000 - - # Temperature Scene - - label: - "Step 7a: TH sends a _AddScene_ command to DUT with the _GroupID_ - field set to _G~1~_, the _SceneID_ field set to 0x04, the - TransitionTime field set to 0 and the ExtensionFieldSets set to: '[{ - ClusterID: 0x0300, AttributeValueList: [{ AttributeID: 0x4001, - ValueUnsigned8: 0x02 }, { AttributeID: 0x0007, ValueUnsigned16: 175 - }]}]'" - PICS: CC.S.C0a.Rsp - command: "AddScene" - arguments: - values: - - name: "GroupID" - value: G1 - - name: "SceneID" - value: 0x04 - - name: "TransitionTime" - value: 0 - - name: "SceneName" - value: "TestScene" - - name: "ExtensionFieldSets" - value: - [ - { - ClusterID: 0x0300, - AttributeValueList: - [ - { - AttributeID: 0x0001, - ValueUnsigned8: 0x00, - }, - { - AttributeID: 0x0003, - ValueUnsigned16: 0x00, - }, - { - AttributeID: 0x0004, - ValueUnsigned16: 0x00, - }, - { - AttributeID: 0x0007, - ValueUnsigned16: 175, - }, - { - AttributeID: 0x4000, - ValueUnsigned16: 0x00, - }, - { - AttributeID: 0x4001, - ValueUnsigned8: 0x02, - }, - { - AttributeID: 0x4002, - ValueUnsigned8: 0x00, - }, - { - AttributeID: 0x4003, - ValueUnsigned8: 0x00, - }, - { - AttributeID: 0x4004, - ValueUnsigned16: 0x00, - }, - ], - }, - ] - response: - values: - - name: "Status" - value: 0x00 - - name: "GroupID" - value: G1 - - name: "SceneID" - value: 0x04 - - - label: - "Step 7b: TH sends a RecallScene command to DUT with the GroupID field - set to G1 and the SceneID field set to 0x02." - PICS: CC.S.C0a.Rsp - command: "RecallScene" - arguments: - values: - - name: "GroupID" - value: G1 - - name: "SceneID" - value: 0x04 - - - label: "Step 7c: TH reads ColorTemperatureMireds attribute from DUT." - PICS: CC.S.F04 && CC.S.A0007 && CC.S.C4b.Rsp - cluster: "Color Control" - command: "readAttribute" - attribute: "ColorTemperatureMireds" - response: - constraints: - minValue: ColorTempPhysicalMinMiredsValue - maxValue: ColorTempPhysicalMaxMiredsValue - - # Enhanced Hue and saturation scene - - label: - "Step 8a: TH sends a _AddScene_ command to DUT with the _GroupID_ - field set to _G~1~_, the _SceneID_ field set to 0x05, the - TransitionTime field set to 0 and the ExtensionFieldSets set to: '[{ - ClusterID: 0x0300, AttributeValueList: [{ AttributeID: 0x4001, - ValueUnsigned8: 0x03 }, { AttributeID: 0x4000, ValueUnsigned16: 12000 - }, { AttributeID: 0x0001, ValueUnsigned16: 70 }]}]'" - PICS: CC.S.C0a.Rsp - command: "AddScene" - arguments: - values: - - name: "GroupID" - value: G1 - - name: "SceneID" - value: 0x05 - - name: "TransitionTime" - value: 0 - - name: "SceneName" - value: "TestScene" - - name: "ExtensionFieldSets" - value: - [ - { - ClusterID: 0x0300, - AttributeValueList: - [ - { AttributeID: 0x0001, ValueUnsigned8: 70 }, - { - AttributeID: 0x0003, - ValueUnsigned16: 0x00, - }, - { - AttributeID: 0x0004, - ValueUnsigned16: 0x00, - }, - { - AttributeID: 0x0007, - ValueUnsigned16: 0x00, - }, - { - AttributeID: 0x4000, - ValueUnsigned16: 12000, - }, - { - AttributeID: 0x4001, - ValueUnsigned8: 0x03, - }, - { - AttributeID: 0x4002, - ValueUnsigned8: 0x00, - }, - { - AttributeID: 0x4003, - ValueUnsigned8: 0x00, - }, - { - AttributeID: 0x4004, - ValueUnsigned16: 0x00, - }, - ], - }, - ] - response: - values: - - name: "Status" - value: 0x00 - - name: "GroupID" - value: G1 - - name: "SceneID" - value: 0x05 - - - label: - "Step 8b: TH sends a RecallScene command to DUT with the GroupID field - set to G1 and the SceneID field set to 0x02." - PICS: CC.S.C0a.Rsp - command: "RecallScene" - arguments: - values: - - name: "GroupID" - value: G1 - - name: "SceneID" - value: 0x05 - - - label: "Step 8c: TH reads EnhancedCurrentHue attribute from DUT" - PICS: CC.S.F01 && CC.S.A4000 - cluster: "Color Control" - command: "readAttribute" - attribute: "EnhancedCurrentHue" - response: - constraints: - minValue: 10200 - maxValue: 13800 - - - label: "Step 8c1: TH reads CurrentSaturation attribute from DUT" - PICS: CC.S.F01 && CC.S.A0001 - command: "readAttribute" - cluster: "Color Control" - attribute: "CurrentSaturation" - response: - constraints: - minValue: 62 - maxValue: 78 - - # Color Loop scene - - label: - "Step 9a: TH sends a _AddScene_ command to DUT with the _GroupID_ - field set to _G~1~_, the _SceneID_ field set to 0x06, the - TransitionTime field set to 0 and the ExtensionFieldSets set to: '[{ - ClusterID: 0x0300, AttributeValueList: [{ AttributeID: 0x4002, - ValueUnsigned16: 1 }, { AttributeID: 0x4002, ValueUnsigned16: 1 }, { - AttributeID: 0x4004, ValueUnsigned16: 5 }]}]'" - PICS: CC.S.C44.Rsp - command: "AddScene" - arguments: - values: - - name: "GroupID" - value: G1 - - name: "SceneID" - value: 0x06 - - name: "TransitionTime" - value: 0 - - name: "SceneName" - value: "TestScene" - - name: "ExtensionFieldSets" - value: - [ - { - ClusterID: 0x0300, - AttributeValueList: - [ - { - AttributeID: 0x0001, - ValueUnsigned8: 0x00, - }, - { - AttributeID: 0x0003, - ValueUnsigned16: 0x00, - }, - { - AttributeID: 0x0004, - ValueUnsigned16: 0x00, - }, - { - AttributeID: 0x0007, - ValueUnsigned16: 0x00, - }, - { - AttributeID: 0x4000, - ValueUnsigned16: 0x00, - }, - { - AttributeID: 0x4001, - ValueUnsigned8: 0x00, - }, - { AttributeID: 0x4002, ValueUnsigned8: 1 }, - { AttributeID: 0x4003, ValueUnsigned8: 1 }, - { AttributeID: 0x4004, ValueUnsigned16: 5 }, - ], - }, - ] - response: - values: - - name: "Status" - value: 0x00 - - name: "GroupID" - value: G1 - - name: "SceneID" - value: 0x06 - - - label: - "Step 9b: TH sends a RecallScene command to DUT with the GroupID field - set to G1 and the SceneID field set to 0x02." - PICS: CC.S.C44.Rsp - command: "RecallScene" - arguments: - values: - - name: "GroupID" - value: G1 - - name: "SceneID" - value: 0x06 - - - label: "Step 9c: Read ColorLoopActive attribute from DUT" - command: "readAttribute" - cluster: "Color Control" - attribute: "ColorLoopActive" - PICS: CC.S.F01 && CC.S.F02 && CC.S.A4002 && CC.S.C44.Rsp - response: - value: 1 - - - label: "Step 9d: Read ColorLoopDirection attribute from DUT." - command: "readAttribute" - cluster: "Color Control" - attribute: "ColorLoopDirection" - PICS: CC.S.F01 && CC.S.F02 && CC.S.A4003 && CC.S.C44.Rsp - response: - value: 1 - - - label: "Step 9e: Read ColorLoopTime attribute from DUT." - command: "readAttribute" - cluster: "Color Control" - attribute: "ColorLoopTime" - PICS: CC.S.F01 && CC.S.F02 && CC.S.A4004 && CC.S.C44.Rsp - response: - value: 5 diff --git a/src/python_testing/TC_CC_10_1.py b/src/python_testing/TC_CC_10_1.py new file mode 100644 index 00000000000000..3aedb1a690a386 --- /dev/null +++ b/src/python_testing/TC_CC_10_1.py @@ -0,0 +1,484 @@ +# +# Copyright (c) 2024 Project CHIP Authors +# All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +# See https://github.com/project-chip/connectedhomeip/blob/master/docs/testing/python.md#defining-the-ci-test-arguments +# for details about the block below. +# +# === BEGIN CI TEST ARGUMENTS === +# test-runner-runs: run1 +# test-runner-run/run1/app: ${ALL_CLUSTERS_APP} +# test-runner-run/run1/factoryreset: True +# test-runner-run/run1/quiet: True +# test-runner-run/run1/app-args: --discriminator 1234 --KVS kvs1 --trace-to json:${TRACE_APP}.json +# test-runner-run/run1/script-args: --storage-path admin_storage.json --commissioning-method on-network --discriminator 1234 --passcode 20202021 --PICS src/app/tests/suites/certification/ci-pics-values --trace-to json:${TRACE_TEST_JSON}.json --trace-to perfetto:${TRACE_TEST_PERFETTO}.perfetto +# === END CI TEST ARGUMENTS === + +import asyncio +from typing import List + +import chip.clusters as Clusters +from chip.interaction_model import Status +from matter_testing_support import MatterBaseTest, TestStep, async_test_body, default_matter_test_main +from mobly import asserts + +kCCAttributeValueIDs = [0x0001, 0x0003, 0x0004, 0x0007, 0x4000, 0x4001, 0x4002, 0x4003, 0x4004] + + +class TC_CC_10_1(MatterBaseTest): + + # + # Class Helper functions + # + def _prepare_cc_extension_field_set(self, attribute_value_list: List[Clusters.ScenesManagement.Structs.AttributeValuePairStruct]) -> Clusters.ScenesManagement.Structs.ExtensionFieldSet: + efs_attribute_value_list: List[Clusters.ScenesManagement.Structs.AttributeValuePairStruct] = [] + for attribute_id in kCCAttributeValueIDs: + # Attempt to find the attribute in the input list + found = False + for pair in attribute_value_list: + if pair.attributeID == attribute_id: + efs_attribute_value_list.append(pair) + found = True + break + + if not found: + if attribute_id == 0x0001 or attribute_id == 0x4001 or attribute_id == 0x4002 or attribute_id == 0x4003: + empty_attribute_value = Clusters.ScenesManagement.Structs.AttributeValuePairStruct( + attributeID=attribute_id, + valueUnsigned8=0x00, + ) + elif attribute_id == 0x0003 or attribute_id == 0x0004 or attribute_id == 0x0007 or attribute_id == 0x4004: + empty_attribute_value = Clusters.ScenesManagement.Structs.AttributeValuePairStruct( + attributeID=attribute_id, + valueUnsigned16=0x0000, + ) + efs_attribute_value_list.append(empty_attribute_value) + + extension_field_set = Clusters.ScenesManagement.Structs.ExtensionFieldSet( + cluster_id=Clusters.Objects.ColorControl.id, + attribute_value_list=efs_attribute_value_list + ) + + return extension_field_set + + def desc_TC_CC_10_1(self) -> str: + """Returns a description of this test""" + return "4.2.29. [TC_CC_10_1] Scenes Management Cluster Interaction with DUT as Server" + + def pics_TC_CC_10_1(self): + """ This function returns a list of PICS for this test case that must be True for the test to be run""" + return ["CC.S", "S.S"] + + def steps_TC_CC_10_1(self) -> list[TestStep]: + steps = [ + TestStep("0", "Commissioning, already done", is_commissioning=True), + TestStep("0a", "TH sends KeySetWrite command in the GroupKeyManagement cluster to DUT using a key that is pre-installed on the TH. GroupKeySet fields are as follows: GroupKeySetID: 0x01a1, GroupKeySecurityPolicy: TrustFirst (0), EpochKey0: a0a1a2a3a4a5a6a7a8a9aaabacadaeaf, EpochStartTime0: 1110000, EpochKey1: b0b1b2b3b4b5b6b7b8b9babbbcbdbebf, EpochStartTime1: 1110001, EpochKey2: c0c1c2c3c4c5c6c7c8c9cacbcccdcecf, EpochStartTime2: 1110002"), + TestStep("0b", "TH binds GroupIds 0x0001 with GroupKeySetID 0x01a1 in the GroupKeyMap attribute list on GroupKeyManagement cluster by writing the GroupKeyMap attribute with two entries as follows: * List item 1: - FabricIndex: 1 - GroupId: 0x0001 - GroupKeySetId: 0x01a1"), + TestStep("0c", "TH sends a _RemoveAllGroups_ command to DUT."), + TestStep("1a", "TH sends a _AddGroup_ command to DUT with the _GroupID_ field set to _G~1~_."), + TestStep("1b", "TH sends a _RemoveAllScenes_ command to DUT with the _GroupID_ field set to _G~1~_."), + TestStep("1c", "TH sends a _GetSceneMembership_ command to DUT with the _GroupID_ field set to _G~1~_."), + TestStep("1d", "TH reads ColorTempPhysicalMinMireds attribute from DUT."), + TestStep("1e", "TH reads ColorTempPhysicalMaxMireds attribute from DUT."), + TestStep("2a", "TH sends _MoveToHueAndSaturation command_ to DUT with _Hue_=200, _Saturation_=50 and _TransitionTime_=0 (immediately)."), + TestStep("2b", "TH reads _CurrentHue and CurrentSaturation attributes_ from DUT."), + TestStep("2c", "TH sends _MoveToColor command_ to DUT, with: ColorX = 32768/0x8000 (x=0.5) (purple), ColorY = 19660/0x4CCC (y=0.3), TransitionTime = 0 (immediate)"), + TestStep("2d", "TH reads _CurrentX and CurrentY attributes_ from DUT."), + TestStep("2e", "TH sends _MoveToColorTemperature command_ to DUT with _ColorTemperatureMireds_=(_ColorTempPhysicalMinMireds_ + _ColorTempPhysicalMaxMireds_)/2"), + TestStep("2f", "TH sends _MoveColorTemperature command_ to DUT with _MoveMode_ = 0x01 (up), _Rate_ = (_ColorTempPhysicalMaxMireds_ - _ColorTempPhysicalMinMireds_)/40"), + TestStep("2g", "After 10 seconds, TH reads _ColorTemperatureMireds attribute_ from DUT."), + TestStep("2h", "TH sends _EnhancedMoveToHueAndSaturation command_ to DUT with _EnhancedHue_=20000, _Saturation_=50 and _TransitionTime_=0 (immediately)."), + TestStep("2i", "TH reads _EnhancedCurrentHue and CurrentSaturation attributes_ from DUT."), + TestStep("3", "TH sends a _StoreScene_ command to DUT with the _GroupID_ field set to _G~1~_ and the _SceneID_ field set to 0x01."), + TestStep("4", "TH sends a _ViewScene_ command to DUT with the _GroupID_ field set to _G~1~_ and the _SceneID_ field set to 0x01."), + TestStep( + "5a", "TH sends a _AddScene_ command to DUT with the _GroupID_ field set to _G~1~_, the _SceneID_ field set to 0x02, the TransitionTime field set to 0 and the ExtensionFieldSets set to: '[{ ClusterID: 0x0300, AttributeValueList: [{ AttributeID: 0x4001, ValueUnsigned8: 0x00 }, { AttributeID: 0x0001, ValueUnsigned8: 0xFE }]}]'"), + TestStep("5b", "TH sends a _RecallScene_ command to DUT with the _GroupID_ field set to _G~1~_, the _SceneID_ field set to 0x02 and the _TransitionTime_ omitted."), + TestStep("5c", "TH reads the _CurrentSaturation attribute_ from DUT."), + TestStep( + "6a", "TH sends a _AddScene_ command to DUT with the _GroupID_ field set to _G~1~_, the _SceneID_ field set to 0x03, the TransitionTime field set to 0 and the ExtensionFieldSets set to: '[{ ClusterID: 0x0300, AttributeValueList: [{ AttributeID: 0x4001, ValueUnsigned8: 0x01 }, { AttributeID: 0x0003, ValueUnsigned16: 16334 },{ AttributeID: 0x0004, ValueUnsigned16: 13067 }]}]'"), + TestStep("6b", "TH sends a _RecallScene_ command to DUT with the _GroupID_ field set to _G~1~_, the _SceneID_ field set to 0x03 and the _TransitionTime_ omitted."), + TestStep("6c", "TH reads _CurrentX and CurrentY attributes_ from DUT."), + TestStep( + "7a", "TH sends a _AddScene_ command to DUT with the _GroupID_ field set to _G~1~_, the _SceneID_ field set to 0x04, the TransitionTime field set to 0 and the ExtensionFieldSets set to: '[{ ClusterID: 0x0300, AttributeValueList: [{ AttributeID: 0x4001, ValueUnsigned8: 0x02 }, { AttributeID: 0x0007, ValueUnsigned16: 175 }]}]'"), + TestStep("7b", "TH sends a _RecallScene_ command to DUT with the _GroupID_ field set to _G~1~_, the _SceneID_ field set to 0x04 and the _TransitionTime_ omitted."), + TestStep("7c", "TH reads _ColorTemperatureMireds attribute_ from DUT."), + TestStep( + "8a", "TH sends a _AddScene_ command to DUT with the _GroupID_ field set to _G~1~_, the _SceneID_ field set to 0x05, the TransitionTime field set to 0 and the ExtensionFieldSets set to: '[{ ClusterID: 0x0300, AttributeValueList: [{ AttributeID: 0x4001, ValueUnsigned8: 0x03 }, { AttributeID: 0x4000, ValueUnsigned16: 12000 }, { AttributeID: 0x0001, ValueUnsigned16: 70 }]}]'"), + TestStep("8b", "TH sends a _RecallScene_ command to DUT with the _GroupID_ field set to _G~1~_, the _SceneID_ field set to 0x05 and the _TransitionTime_ omitted."), + TestStep("8c", "TH reads _EnhancedCurrentHue and CurrentSaturation attributes_ from DUT."), + TestStep( + "9a", "TH sends a _AddScene_ command to DUT with the _GroupID_ field set to _G~1~_, the _SceneID_ field set to 0x06, the TransitionTime field set to 0 and the ExtensionFieldSets set to: '[{ ClusterID: 0x0300, AttributeValueList: [{ AttributeID: 0x4002, ValueUnsigned16: 1 }, { AttributeID: 0x4002, ValueUnsigned16: 1 }, { AttributeID: 0x4004, ValueUnsigned16: 5 }]}]'"), + TestStep("9b", "TH sends a _RecallScene_ command to DUT with the _GroupID_ field set to _G~1~_, the _SceneID_ field set to 0x05 and the _TransitionTime_ omitted."), + TestStep("9c", "TH read _ColorLoopActive attribute_ from DUT."), + TestStep("9d", "TH read _ColorLoopDirection attribute_ from DUT."), + TestStep("9e", "TH read _ColorLoopTime attribute_ from DUT."), + ] + return steps + + @async_test_body + async def test_TC_CC_10_1(self): + cluster = Clusters.Objects.ColorControl + attributes = cluster.Attributes + + # Pre-Condition: Commissioning + self.step("0") + + self.step("0a") + + self.TH1 = self.default_controller + self.kGroupKeyset1 = 0x01a1 + self.groupKey = Clusters.GroupKeyManagement.Structs.GroupKeySetStruct( + groupKeySetID=self.kGroupKeyset1, + groupKeySecurityPolicy=Clusters.GroupKeyManagement.Enums.GroupKeySecurityPolicyEnum.kTrustFirst, + epochKey0="0123456789abcdef".encode(), + epochStartTime0=1110000, + epochKey1="0123456789abcdef".encode(), + epochStartTime1=1110001, + epochKey2="0123456789abcdef".encode(), + epochStartTime2=1110002) + + await self.TH1.SendCommand(self.dut_node_id, 0, Clusters.GroupKeyManagement.Commands.KeySetWrite(self.groupKey)) + + self.step("0b") + self.kGroup1 = 0x0001 + mapping_structs: List[Clusters.GroupKeyManagement.Structs.GroupKeyMapStruct] = [] + + mapping_structs.append(Clusters.GroupKeyManagement.Structs.GroupKeyMapStruct( + groupId=self.kGroup1, + groupKeySetID=self.kGroupKeyset1, + fabricIndex=1)) + result = await self.TH1.WriteAttribute(self.dut_node_id, [(0, Clusters.GroupKeyManagement.Attributes.GroupKeyMap(mapping_structs))]) + asserts.assert_equal(result[0].Status, Status.Success, "GroupKeyMap write failed") + + self.step("0c") + await self.TH1.SendCommand(self.dut_node_id, 1, Clusters.Groups.Commands.RemoveAllGroups()) + + self.step("1a") + result = await self.TH1.SendCommand(self.dut_node_id, 1, Clusters.Groups.Commands.AddGroup(self.kGroup1, "Group1")) + asserts.assert_equal(result.status, Status.Success, "Adding Group 1 failed") + + self.step("1b") + result = await self.TH1.SendCommand(self.dut_node_id, 1, Clusters.ScenesManagement.Commands.RemoveAllScenes(self.kGroup1)) + asserts.assert_equal(result.status, Status.Success, "Remove All Scenes failed on status") + asserts.assert_equal(result.groupID, self.kGroup1, "Remove All Scenes failed on groupID") + + self.step("1c") + result = await self.TH1.SendCommand(self.dut_node_id, 1, Clusters.ScenesManagement.Commands.GetSceneMembership(self.kGroup1)) + asserts.assert_equal(result.status, Status.Success, "Get Scene Membership failed on status") + asserts.assert_equal(result.groupID, self.kGroup1, "Get Scene Membership failed on groupID") + asserts.assert_equal(result.sceneList, [], "Get Scene Membership failed on sceneList") + + self.step("1d") + result = await self.TH1.ReadAttribute(self.dut_node_id, [(1, attributes.ColorTempPhysicalMinMireds)]) + ColorTempPhysicalMinMiredsValue = result[1][cluster][attributes.ColorTempPhysicalMinMireds] + + self.step("1e") + result = await self.TH1.ReadAttribute(self.dut_node_id, [(1, attributes.ColorTempPhysicalMaxMireds)]) + ColorTempPhysicalMaxMiredsValue = result[1][cluster][attributes.ColorTempPhysicalMaxMireds] + + self.step("2a") + if self.pics_guard(self.check_pics("CC.S.C06.Rsp")): + await self.TH1.SendCommand(self.dut_node_id, 1, cluster.Commands.MoveToHueAndSaturation(200, 50, 0, 1, 1)) + + self.step("2b") + if self.pics_guard(self.check_pics("CC.S.C06.Rsp")): + result = await self.TH1.ReadAttribute(self.dut_node_id, [(1, attributes.CurrentHue), (1, attributes.CurrentSaturation)]) + asserts.assert_less_equal(result[1][cluster][attributes.CurrentHue], 230, "CurrentHue is not less than or equal to 230") + asserts.assert_greater_equal(result[1][cluster][attributes.CurrentHue], 170, + "CurrentHue is not greater than or equal to 170") + asserts.assert_less_equal(result[1][cluster][attributes.CurrentSaturation], 58, "CurrentSaturation is not 58") + asserts.assert_greater_equal(result[1][cluster][attributes.CurrentSaturation], 42, "CurrentSaturation is not 42") + + self.step("2c") + if self.pics_guard(self.check_pics("CC.S.C07.Rsp")): + await self.TH1.SendCommand(self.dut_node_id, 1, cluster.Commands.MoveToColor(32768, 19660, 0, 1, 1)) + + self.step("2d") + if self.pics_guard(self.check_pics("CC.S.C07.Rsp")): + result = await self.TH1.ReadAttribute(self.dut_node_id, [(1, attributes.CurrentX), (1, attributes.CurrentY)]) + asserts.assert_less_equal(result[1][cluster][attributes.CurrentX], 35000, "CurrentX is not less than or equal to 35000") + asserts.assert_greater_equal(result[1][cluster][attributes.CurrentX], 31000, + "CurrentX is not greater than or equal to 31000") + asserts.assert_less_equal(result[1][cluster][attributes.CurrentY], 21000, "CurrentY is not less than or equal to 21000") + asserts.assert_greater_equal(result[1][cluster][attributes.CurrentY], 17000, + "CurrentY is not greater than or equal to 17000") + + self.step("2e") + if self.pics_guard(self.check_pics("CC.S.C0a.Rsp")): + await self.TH1.SendCommand(self.dut_node_id, 1, cluster.Commands.MoveToColorTemperature((ColorTempPhysicalMinMiredsValue + ColorTempPhysicalMaxMiredsValue) / 2, 0, 1, 1)) + await asyncio.sleep(1) + + self.step("2f") + if self.pics_guard(self.check_pics("CC.S.C0a.Rsp")): + await self.TH1.SendCommand(self.dut_node_id, 1, cluster.Commands.MoveColorTemperature(1, (ColorTempPhysicalMaxMiredsValue - ColorTempPhysicalMinMiredsValue) / 40, 1, 1)) + await asyncio.sleep(10) + + self.step("2g") + if self.pics_guard(self.check_pics("CC.S.C0a.Rsp")): + result = await self.TH1.ReadAttribute(self.dut_node_id, [(1, attributes.ColorTemperatureMireds)]) + asserts.assert_less_equal(result[1][cluster][attributes.ColorTemperatureMireds], ColorTempPhysicalMaxMiredsValue, + "ColorTemperatureMireds is not less than or equal to ColorTempPhysicalMaxMireds") + asserts.assert_greater_equal(result[1][cluster][attributes.ColorTemperatureMireds], ColorTempPhysicalMinMiredsValue, + "ColorTemperatureMireds is not greater than or equal to ColorTempPhysicalMinMireds") + + self.step("2h") + if self.pics_guard(self.check_pics("CC.S.C43.Rsp")): + await self.TH1.SendCommand(self.dut_node_id, 1, cluster.Commands.EnhancedMoveToHueAndSaturation(20000, 50, 0, 1, 1)) + + self.step("2i") + if self.pics_guard(self.check_pics("CC.S.C43.Rsp")): + result = await self.TH1.ReadAttribute(self.dut_node_id, [(1, attributes.EnhancedCurrentHue), (1, attributes.CurrentSaturation)]) + asserts.assert_less_equal(result[1][cluster][attributes.EnhancedCurrentHue], 21800, + "EnhancedCurrentHue is not less than or equal to 21800") + asserts.assert_greater_equal(result[1][cluster][attributes.EnhancedCurrentHue], 18200, + "EnhancedCurrentHue is not greater than or equal to 18200") + asserts.assert_less_equal(result[1][cluster][attributes.CurrentSaturation], 58, "CurrentSaturation is not 58") + asserts.assert_greater_equal(result[1][cluster][attributes.CurrentSaturation], 42, "CurrentSaturation is not 42") + + self.step("3") + result = await self.TH1.SendCommand(self.dut_node_id, 1, Clusters.ScenesManagement.Commands.StoreScene(self.kGroup1, 0x01)) + asserts.assert_equal(result.status, Status.Success, "Store Scene failed on status") + asserts.assert_equal(result.groupID, self.kGroup1, "Store Scene failed on groupID") + asserts.assert_equal(result.sceneID, 0x01, "Store Scene failed on sceneID") + + self.step("4") + result = await self.TH1.SendCommand(self.dut_node_id, 1, Clusters.ScenesManagement.Commands.ViewScene(self.kGroup1, 0x01)) + asserts.assert_equal(result.status, Status.Success, "View Scene failed on status") + asserts.assert_equal(result.groupID, self.kGroup1, "View Scene failed on groupID") + asserts.assert_equal(result.sceneID, 0x01, "View Scene failed on sceneID") + asserts.assert_equal(result.transitionTime, 0, "View Scene failed on transitionTime") + + for EFS in result.extensionFieldSets: + if EFS.clusterID == 0x0300: + for AV in EFS.attributeValueList: + if AV.attributeID == 0x0001 and self.pics_guard(self.check_pics("CC.S.C06.Rsp")): + asserts.assert_less_equal(AV.valueUnsigned8, 58, "View Scene failed on Satuation above limit") + asserts.assert_greater_equal(AV.valueUnsigned8, 42, "View Scene failed on Satuation below limit") + + if AV.attributeID == 0x0003 and self.pics_guard(self.check_pics("CC.S.C07.Rsp")): + asserts.assert_less_equal(AV.valueUnsigned16, 35000, "View Scene failed on CurrentX above limit") + asserts.assert_greater_equal(AV.valueUnsigned16, 31000, "View Scene failed on CurrentX below limit") + + if AV.attributeID == 0x0004 and self.pics_guard(self.check_pics("CC.S.C07.Rsp")): + asserts.assert_less_equal(AV.valueUnsigned16, 21000, "View Scene failed on CurrentY above limit") + asserts.assert_greater_equal(AV.valueUnsigned16, 17000, "View Scene failed on CurrentY below limit") + + if AV.attributeID == 0x0007 and self.pics_guard(self.check_pics("CC.S.C0a.Rsp")): + asserts.assert_less_equal(AV.valueUnsigned16, ColorTempPhysicalMaxMiredsValue, + "View Scene failed on ColorTemperatureMireds above limit") + asserts.assert_greater_equal(AV.valueUnsigned16, ColorTempPhysicalMinMiredsValue, + "View Scene failed on ColorTemperatureMireds below limit") + + if AV.attributeID == 0x4000 and self.pics_guard(self.check_pics("CC.S.C43.Rsp")): + asserts.assert_less_equal(AV.valueUnsigned16, 21800, "View Scene failed on EnhancedHue above limit") + asserts.assert_greater_equal(AV.valueUnsigned16, 18200, "View Scene failed on EnhancedHue below limit") + + self.step("5a") + if self.pics_guard(self.check_pics("CC.S.C06.Rsp")): + result = await self.TH1.SendCommand( + self.dut_node_id, 1, + Clusters.ScenesManagement.Commands.AddScene( + self.kGroup1, + 0x02, + 0, + "Sat Scene", + [ + self._prepare_cc_extension_field_set( + [ + Clusters.ScenesManagement.Structs.AttributeValuePairStruct(attributeID=0x4001, valueUnsigned8=0x00), + Clusters.ScenesManagement.Structs.AttributeValuePairStruct(attributeID=0x0001, valueUnsigned8=0xFE) + ] + ) + ] + + ) + ) + asserts.assert_equal(result.status, Status.Success, "Add Scene failed on status") + asserts.assert_equal(result.groupID, self.kGroup1, "Add Scene failed on groupID") + asserts.assert_equal(result.sceneID, 0x02, "Add Scene failed on sceneID") + + self.step("5b") + if self.pics_guard(self.check_pics("CC.S.C06.Rsp")): + await self.TH1.SendCommand(self.dut_node_id, 1, Clusters.ScenesManagement.Commands.RecallScene(self.kGroup1, 0x02)) + + self.step("5c") + if self.pics_guard(self.check_pics("CC.S.C06.Rsp")): + result = await self.TH1.ReadAttribute(self.dut_node_id, [(1, attributes.CurrentSaturation)]) + asserts.assert_less_equal(result[1][cluster][attributes.CurrentSaturation], 0xFE, "CurrentSaturation is above limit") + asserts.assert_greater_equal(result[1][cluster][attributes.CurrentSaturation], 0xF6, "CurrentSaturation is below limit") + + self.step("6a") + if self.pics_guard(self.check_pics("CC.S.C07.Rsp")): + result = await self.TH1.SendCommand( + self.dut_node_id, 1, + Clusters.ScenesManagement.Commands.AddScene( + self.kGroup1, + 0x03, + 0, + "XY Scene", + [ + self._prepare_cc_extension_field_set( + [ + Clusters.ScenesManagement.Structs.AttributeValuePairStruct(attributeID=0x4001, valueUnsigned8=0x01), + Clusters.ScenesManagement.Structs.AttributeValuePairStruct( + attributeID=0x0003, valueUnsigned16=16334), + Clusters.ScenesManagement.Structs.AttributeValuePairStruct( + attributeID=0x0004, valueUnsigned16=13067) + ] + ) + ] + + ) + ) + asserts.assert_equal(result.status, Status.Success, "Add Scene failed on status") + asserts.assert_equal(result.groupID, self.kGroup1, "Add Scene failed on groupID") + asserts.assert_equal(result.sceneID, 0x03, "Add Scene failed on sceneID") + + self.step("6b") + if self.pics_guard(self.check_pics("CC.S.C07.Rsp")): + await self.TH1.SendCommand(self.dut_node_id, 1, Clusters.ScenesManagement.Commands.RecallScene(self.kGroup1, 0x03)) + + self.step("6c") + if self.pics_guard(self.check_pics("CC.S.C07.Rsp")): + result = await self.TH1.ReadAttribute(self.dut_node_id, [(1, attributes.CurrentX), (1, attributes.CurrentY)]) + asserts.assert_less_equal(result[1][cluster][attributes.CurrentX], 18000, "CurrentX is above limit") + asserts.assert_greater_equal(result[1][cluster][attributes.CurrentX], 14000, "CurrentX is below limit") + asserts.assert_less_equal(result[1][cluster][attributes.CurrentY], 15000, "CurrentY is above limit") + asserts.assert_greater_equal(result[1][cluster][attributes.CurrentY], 11000, "CurrentY is below limit") + + self.step("7a") + if self.pics_guard(self.check_pics("CC.S.C0a.Rsp")): + result = await self.TH1.SendCommand( + self.dut_node_id, 1, + Clusters.ScenesManagement.Commands.AddScene( + self.kGroup1, + 0x04, + 0, + "Temp Scene", + [ + self._prepare_cc_extension_field_set( + [ + Clusters.ScenesManagement.Structs.AttributeValuePairStruct(attributeID=0x4001, valueUnsigned8=0x02), + Clusters.ScenesManagement.Structs.AttributeValuePairStruct(attributeID=0x0007, valueUnsigned16=175) + ] + ) + ] + + ) + ) + asserts.assert_equal(result.status, Status.Success, "Add Scene failed on status") + asserts.assert_equal(result.groupID, self.kGroup1, "Add Scene failed on groupID") + asserts.assert_equal(result.sceneID, 0x04, "Add Scene failed on sceneID") + + self.step("7b") + if self.pics_guard(self.check_pics("CC.S.C0a.Rsp")): + await self.TH1.SendCommand(self.dut_node_id, 1, Clusters.ScenesManagement.Commands.RecallScene(self.kGroup1, 0x04)) + + self.step("7c") + if self.pics_guard(self.check_pics("CC.S.C0a.Rsp")): + result = await self.TH1.ReadAttribute(self.dut_node_id, [(1, attributes.ColorTemperatureMireds)]) + asserts.assert_less_equal(result[1][cluster][attributes.ColorTemperatureMireds], + ColorTempPhysicalMaxMiredsValue, "ColorTemperatureMireds is above limit") + asserts.assert_greater_equal(result[1][cluster][attributes.ColorTemperatureMireds], + ColorTempPhysicalMinMiredsValue, "ColorTemperatureMireds is below limit") + + self.step("8a") + if self.pics_guard(self.check_pics("CC.S.C43.Rsp")): + result = await self.TH1.SendCommand( + self.dut_node_id, 1, + Clusters.ScenesManagement.Commands.AddScene( + self.kGroup1, + 0x05, + 0, + "Enh Scene", + [ + self._prepare_cc_extension_field_set( + [ + Clusters.ScenesManagement.Structs.AttributeValuePairStruct(attributeID=0x4001, valueUnsigned8=0x03), + Clusters.ScenesManagement.Structs.AttributeValuePairStruct( + attributeID=0x4000, valueUnsigned16=12000), + Clusters.ScenesManagement.Structs.AttributeValuePairStruct(attributeID=0x0001, valueUnsigned16=70) + ] + ) + ] + + ) + ) + asserts.assert_equal(result.status, Status.Success, "Add Scene failed on status") + asserts.assert_equal(result.groupID, self.kGroup1, "Add Scene failed on groupID") + asserts.assert_equal(result.sceneID, 0x05, "Add Scene failed on sceneID") + + self.step("8b") + if self.pics_guard(self.check_pics("CC.S.C43.Rsp")): + await self.TH1.SendCommand(self.dut_node_id, 1, Clusters.ScenesManagement.Commands.RecallScene(self.kGroup1, 0x05)) + + self.step("8c") + if self.pics_guard(self.check_pics("CC.S.C43.Rsp")): + result = await self.TH1.ReadAttribute(self.dut_node_id, [(1, attributes.EnhancedCurrentHue), (1, attributes.CurrentSaturation)]) + asserts.assert_less_equal(result[1][cluster][attributes.EnhancedCurrentHue], 13800, "EnhancedCurrentHue is above limit") + asserts.assert_greater_equal(result[1][cluster][attributes.EnhancedCurrentHue], + 10200, "EnhancedCurrentHue is below limit") + asserts.assert_less_equal(result[1][cluster][attributes.CurrentSaturation], 78, "CurrentSaturation is above limit") + asserts.assert_greater_equal(result[1][cluster][attributes.CurrentSaturation], 62, "CurrentSaturation is below limit") + + self.step("9a") + if self.pics_guard(self.check_pics("CC.S.C44.Rsp")): + result = await self.TH1.SendCommand( + self.dut_node_id, 1, + Clusters.ScenesManagement.Commands.AddScene( + self.kGroup1, + 0x06, + 0, + "Loop Scene", + [ + self._prepare_cc_extension_field_set( + [ + Clusters.ScenesManagement.Structs.AttributeValuePairStruct(attributeID=0x4002, valueUnsigned8=0x01), + Clusters.ScenesManagement.Structs.AttributeValuePairStruct(attributeID=0x4003, valueUnsigned8=0x01), + Clusters.ScenesManagement.Structs.AttributeValuePairStruct(attributeID=0x4004, valueUnsigned16=5) + ] + ) + ] + + ) + ) + asserts.assert_equal(result.status, Status.Success, "Add Scene failed on status") + asserts.assert_equal(result.groupID, self.kGroup1, "Add Scene failed on groupID") + asserts.assert_equal(result.sceneID, 0x06, "Add Scene failed on sceneID") + + self.step("9b") + if self.pics_guard(self.check_pics("CC.S.C44.Rsp")): + await self.TH1.SendCommand(self.dut_node_id, 1, Clusters.ScenesManagement.Commands.RecallScene(self.kGroup1, 0x06)) + + self.step("9c") + if self.pics_guard(self.check_pics("CC.S.C44.Rsp")): + result = await self.TH1.ReadAttribute(self.dut_node_id, [(1, attributes.ColorLoopActive)]) + asserts.assert_equal(result[1][cluster][attributes.ColorLoopActive], 1, "ColorLoopActive is not 1") + + self.step("9d") + if self.pics_guard(self.check_pics("CC.S.C44.Rsp")): + result = await self.TH1.ReadAttribute(self.dut_node_id, [(1, attributes.ColorLoopDirection)]) + asserts.assert_equal(result[1][cluster][attributes.ColorLoopDirection], 1, "ColorLoopDirection is not 1") + + self.step("9e") + if self.pics_guard(self.check_pics("CC.S.C44.Rsp")): + result = await self.TH1.ReadAttribute(self.dut_node_id, [(1, attributes.ColorLoopTime)]) + asserts.assert_equal(result[1][cluster][attributes.ColorLoopTime], 5, "ColorLoopTime is not 5") + + +if __name__ == "__main__": + default_matter_test_main()