auchter / haaska

Home Assistant Alexa Skill Adapter
261 stars 60 forks source link

Unreliable Control of Lights #100

Closed dfiel closed 6 years ago

dfiel commented 6 years ago

Hello,

I got everything set up okay. I can issue commands like "Alexa, turn off X" and itll work. But if I give it another command right after, like "Alexa, turn on Y", it will fail. It seems to only work every once in a while.

Any ideas?

trisk commented 6 years ago

Check the logs for your Lambda function execution in Amazon CloudWatch.

dfiel commented 6 years ago

@trisk The only errors I get are for unverified HTTPs connections, which is to be expected, as I didn't set the option to verify SSL.

thizzle commented 6 years ago

Can you post the CloudWatch logs here, ideally the logs for the transaction that fails.

dfiel commented 6 years ago

@thizzle @trisk Here is a link to a copy of the CloudWatch logs, for when I made 2 requests, to turn on and off a lamp. The ON command went through and worked fine, but not the second OFF command. Any ideas?

thizzle commented 6 years ago

Can you enable the debug parameter in your config.json, perform this experiment again, and forward the logs? Enabling that will include much more helpful information in the logs.

dfiel commented 6 years ago

@thizzle I didn't realize there was a debug option, thanks for that!

Here is the updated logs. Everything looks fine in the logs, but only one of those commands (Alexa, turn on Server Closet) worked. Everything else was ignored. HA is working, as my dash buttons and Alexa control (Alexa, ask Home Assistant to turn off David's Desk Lamp) still work, as well as the web UI.

thizzle commented 6 years ago

I suspect what may be happening is the request to Home Assistant times out occasionally.

Specifically, I was also seeing these lines in my logs:

request for services/homeassistant/turn_off sent without waiting for response

The problem is with how this code waits for Home Assistant to respond (it usually doesn't wait). This is probably fine if your Home Assistant responds quickly, but mine is running an older model Raspberry Pi, and it takes a few seconds to respond.

I resolved the issue with this patch, which you can try out if you like. You can just apply this patch (or checkout the branch in my fork). If you do try, report your results back!

https://github.com/thizzle/haaska/commit/456cd117c115a3c1d4f78d92e2b46af2a53dbabb

Good luck,

Tharsan

dfiel commented 6 years ago

@thizzle Hmm, it should respond fairly quickly as its running on a VM on my server, but I'll try your fork. What should I set the timeout to?

EDIT: I set the timeout to 5 seconds, and it seems to have fixed the issue. Thank you so much!