Alexa brightness automated tests issue

111 views Asked by At

I'm developing a smart home skill for Alexa, which involves controlling a light with various capabilities such as brightness, color temperature (CT), and more. I've successfully addressed all the other issues, including CT, colors, and ON/OFF functionality. However, I'm encountering difficulties passing the automated tests specifically related to the brightness capabilities.

My problem is on brightness when running automated tests, I am getting error on brighness that is detailed bellow;

Scenario 1: Let's assume that the initial state before the request is that the brightness is set at a value of 75.

In the first scenario, I'm retaining the brightness value it had before the "SetBrightness" command to set it to 0, which also serves as a signal to turn off the light.

Request:

{
   "directive":{
      "header":{
         "namespace":"Alexa.BrightnessController",
         "name":"SetBrightness",
         "messageId":"fed54fb1-a40e-42c5-819d-53894fb19fd8",
         "correlationToken":"ctooken",
         "payloadVersion":"3",
         "endpoint":{
            "scope":{
               "type":"BearerToken",
               "token":"token",
               "endpointId":"b38d964c-0b55-4b9a-8c0c-c537721bd2e5",
               "cookie":{},
               "payload":{
                  "brightness":0
               }
            }
         }
      }
   }
}

Response:

{
   "event":{
      "header":{
         "namespace":"Alexa",
         "name":"Response",
         "messageId":"fed54fb1-a40e-42c5-819d-53894fb19fd8-R",
         "correlationToken":"ctoken",
         "payloadVersion":"",
         "endpoint":{
            "endpointId":"b38d964c-0b55-4b9a-8c0c-c537721bd2e5",
            "scope":{
               "token":"token",
               "type":"BearerToken"
            },
            "payload":{},
            "context":{
               "properties":[
                  {
                     "namespace":"Alexa.BrightnessController",
                     "value":75,
                     "name":"brightness",
                     "timeOfSample":"2023-09-08T05:30:10.410Z",
                     "uncertaintyInMilliseconds":3000
                  },
                  {
                     "namespace":"Alexa.PowerController",
                     "value":"OFF,
                     "name":"powerState",
                     "timeOfSample":"2023-09-08T05:30:10.410Z",
                     "uncertaintyInMilliseconds":3000
                  }
               ]
            }
         }
      }
   }
}

When running tests, I am getting on from on https://developer.amazon.com/alexa/console

Error:

"The endpoint could not be set to the Initial States required by the Test Case."

Scenario 2: Assuming the initial brightness is set at 100.

In the second scenario, I'm setting the brightness to the value specified in the "SetBrightness" command. If the command instructs the brightness to be set to 0, I will report back a brightness value of zero along with turning off the light.

Request:

{
  "directive": {
    "header": {
      "namespace": "Alexa.BrightnessController",
      "name": "SetBrightness",
      "messageId": "fed54fb2-a40e-42c5-819d-53894fb19fd8",
      "correlationToken": "ctooken",
      "payloadVersion": "3",
      "endpoint": {
        "scope": {
          "type": "BearerToken",
          "token": "token-",
          "endpointId": "b38d964c-0b55-4b9a-8c0c-c537721bd2e5",
          "cookie": {},
          "payload": {
            "brightness": 0
          }
        }
      }
    }
  }
}

Response:

{
  "event": {
    "header": {
      "namespace": "Alexa",
      "name": "Response",
      "messageId": "fed54fb1-a40e-42c5-819d-53894fb19fd8-R",
      "correlationToken": "ctoken",
      "payloadVersion": "3",
      "endpoint": {
        "endpointId": "b38d964c-0b55-4b9a-8c0c-c537721bd2e5",
        "scope": {
          "token": "token",
          "type": "BearerToken"
        },
        "payload": {},
        "context": {
          "properties": [
            {
              "namespace": "Alexa.BrightnessController",
              "value": 0,
              "name": "brightness",
              "timeOfSample": "2023-09-08T05:30:10.410Z",
              "uncertaintyInMilliseconds": 3000
            },
            {
              "namespace": "Alexa.PowerController",
              "value": "OFF",
              "name": "powerState",
              "timeOfSample": "2023-09-08T05:30:10.410Z",
              "uncertaintyInMilliseconds": 3000
            }
          ]
        }
      }
    }
  }
}

Error in EvaluationResults:

{
            "name": "DevRe_9.1",
            "status": "FAILED",
            "expectedCapabilityStates": [
                {
                    "namespace": "Alexa.BrightnessController",
                    "name": "brightness",
                    "value": 100
                }
            ],
            "directive": {
                "header": {
                    "namespace": "Alexa.PowerController",
                    "name": "TurnOn"
                },
                "payload": {}
            },
            "actualCapabilityStates": [
                {
                    "namespace": "Alexa.BrightnessController",
                    "name": "brightness",
                    "value": 0
                }
            ]
},

In the above EvaluationResults, It looks to me that it wanted the 100 back which was the value before issue setBrightness=0.

The question here is what is the expected response, when set brightness to (0)zero, is issued? Later what is expected values When the ReportState is issued?

1

There are 1 answers

3
Amari On BEST ANSWER

For Scenario 1: Your skill simply needs to set value=0 and send back to Alexa with value=0. SetBrightness is a request from Alexa(a user) to set your device value to specific value. For Scenario 2: It seems that the test expects that the device returns value=100 when the device is turned on. However if the device is asked state report during the the device is off(value=0), the device should respond with current state(value=0).