5
votes

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?

5
Have you managed to make it work? I'm facing the exact same issue. I already tried generating a true random messageId, and changing other values just in case, but noghing :( - jotadepicas
I've just made min work! In my case, I had name and namespace values mixed up. Unfortunately I have to say that now my response looks just like yours... I think the lacking of a good debugging tool on Alexa's side makes it harder to find this minor mistakes.... - jotadepicas

5 Answers

2
votes

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.

1
votes

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.

0
votes

Recreating lambda function helped me fix the issue. I also set "Enable trigger" check button while creating, though I'm not sure if that matters. After that my device provided by skill was found successfully.

0
votes

Edit: Answer was wrong. Only useful information was this

This context.fail syntax is actually deprecated. Look up the Lambda context object properties, it should look more like "callback(null, resultObj)" now.

0
votes

Did you include the return statement in your function?

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

It was missing in the example and after adding it, I was able to 'discover' my device.