alexa-smarthome icon indicating copy to clipboard operation
alexa-smarthome copied to clipboard

Device discovery fails while response from lambda seems correct

Open Mathieu45852 opened this issue 5 years ago • 2 comments

Hi, I've my own lambda on which I've built a static device for dev purposes.

Unexpected behavior is that even if response from lambda seems correct, device is not added:

here is the response I've from lambda test : { "event": { "header": { "messageId": "38A28869-DD5E-48CE-BBE5-A4DB78CECB33", "name": "Discover.Response", "namespace": "Alexa.Discovery", "payloadVersion": "3" }, "payload": { "enpoints": [ { "endpointId": "appliance003", "friendlyName": "Front Door", "description": "Smart Lock by Sample Manufacturer", "manufacturerName": "Sample Manufacturer", "displayCategories": [ "SMARTLOCK" ], "cookie": {}, "capabilities": [ { "type": "AlexaInterface", "interface": "Alexa.LockController", "version": "3", "properties": { "supported": [ { "name": "lockState" } ], "proactivelyReported": true, "retrievable": true } }, { "type": "AlexaInterface", "interface": "Alexa", "version": "3" } ] } ] } } }

I can also confirm that lambda receive request when discover device is launch.

Any idea ?

Mathieu45852 avatar Oct 14 '19 10:10 Mathieu45852

I highly recommend doing schema validation when you have an issue like this. See the schema in this repo: https://github.com/alexa/alexa-smarthome/blob/master/validation_schemas/alexa_smart_home_message_schema.json

There are probably others, but if you npm install avj-cli you can use the avj command line tool to validate a json document.

Running this on yours highlighted two issues in your sample:

  • You have an element named .event.payload.enpoints which should be .event.payload.endpoints
  • ~~The .event.payload.endpoints[0].cookie value should be an object, and you currently have null. You may just need to change this to {}~~

Keep in mind that running a JSON schema validator will usually produce a lot of noise in addition to the actual issue.

Edited as I somehow got a null for the value of the cookie element when I pasted your document into emacs. So, my second note was a false alarm.

RobMullen avatar Oct 15 '19 18:10 RobMullen

As @RobMullen said, there is a typo in endpoints. This project schema is exactly for that and is working. I think this issue should be closed, @Mathieu45852

helviojr avatar Jun 15 '20 03:06 helviojr

The device is not added because the JSON you are trying to send is malformed because of a typo. Replacing "enpoints" with "endpoints" will make it work.

dievaa avatar Oct 03 '23 09:10 dievaa