[Deprecated] Amazon Alexa Text to Speech (TTS) v0.6.2 - Direct Integration (USA, Canada, UK, Italy, Australia, & Brazil)

While trying to troubleshoot I noticed them, but nothing gets logged which is really weird. I get the same error page as @keo.

I originally logged out because I don't like staying logged in after using an extension, but with the developer tools method that's no longer a concern so I'm fine with leaving it logged in.

Things are still working great this morning.

1 Like

Yeah. Mine is still working, but this could be problematic if new devices are added. I am decent at hacking code together, so I'll take a look later.

1 Like

I don't know much about cookies but I'm wondering if a different type of error is generated by an expired cookie. An invalid cookie probably throws back a general error but a previously valid cookie may get a bit further in the process before balking. On kid duty again today but I will try to invalidate my cookie and see what happens later today.

1 Like

I made a small edit to my cookie string on my test hub, and then clicked next... got the page can't be displayed error. Nothing in the live logs though. At least I can reproduce the problem. I may need to move the logic the retrieves the device list to be able to trap any errors. I just am not much of a Hubitat App writer. Most of my work has been in Drivers. Help is always appreciated!

For those real noobs like me, don't forget to add a semicolon at the end of your string or the device list won't show your Alexa device(s)

Other than that, I had no issues

Rick

1 Like

interesting... I have never added a semicolon to the end of the string.

All,

I have trapped the invalid data response coming from Amazon when the cookie is invalid. This will prevent the web page error that has been reported. Thank you all for helping to test this integration and make it better.

Grab the latest code from here.

https://raw.githubusercontent.com/ogiewon/Hubitat/master/Alexa%20TTS/Apps/alexa-tts-manager.src/alexa-tts-manager.groovy

It looks like if you copy the entire cookie from developer tools then the semicolon is required at the end so I updated my instructions.

I've re-generated the cookie multiple times and the copy from developer tools always works so there's no need to install that extension and manually build the cookie yourself.

2 Likes

Here are some quick instructions on getting the cookie from Chrome Developer tools. Hopefully it will help. @ogiewon is going to update his readme with them as well.

  1. Open Chrome and Login to alexa.amazon.com
  2. Open the Chrome menu at the top-right of your browser window, then select Tools (More Tools) > Developer Tools
  3. On top row of developer tools you will see several tabs: Elements, Console, Sources, Network, etc. Click Network.
  4. Just below the tabs you will see a red circle, below that you will see a filter box, and below that you will see sub tabs: All, XHR, JS, etc. Click XHR
  5. Click Smart Home in the left navigation
  6. The developer tools XHR list should populate with several items, one called "featureaccess-v3", right-click on it and choose Copy, Copy Request Headers. This will place it into your clipboard.
  7. Open your favorite text editor such as Notepad and paste the contents into it.
  8. The last item should be the cookie. Remove everything including "Cookie: ", leaving the raw cookie in the text editor.
  9. Remove all double quotes. Search for double quotes and replace with an empty string.
  10. Use this cookie in HE.
6 Likes

I am struggling with the cookie - instructions seem pretty clear. I now see an error in the log as follows:

2018-10-21 16:34:20.979:errorEncountered an error. http resp.status = '200'. http resp.contentType = 'text/html'. Should be '200' and 'application/json'. Check your cookie string!

Could the fact that I am in the uk be causing any issues - my cookie comes from alexa.amazon.co.uk (I tried changing the .coms in the app but did not help).

Yes I think this could be an issue. I have not looked at the code myself though. Seems like there were a few places in the original script that had to be adjusted for this.

@ogiewon will likely know better.

Yes, this is specifically for the US right now. I believe it could be made to work for the UK as the original code this is based on did seem to have support for it. I just haven't added that support yet, and will need someone, like yourself, to test it.

More than happy to do so and report back. I pretty sure there will be others who are willing. Is this the block that need to change or does it get more complex:

       def params = [uri: "https://pitangui.amazon.co.uk/api/behaviors/preview",
                      headers: ["Cookie":"""${alexaCookie}""",
                        "Referer": "https://alexa.amazon.co.uk/spa/index.html",
                        "Origin": "https://alexa.amazon.co.uk",
                        "csrf": "${csrf}",
                        "Connection": "keep-alive",
                        "DNT":"1"],
1 Like

It is these variables in the original script. There are likely several calls that need to be adjusted.

#LANGUAGE="en-GB"
LANGUAGE="en-US"

#AMAZON='amazon.de'
#AMAZON='amazon.co.uk'
AMAZON='amazon.com'

#ALEXA='layla.amazon.de'
#ALEXA='layla.amazon.co.uk'
ALEXA='pitangui.amazon.com'

1 Like

There are at least two blocks like that. I am not sure if anything needs to change, or if your edits are correct though. The original source can be found at ha-alexa-tts/alexa_remote_control.sh at master · walthowd/ha-alexa-tts · GitHub

And @cwwilson08 has posted above what appears to be the required changes.

@Jim_UK, please let me know if these changes work for you and I will try to modify the App to allow a choice between the two contries.

Great thanks for pointers - will report back soon.

This is really cool @ogiewon.
It works well for the most part. It sends each device the request independently, which makes it rather slow, of course. I think nothing you can do about that. However, I get the following error on some of the requests pretty consistently.

This happens on a specific device whether bulk messaging or sending a test from the device property page.

error'speakMessage()': Error making Call (getMessage): Bad Request
error'speakMessage()': Error making Call (Status): 400
error'speakMessage()': Error making Call (Data): [message:null]

This happens when I'm sending messages to all 6 devices.

error'speakMessage()': Error making Call (getMessage): Bad Request
error'speakMessage()': Error making Call (Status): 400
error'speakMessage()': Error making Call (Data): [message:Rate exceeded]

@doug

I think you may be able to send one command to a group created in the alexa app. Just use the name of the group in place of the individual devices.

Groups don't show up in the list in HE.

Works north of the wall (Canada) as well

thank you!

2 Likes