My cookie timed out after 23 days. No issue is recreating with the authenticator
@lonebaggie Thank you for providing instructions on how to do this. I had a question that I couldn’t find the answer to while skimming through previous posts or I didn’t understand the answer. Once I turn on 2 factor authentication and create the cookie, can I turn 2FA back off again or must I leave it on at all times for this to work properly?
I currently have the Echo media player working using “Echo Devices (Alexa) as Media Player - Testers Needed” and I don’t want to break it. Sorry if you’ve answered this previously.
Once you have the cookie file ,the script will run until it times out .Both systems support 2FA. I run both systems without issue
The only reason I use Alexa script is for last Alexa function , if you only have one echo the media player option is a much better option
Thank you for the reply. Yes I want the last alexa function too. So you’re saying I “can” turn off 2FA until its time to generate another cookie?
I can’t see why not , but 2fa on an amazon account seems very sensible to me
it appears the more you request the script the shorter the cookie life. Running the ask alexa sensor every min cookie life was about 2 days . every hour about 23 days
Arrrrgh, I cannot create the cookie. I must be doing something wrong.
I enabled 2FA and it works from a browser
Using ssh I placed alexa_remote_control.sh into /TMP
I am in the US. I edited alexa_remote_control.sh:
On the password above, I used the Authenicator app to append the 6 digits to my password like this example:
I then quickly (before the 30 seconds expire) execute:
But each time I get:
And of course, no cookie:
core-ssh:/tmp# ls /tmp -la total 108 drwxrwxrwt 1 root root 4096 Nov 26 18:53 . drwxr-xr-x 1 root root 4096 Nov 25 20:48 .. -rw-r--r-- 1 root root 67221 Nov 26 18:53 .alexa.login -rwxr--r-- 1 root root 32693 Nov 26 18:53 alexa_remote_control.sh
When I open .alexa.login with browser, it shows that it still wants the captcha even though I added the 6 digits from the authenticator app.
I know I am using the correct email and password. I cannot figure out what else I might be doing wrong? Any ideas?
dont add the 6 digits to your password.
get the firefox addon cookies.txt
export your cookie with the name it has in the sh file
(and i dont think its the wisest move to place programs you want to use in tmp )
Yes thanks. Its really in /config/alexa, but I copied over to /tmp while trying to figure out what might be wrong. So I should:
Install firefox and install a firefox addon called “cookies.txt”?
Use firefox to login to Amazon.com successfully?
Then use the addon to export the Amazon cookie?
Then rename the cookie to .alexa.cookie?
I am using Hassio. Its okay to use another computer to use Firefox to create the cookie?
if thats the name in the sh file.
or save it with any name and change the name in the sh file to what you called it.
it saves default to cookies.txt so i did put that in the SH file.
just make sure the cookie file has the right owner and fileright settings.
Sorry I don’t know how to do that. I don’t know much about linux.
find a program that makes that visual for you.
i use winscp.
to set the filerights with commands isnt my kind of thing either
if you use samba and are using the right user to login, it should be right in most cases.
Ok you were right. Just copying the cookie over to the samba share from my Windows computer seemed to work just fine. No longer getting “cookie does not exist”. Thanks.
looks like authenticator route does not work in the US can’t see that you were doing anything wrong . Perversely I have never managed to get the copy cookie method to work
Glad its sorted
Thank you @lonebaggie! I really appreciate this whole solution that you put together along with the py script and the yaml code that you provided. One other question I did have though is, is there an easy way for me to replace the spaces with underscores in the media player name that is returned from the script?
I’m struggling with my automations with those echoes that have a space in the name such as “Echo Plus” or “Laundry Room”. In other words when I’m using alexa tts to send a message back to the echo, those with spaces aren’t working because the syntax requires an underscore instead.
the easiest way is to rename those devices in the alexa app.
just dont use spaces in the names
Yeah was hoping to avoid that due to breaking a lot of other integration, but will do if I must.
its always the best way to tackle the problem at the beginning.
if you get around it now, you will run into it at another moment again.
Ok I decided I preferred to be able to name my echoes with spaces. I wanted the alexa_wrapper.py to replace spaces with underscores which made it more compatible with HA. Therefore I changed the last line from
You’re probably right. However I tried renaming “Laundry Room” to Laundry in the Alexa app. Now almost 2 hours later, sensor.last_alexa still shows the old name. In the Alexa app the echo is called “Laundry”. I have activated other echoes so that sensor.last_alexa changes, but when I activate Laundry, the script is still returning the old name, Laundry Room for sensor.last_alexa. Any ideas?
I found the problem. I also had to rename it in the .alexa.devicelist.json file
the line you replaced is only for the output in the terminal, so it wouldnt change anything
and besides renaming it in the list you could also delete the list, it will be recreated.