Echo Devices (Alexa) as Media Player - Testers Needed

Thanks very much. My url is right, so I’ll give it a try.

If you have problems, try post No.7 in the discussion. I’ve invited you too.

This automation is amazing!! Worked for me with almost no modification. Removed 7 or 8 battery template sensors and still able to track their status.

Please DM your logs. I tried inviting you to debug earlier but you never joined. Also, what domain are you using?

@LarsAC
Please turn on debugging per my message with RandyA and DM the logs. Also, what domain are you using?

@keithh666
The standby problem should only happen if you’re on the wrong domain. One way to check is to manually try to log into https://alexa.amazon.com/api/devices-v2/device and compare it with https://alexa.amazon.co.uk/api/devices-v2/device or other domains to see which returns the larger response and which one has more "online":true entries. Assuming .co.uk does give you the longer list/more online entries, we may have to do a new build to debug what’s happening.

Hi,
Is there a way of making a Sonos mirror an Alexa? I use a Sonos in the same room as my Alexa (although in different places in the room) as the sound quality is far better, but it would be great if the Sonos mirrored Alexa.

Hmm strange the .com gives more entries but neither have any devices online, however I can still ask alexa stuff and it works ;P, going to change to .com and see if it changes anything.

Edit: my echo is online true in the .co.uk one.

Edit: the devices change to unavailable with .com

Edit: trying a reboot rather than a restart

Well, if not for this school boy error, I wouldn’t find the solution as well.
Thanks for asking DrZzs, and thanks for the answers. A simple a forum lookup solved this problem for me as well.

Got everything working “right out the box” with Alexa Echo as a media player and the Alexa TTS. I have, however one small question; is it possible to have the Alexa TTS to speak slower? She speaks to quick for our liking, given English isn’t the first language in this house :slight_smile:

One suggestion is to make sure you use proper punctuation in your text. She speaks at the same rate she would speak anything, such as a flash briefing, etc. Punctuation makes a big difference.

Yes, I noticed. I have written it out with the correct punctuations. Is there a way to make Alexa pause a little longer between each sentence instead maybe? With Amazon Polly TTS, this is an option if I rememember correctly.

This is essentially using the command “Alexa Simon say - your TTS here.” there is no way via commands, or settings to slow this down, it does not use amazon Poly. it’s a clever (very clever) hack. If you want to slow it down I recomend trying adding commas, extra periods, etc? Maybe try different messages via json, etc until you get it to speak at the speed you want. that is really the only option for this component

1 Like

Seems after updating to latest HA today, I’m stuck in the cyclic captcha process, despite this working previously.

I’ve pushed to the latest custom component, deleted the cache py, even remove the pickle and tried all combinations on amazon, but simply can’t get it to work anymore.

I’m running the docker version of HA and have always been. Trying to see now if I can figure out why it’s going in cycles, but it’s not easy :frowning:

— Update —
After editing the file and enabling the debugs/save of the file, I pulled back the alexa_mediapost.html and tried to follow that through… after a couple of goes in firefox, it requested to authenticate with a text/email. Once I’d done that it all started working.

@keatontaylor - would it be possible to pick the first validation option (be it email or text) and change the configure box to use that after the captcha so that you don’t get stuck in a loop when it decides randomly to need to validate your account? I’d have a stab myself, but I’m a noob at python :smiley:

Are you referring to a 2 Factor Authentication page? The code should automatically detect when it’s asking for a 2FA and request that instead. I assume you have 2FA turned on and it wasn’t some other random page. If it’s a random page, we’re trying to figure out what that is so we can analyze it to fix the Captcha loop.

Hi there. I got through the captcha and in the logs, I have confirmation that I’m successfully logged in, but I always get this error.

Can somebody help whats going wrong?

The error is always present, it doesnt matter if i play music through it or not.

Error doing job: Future exception was never retrieved
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/concurrent/futures/thread.py", line 56, in run
result = self.fn(*self.args, **self.kwargs)
  File "/config/custom_components/media_player/alexa.py", line 220, in setup_alexa
update_devices()
  File "/usr/local/lib/python3.6/site-packages/homeassistant/util/__init__.py", line 325, in wrapper
result = method(*args, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/homeassistant/util/__init__.py", line 325, in wrapper
result = method(*args, **kwargs)
  File "/config/custom_components/media_player/alexa.py", line 192, in update_devices
update_devices, url)
  File "/config/custom_components/media_player/alexa.py", line 258, in __init__
self.refresh(device)
  File "/config/custom_components/media_player/alexa.py", line 300, in refresh
