[Release] Echo Speaker - Control Alexa Echo Devices Without External Server, TTS, TuneIn , Play , Pause, Next

Amazon Echo has some method to send messages directly without request. In alexa.amazon.com site, you can get access to several functions.

To emulate the actions with SmartThings its necessary to get the cookie from the alexa site to send the commands

To share the cookie is a security problem , with the cookie it’s possible to control your echo and smart devices connected to system. it´s possible to know your name, email, address, wifi network, etc.

I don’t like to use a third party servers to get the cookie and update it

To avoid the use of external server, this development needs to get the cookie manually to use it, only you will known the cookie and this information will be send only to your amazon server (.com, .uk, .mx, etc)

I think the cookie last 15 days, then you need to update the cookie again.

Tip: Try to open a incognito window to login in alexa.amazon.com, once you get your cookie just close the window, if you log out from the site , your cookie will expire, then just close the window and you can open other session in your regular browser if you need it.

To get the cookie you need to go to alexa.amazon.com, if you are in other country the site will redirect you to your country site.

Instructions to get the cookie https://www.gehrig.info/alexa/Alexa.html , we need the Domain : https://alexa.amazon.com or the domain you get in the site, it depends of your country, the CSRF and the cookie

If you have problems to find the beginning and end of the cookie, try to use the site https://incarnate.github.io/curl-to-php , it will parse the curl command into pieces. just be careful to remove the Cookie: . from the beginning if you use the site.

In my Chrome Browser I use the option “Copy as Curl(bash)” and paste that info en the parser site.

If your browser does not have the option “Copy as Curl(bash)” be careful your cookie data do not have ^^ characters, try to use another copy as curl option

You need add the info obtained from alexa site in the iniSettings() secction of the Echo Connect App Code, it have some example data , but you must replace it with your real info

