# Copyright (c) 2023 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: Dishwasher Alarm Tests

config:
    nodeId: 0x12344321
    cluster: "Dishwasher Alarm"
    endpoint: 1

tests:
    - label: "Wait for the commissioned device to be retrieved"
      cluster: "DelayCommands"
      command: "WaitForCommissionee"
      arguments:
          values:
              - name: "nodeId"
                value: nodeId
    #Init
    #Support 10 1111  (47) (0x2F)
    #Mask    10 1111  (47) (0x2F)
    #Latch   00 0011  (3)  (0x03)
    #State   00 0111  (7)  (0x07)
    #FeatureMap 1
    - label: "Read Supported Attribute"
      command: "readAttribute"
      attribute: "Supported"
      response:
          value: 47

    - label: "Read Mask Attribute"
      command: "readAttribute"
      attribute: "Mask"
      response:
          value: 47

    - label: "Read Latch Attribute"
      command: "readAttribute"
      attribute: "Latch"
      response:
          value: 3

    - label: "Read State Attribute"
      command: "readAttribute"
      attribute: "State"
      response:
          value: 7

    - label: "Read feature map Attribute"
      command: "readAttribute"
      attribute: "FeatureMap"
      response:
          constraints:
              type: bitmap32
              hasMasksSet: [0x1]

    #After Modify Enabled Alarm (Valid)
    #Support 10 1111  (47) (0x2F)
    #Mask    10 1001  (41) (0x29)
    #Latch   00 0011  (3)  (0x03)
    #State   00 0001  (1)  (0x01)
    - label: "Modify enabled alarms Command"
      command: "ModifyEnabledAlarms"
      arguments:
          values:
              - name: "Mask"
                value: 41

    - label: "Read Mask Attribute"
      command: "readAttribute"
      attribute: "Mask"
      response:
          value: 41

    - label: "Read Latch Attribute"
      command: "readAttribute"
      attribute: "Latch"
      response:
          value: 3

    - label: "Read State Attribute"
      command: "readAttribute"
      attribute: "State"
      response:
          value: 1

    #After Modify Enabled Alarm (Invalid, set for unknown alarms)
    #Support 10 1111  (47) (0x2F)
    #Mask   110 1001  (105) (0x69)
    #Latch   00 0011  (3)  (0x03)
    #State   00 0001  (1)  (0x01)
    - label: "Modify enabled alarms Command"
      command: "ModifyEnabledAlarms"
      arguments:
          values:
              - name: "Mask"
                value: 105
      response:
          error: INVALID_COMMAND

    - label: "Read Mask Attribute"
      command: "readAttribute"
      attribute: "Mask"
      response:
          value: 41

    - label: "Read Latch Attribute"
      command: "readAttribute"
      attribute: "Latch"
      response:
          value: 3

    - label: "Read State Attribute"
      command: "readAttribute"
      attribute: "State"
      response:
          value: 1

    #After Modify Enabled Alarm (Invalid, set for alarms which are not supported)
    #Support 10 1111  (47) (0x2F)
    #Mask    11 1011  (59) (0x3B)
    #Latch   00 0011  (3)  (0x03)
    #State   00 0001  (1)  (0x01)
    - label: "Modify enabled alarms Command"
      command: "ModifyEnabledAlarms"
      arguments:
          values:
              - name: "Mask"
                value: 59
      response:
          error: INVALID_COMMAND

    - label: "Read Mask Attribute"
      command: "readAttribute"
      attribute: "Mask"
      response:
          value: 41

    - label: "Read Latch Attribute"
      command: "readAttribute"
      attribute: "Latch"
      response:
          value: 3

    - label: "Read State Attribute"
      command: "readAttribute"
      attribute: "State"
      response:
          value: 1

    #After Reset alarms bit 0
    #Support 10 1111  (47) (0x2F)
    #Mask    10 1001  (41) (0x29)
    #Latch   00 0011  (3)  (0x03)
    #State   00 0000  (0)  (0x00)
    - label: "Reset Command"
      command: "Reset"
      arguments:
          values:
              - name: "Alarms"
                value: 1

    - label: "Read Mask Attribute"
      command: "readAttribute"
      attribute: "Mask"
      response:
          value: 41

    - label: "Read Latch Attribute"
      command: "readAttribute"
      attribute: "Latch"
      response:
          value: 3

    - label: "Read State Attribute"
      command: "readAttribute"
      attribute: "State"
      response:
          value: 0
