Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Amazon Alexa Device Discovery for Smart Home API with Lambda Failing

I have setup an Alexa Smart Home Skill, all settings done, oauth2 processed done and skill is enabled on my Amazon Echo device. Lambda function is setup and linked to the skill. When I "Discover Devices" I can see the payload hit my Lambda function in the log. I am literally returning via the context.succeed() method the following JSON with a test appliance. However Echo tells me that it fails to 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 look correct?

like image 283
daviemanchester Avatar asked Oct 19 '22 08:10

daviemanchester


2 Answers

According to https://developer.amazon.com/public/solutions/alexa/alexa-skills-kit/docs/smart-home-skill-api-reference#discovery-messages the version attribute is required. Your response seems to be missing that attribute.

In my (very short) experience with this, even the smallest mistake in the response would generate a silent error like the one you are experiencing.

like image 122
jotadepicas Avatar answered Dec 14 '22 02:12

jotadepicas


I had the same problem. If you are creating discovery for "Entertainment Device", make sure you have wrapped the output in 'event' key for 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, in the sample code, this is never mentioned and an incorrect 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 provided includes the "event" key.

like image 25
Laurynas Avatar answered Dec 14 '22 03:12

Laurynas