def iniSettings(){
state.cookie = “x-amzn-dat-gui-client-v=1.24.2024…I6H6epBktwjMhQjRRVM+c9uvwoX6”
state.csrf = “-2168072530”
state.domain = “https://alexa.amazon.com

I still need to add more functions, but need your feedback to improve the code.

Updates

v 1.4.0

Added some speak commands in speak function , now you can ask Weather,Traffic,FlashBriefing,GoodMorning,SingASong,TellStory in speak command

Restore volume is not possible due a undefined length of phrase, but you can force a restore volume if you set a delay

Example speak(“weather”) or speak(“tellStory”,50) or speak(“tellStory”,50, 20)

v 1.3.1

Fix Volume value, each Update Status the volume is updated even if no media is playng
Fix Status, Added “IDLE” and “Standby” status
Speak Parametrs Added, you can use speak with volume change and custom delay, volume and delay are optional speak(Message required, Volume optional, Delay optional)
speak(“The door is open”) TTS
speak(“The door is open”, 50) TTS If New Volumen != Current Volume it changes and after some time the volume is restored, the delay is message/19
speak(“The door is open”, 50, 4) TTS If New Volumen != Current Volume it changes and after custom delay the volume is restored

V1.2.0 Added createReminder("2018-12-25T00:01,“Christmas Time”)

V1.1.0 Added TuneIn stations, Search and play

tell me if works with others alexa third party devices.

1 Like

Hi.
Looks interesting.
The 2 groovy files are they both to be installed as SmartApps or Device Handlers ?

Hi @Steveuk23, the echo connect is a smart app , the echo code is the device.

@ule - its been frustrating for a while I cannot automate (turn off) Echo in my routines. It’s not clear if this is possible with your smartapp. Is it?

Thanks
I’ve added both them and gone into the Smartapp but there’s nowhere to enter the cookie data.
I’ve created a new device with the device handler and that doesn’t have anywhere to enter the credentials either.

Hi @Steveuk23, You can set the cookie inside the code off Echo connect app.

def iniSettings(){
state.cookie = “”
state.csrf = “-2168072530”
state.domain = “https://alexa.amazon.com
state.loadStatus = “Inactive”
log.trace “state.loadStatus ${state.loadStatus}”
return dynamicPage(name:“iniSettings”, title:“Connect Your Echo devices to SmartThings”, nextPage:“chooseDevices”, install:false, uninstall: true) {
section(“Echo Remote Credentials”) {
paragraph “Get your Echo data from https://alexa.amazon.com\r\n\r\nThe cookie data is to long, you must to split it in 3 parts, go to APP settings in IDE to add the info\r\n\r\nTap ‘Next’ after you have entered the data.\r\n\r\nOnce your request is accepted, SmartThings will scan your Echo devices.”
}
}
}

The options in the connect app are greyed out and won’t let me enter anything.


hi, you must to write the data inside the code in the IDE , its easier to write in the iDE than the phone,

In your Echo connect app you must go to settings and write the data

def iniSettings(){
state.cookie = “”
state.csrf = “”
state.domain = “”
state.loadStatus = “Inactive”
log.trace “state.loadStatus ${state.loadStatus}”
return dynamicPage(name:“iniSettings”, title:“Connect Your Echo devices to SmartThings”, nextPage:“chooseDevices”, install:false, uninstall: true) {
section(“Echo Remote Credentials”) {
paragraph “Get your Echo data from https://alexa.amazon.com\r\n\r\nThe cookie data is to long, you must to split it in 3 parts, go to APP settings in IDE to add the info\r\n\r\nTap ‘Next’ after you have entered the data.\r\n\r\nOnce your request is accepted, SmartThings will scan your Echo devices.”
}
}
}

1 Like

So I added the csrf and domain.
And entered the cookie code but when I hit save on the IDE I get a error.
But then in your description I see something about spilting the cookie code into 3 as it’s too long but it doesn’t say how or where.
Could you do some clearer instructions.
Thanks

hi @Steveuk23, Forget the split I have changed it inside the code, it’s easier, I have changed the text in connect app

I think you are omitting escape the double quotes, just check the cookie example in the code.

I suggest you to use the page https://incarnate.github.io/curl-to-php to paste the cookie curl, and you going to have the cookie formatted, just remember to remove the Cookie: at beginning.

inside the Connect code you must to write the data

state.cookie = “x-amzn-dat-gui-client-v=1.24.2024399.0; session-id=173-…[truncated ]…uvwoX6Bsdo=”"
state.csrf = “-2168072530”
state.domain = “https://alexa.amazon.com

1 Like

i’m not having much luck with this unfortunately.
i’ve now correctly added the data to it and made sure it has the double quotes and it saves fine but then when i go to the app there’s nothing showing in the select echos , it still says you can’t currently add this.
i’ve blanked some info out as i’m not sure if they are passwords etc…


Hi, I can see in the cookie you have ^^ , that characters are not valid, I think you use some copy as curl different.

If you use chrome I suggest you to use the " Copy as CURL (bash) " option. be careful not to have that characters ^^

Ah right
Thanks, that website says to use curl (CMD) if using windows.
I’ll do it again later.

I have added a function to create remainders Added createReminder("2018-12-25T00:01,“Christmas Time”)

it must be consumed trough some smart app.

I’ve got it responding now and I’ve selected my echos.
But unable to test it as it’s late here now :open_mouth:

1 Like

Hi @Steveuk23, great news , just try to push the normal button to change to station and push the button play station, it will play smooth jazz music , you can change stations with forward and prev buttons. in settings you can add your search words to play

Hi, I have updated the code, new parameters to command speak()

Speak Parametrs Added, you can use speak with volume change and custom delay, volume and delay are optional speak(Message required, Volume optional, Delay optional)

speak(“The door is open”) TTS

speak(“The door is open”, 50) TTS If New Volumen != Current Volume it changes and after some time the volume is restored, the delay is message/19

speak(“The door is open”, 50, 4) TTS If New Volumen != Current Volume it changes and after custom delay the volume is restored

New Update.

Added some speak commands in speak function , now you can ask Weather,Traffic,FlashBriefing,GoodMorning,SingASong,TellStory in speak command

Restore volume is not possible due a undefined length of phrase, but you can force a restore volume if you set a delay

Example speak(“weather”) or speak(“tellStory”,50) or speak(“tellStory”,50, 20)

2 Likes