alexa-samples / alexa-smarthome

Resources for Alexa Smart Home developers.
https://alexa.design/smarthome
Other
680 stars 336 forks source link

Device discovery fails while response from lambda seems correct #131

Closed Mathieu45852 closed 9 months ago

Mathieu45852 commented 4 years ago

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 ?

RobMullen commented 4 years ago

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:

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.

helviojr commented 4 years ago

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

dievaa commented 9 months ago

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.