question

theGeekyLad avatar image
theGeekyLad asked

Apparent Queuing of non Alexa.Discovery Directives

Hey there.

I have an existing IoT based smart home system in charge of the switches at my house and was interested in an integration with Alexa. I'd gotten started with the official Alexa Skills guide to set up a skill and an associated AWS Lambda function in Node.js. I have a couple of endpoints on my public server at home, one of which responds with the list of devices in a format that the "context.succeed(...)" inside of the request handler needs, as well as another that simply switches the power state of the device on or off. While writing the Lambda function for this, all that I had to change in the boilerplate code of the sample was to include "http GET" requests to my server using the native "http" package of Node.js.

While Alexa, through the linked Lambda function, is able to successfully trigger my home server endpoints which ultimately discovers and switches the devices on / off, there seems to be a massive issue. It appears as though, either the request sent by Alexa or the Lambda function execution seems to be "queued" after the very first discovery request hence executing the "previous" request at every subsequent request. Let me illustrate this for a clearer picture with 3 devices - fan, tubelight and bulb.

1. I ask Alexa to initiate a discovery request. My home server logs correctly show that the discover-devices endpoint was fired by the Lambda function linked with this skill.

2. I ask Alexa to turn on the fan. There is no new log record on my home server stating that a request was made to turn the fan on. Hence the command seems to have done nothing.

3. I ask Alexa to turn off the tubelight. My server logs show that the power-state-toggle endpoint was fired by the Lambda function, but to "turn on the fan" (evidently, this is the "previous" request in #2).

4. I ask Alexa to turn off the fan. This time, just as in the #3 case, the logs show that the tubelight has been turned off (note: "turn off fan" request seems to be queued).

5. Interestingly, if I now initiate another discovery request, my server logs show that it has received 2 requests one after the other:
(a) Turn off the fan (as requested in #4)
(b) Get the list of devices

6. Any subsequent non-discovery request follows the same cycle as above.

If you notice the sequence of events, it's clear that post the first discovery request, every other power control request is cached and the "previous" power control request, if exists, is executed and finally the last discovery request executes the last "queued" power control request followed by the discovery request itself.

This behavior is super weird and balks me from proceeding any further! Even if I defer subsequent commands to Alexa by over 5m or so, the "queuing" behavior remains the same. What could be the issue? Looking forward to your assistance.

Thanks!

alexaalexa smart homelambda
1 comment
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Update:

Apparently CloudWatch logs also suggest the same issue as illustrated above. After the log entry for device-discovery request from Alexa, there is no entry for the first power control request. Subsequent power control requests have log entries showing exactly that the immediately "previous" request was executed. Finally, the last discovery request gets 2 log entries - one for the last "queued" power control request and another for this discovery request itself.

This indicates that there is some kind of a gap in communication between Alexa and the Lambda function for all non-discovery requests.

0 Likes 0 ·

1 Answer

Amazon_Bernardo Bezerra avatar image
Amazon_Bernardo Bezerra answered

Hi @theGeekyLad and thanks for posting.

This could be an issue with how you are handling the requests in your backend. In order to test that, would it be possible for you to share the JSON that you are sending with the discovery response?

Regards,
Barry

10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.