Amazon Alexa Device Discovery for Smart Home API with Lambda Failure

I have the Alexa Smart Home skill, all the settings are made, oauth2 is processed, and the skill is enabled on my Amazon Echo device. The lambda function is configured and associated with the skill. When I "Discover devices", I see that the payload hit my Lambda function in the log. I literally return via context.succeed () the next JSON method with the test device. However, Echo tells me that it does not find any devices.

{
  "header": {
    "messageId": "42e0bf9c-18e2-424f-bb11-f8a12df1a79e",
    "name": "DiscoverAppliancesResponse",
    "namespace": "Alexa.ConnectedHome.Discovery",
    "payloadVersion": "2"
  },
  "payload": {
    "discoveredAppliances": [
      {
        "actions": [
          "incrementPercentage",
          "decrementPercentage",
          "setPercentage",
          "turnOn",
          "turnOff"
        ],
        "applianceId": "0d6884ab-030e-8ff4-ffffaa15c06e0453",
        "friendlyDescription": "Study Light connected to Loxone Kit",
        "friendlyName": "Study Light",
        "isReachable": true,
        "manufacturerName": "Loxone",
        "modelName": "Spot"
      }
    ]
  }
}

Does the above payload match?

+4
source share
5 answers

: .

context.fail . Lambda, "callback (null, resultObj)".

0

- . " " , , . , , .

0

return ?

    return {
        "header": header,
        "payload": payload
    }

, "" .

0

. "Entertainment Device", , "event" context.succeed

var payload = {
    endpoints:
        [
            {
                "endpointId": "My-id",
                "manufacturerName": "Manufacturer",
                "friendlyName": "Living room TV",
                "description": "65in LED TV from Demo AV Company",
                "displayCategories": [  ],
                "cookie": {
                    "data": "e.g. ip address",
                },
                "capabilities":
                    [

                        {
                            "interface": "Alexa.Speaker",
                            "version": "1.0",
                            "type": "AlexaInterface"
                        },

                    ]
            }
        ]
};
var header = request.directive.header;
header.name = "Discover.Response";
context.succeed({ event: {
    header: header, payload: payload
} });

Although this is never mentioned in the sample code and the wrong example is given ( https://developer.amazon.com/public/solutions/alexa/alexa-skills-kit/docs/steps-to-create-a-smart-home-skill ) However, the response body contains an event key.

0
source

All Articles