if 'muted' in self._session['volume']
TypeError: argument of type 'NoneType' is not iterable

Im in the same boat - getting “TypeError: argument of type ‘NoneType’ is not iterable”.

Hopefully an easy fix

There is already an issue open for this: https://github.com/keatontaylor/custom_components/issues/25

No fix yet.

So when I got the error, I uncommented the lines out that wrote out the HTML.

I landed here:

Now - I didn’t save the next page, but what I did was fill in the captcha and password and press sign-in. At that point, I was asked to revalidate my account via 2FA, even though I don’t have 2FA enabled, so I ended up on the screen where I was asked where to send a code, either to my email address or a text message. I picked text message, got the code, and logged in.

Once I’d done that, I went back to HA, started the process again and was logged straight in.

NOTE - I don’t have 2FA turned on in my account. I was prompted to revalidate my account for whatever reason via 2FA. Intriguingly, I’d tried logging in/out/switching/etc loads of times before enabling the HTML write out. Only through the HTML file that was written out did I get the 2FA prompt.

Been loving this and using it for a number of automations. Was working great yesterday but today for some reason the Alexa devices are not being discovered and I have this in the log:

Traceback (most recent call last):
File “/usr/local/lib/python3.6/concurrent/futures/thread.py”, line 56, in run
result = self.fn(*self.args, **self.kwargs)
File “/config/custom_components/media_player/alexa.py”, line 216, in setup_alexa
update_devices()
File “/usr/local/lib/python3.6/site-packages/homeassistant/util/init.py”, line 325, in wrapper
result = method(*args, **kwargs)
File “/usr/local/lib/python3.6/site-packages/homeassistant/util/init.py”, line 325, in wrapper
result = method(*args, **kwargs)
File “/config/custom_components/media_player/alexa.py”, line 188, in update_devices
update_devices, url)
File “/config/custom_components/media_player/alexa.py”, line 252, in init
self.refresh(device)
File “/config/custom_components/media_player/alexa.py”, line 291, in refresh
self._media_is_muted = self._session[‘volume’][‘muted’]
TypeError: ‘NoneType’ object is not subscriptable
2018-08-25 10:08:38 ERROR (MainThread) [homeassistant.core] Error doing job: Future exception was never retrieved
Traceback (most recent call last):
File “/usr/local/lib/python3.6/concurrent/futures/thread.py”, line 56, in run
result = self.fn(*self.args, **self.kwargs)
File “/config/custom_components/media_player/alexa.py”, line 166, in
track_utc_time_change(hass, lambda now: update_devices(), second=30)
File “/usr/local/lib/python3.6/site-packages/homeassistant/util/init.py”, line 325, in wrapper
result = method(*args, **kwargs)
File “/usr/local/lib/python3.6/site-packages/homeassistant/util/init.py”, line 325, in wrapper
result = method(*args, **kwargs)
File “/config/custom_components/media_player/alexa.py”, line 188, in update_devices
update_devices, url)
File “/config/custom_components/media_player/alexa.py”, line 252, in init
self.refresh(device)
File “/config/custom_components/media_player/alexa.py”, line 291, in refresh
self._media_is_muted = self._session[‘volume’][‘muted’]
TypeError: ‘NoneType’ object is not subscriptable

I don’t believe I’ve changed anything and I tried deleting the pickle file and the pycache which brought back the captcha and successfully entered, recreating the files but still no devices are showing up. Even tried the log out and back into the Amazon site with no joy. Anyone had anything similar?

Oh and thanks @SMARTMEDIA, loving your battery sensor automation too!

@falcon2k17 @cmille34 @kdavidson
Potential fix is in the hopper. I can’t reproduce the error so need some testers before we merge it in.

If anyone can get us the raw HTML for this page, we can see about addressing it through home-assistant. I think this may be the cause of the captcha loop everyone is hitting.

1 Like

if I hit it again, I’ll get the raw HTML… I didn’t honestly expect it to work, and don’t really know in what scenario amazon does this! If anyone is in the same situation, you’ll need to:

  1. Enable the file write somewhere around line 700 (in latest version) by uncommenting the localfile lines

  2. restart HA, then go through the configure cycle once

  3. After the captcha comes back again (even though you got it right), locate the file: alexa_mediapost.html which should be in the home-assistant directory (along with the pickle file) - this HTML is created from the lines you uncommented.

  4. Pull it locally, then open it in a browser

  5. try the sign in with the captcha from this HTML.

  6. If after submitting you then get taken to a screen to validate your account, save that page’s HTML! as this needs to be understood

  7. Then re-validate your account on the screen, and once done go back, refresh HA, and try the configure again.