thorsten-gehrig/alexa-remote-control

Return code for commands given to alexa-remote-control

meirlazar opened this issue · 1 comments

Maybe this is more of a feature request, but I cannot distinguish by capturing the return code from this script/binary whether alexa was successful in compleing my request, it seems to always return 0, even when I can hear alexa responding that she is unsure of what I am requesting. Is there a way to capture/determine if the command was executed correctly by alexa or not. I'm ok with having to modify the curl commands or removing the delete commands for the temp logs that the script generates from the curl commands. Please let me know what is the best way of getting that info. Thanks

I'm afraid there is no such thing as a response code for Alexa's replys.
After all it's an asynchrounous request. In most cases you can query some property you intended to change and check for the intended result (e.g. turning up the volume).

There's also the prompt-history (which is currently undergoing massive changes) that might indicate how Alexa responded to a request.

If it is indeed the API HTTP result code (normally HTTP/200) you want to check, then you'd have to use curl's -w "%{http_code}" and redirect the StdOut to some other file descriptor or file:

response=/tmp/response.txt
error=$(curl -s -X GET -w "%{http_code}" -o "${response}" "https://api.example.org"
echo "HTTP response code is: ${error}"
echo "Response content is:"
cat $response