Echo Devices (Alexa) as Media Player - Testers Needed

Here’s something to try for those dealing with Captcha not showing issues, I had a small issue with the Captcha after upgrading to HA 0.74.0…

  • Delete the "custom_components/media_player/__pycache__" folder.
  • Restart HA
  • Hard refresh the HA page in your browser.

On Windows/Linux, Hold down Ctrl and press F5 for Chrome/Firefox/Edge…
On Mac, Hold ⇧ Shift and click the Reload button for Chrome/Firefox.

I find a Hard refresh usually fixes 99% of my frontend issues with updates or new components. If anything it’s something to check off the list since I haven’t seen it mentioned yet.

Issue is from those who have long ping times to US (i.e. AU/ NZ, etc.)
I get the same ‘update’ error timing (and always have since you first made this module).
Internet on this side of the planet uses a carrier pigeon sometimes :-/

Trying url: alexa.amazon.com gives an error,

urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host=‘www.alexa.amazon.com’, port=443): Max retries exceeded with url: /gp/sign-in.html (Caused by NewConnectionError(‘<urllib3.connection.VerifiedHTTPSConnection object at 0x7f833682b0>: Failed to establish a new connection: [Errno -2] Name does not resolve’,))

using url: amazon.com.au results in no captcha being requested.

Which url value i need to use for germany?


alexa.amazon.de
or also

I guess it’s where your account is registered. I bought my Echo from Amazon.co.uk but my account is on amazon.com, so I use .com

Doesn’t matter which country you are from, or which country you are travelling to now, let’s say.
All it matters is the domain of the account that has the Alexa / Echo devices binded to it.
I have amazon accounts on .com, .uk, .au, but my devices are all on amazon.com … so .com it is for me.

If the .com website has high latency there isn’t much that I can do. The major issue with increasing the update interval is that it will increase the time it takes for the comment to see state changes in the media players. So say if I increased it to 30 seconds, it would mean it could take up to 30 seconds for a media player to show the next song title or album art when the echo moves to a new song.

The only real option would be to allow the user to set the update interval for themselves, so that they could decide just what is acceptable.

Update! - Login Issue Potentially resolved

I applied a fix today that instead of checking the login page for a specific keyword/phrase tries to gather a list of echo devices as a means of checking if login was successful. This should work better for those in other regions that the language is something other than English.

As always the code can be found on my GitHub [https://github.com/keatontaylor/custom_components/blob/master/media_player/alexa.py]

Please ensure when downloading that you you ‘VERSION: 0.7.1’ in the file

I wanted to also take a moment to discuss the future of this project. First let me outline what still needs to be done.

  1. Verify that login is working for users
  2. Upload the Alexa Login / Alexa API code to PyPi (pip)
  3. Ensure the component passes all tests/linting for HA
  4. General cleanup and refactor
  5. Submit to HA

If you see any omissions in my list above, please let me know. :slight_smile:

1 Like

Just ran into another issue with the login. Looks like the captcha is not always the only thing that amazon requires to login this way. Sometimes you get an email verification link that is required to proceed. I’ll have to work this into the auth flow. So for those having issues where it keeps asking for the captcha this could be the issue.

amazing work,
please could these work with your skill https://github.com/home-assistant/home-assistant/pull/15320

I have placed the custom component under custom_coponents/media_player/alexa.py.

I then have added the following

media_player:
  - platform: alexa
    email: "my email"
    password: "my password"
    url: alexa.amazon.com

I am not getting any errors but I am not getting any Alexa media players discovered, am I missing something?

1 Like

no quote and double quote, no need alexa in front amazon.com

media_player:
  - platform: alexa
    email: my email
    password: my password
    url: amazon.com
2 Likes

that did the trick, cheers.

I now get the capture screen but can’t see the capture characters, I input something random in the hopes it will pop up again with the characters but the capture screen never pops back up.

same thing is happening to me. I can get it to work sometimes but then it will disconnect shortly after

Did you have lxml and bs4 installed?

Try logging out of HA in your browser, doing a hard refresh as suggested by @VladTepz.

Then log back in and try again. I never get the Captcha first time either, just random text. I type in some letter, hit enter, then try again. 2nd time always works for some reason.

Alas it did not make a difference still can’t see the capture characters if I input anything it never pops back up unless I reboot. Using hassio 0.73.1 RPi 3b

I tested the newest version again. To see if it works now for germany. But it failed with the following errors in the logs:

2018-07-22 12:33:22 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 173, in setup_alexa
    update_devices()
  File "/usr/local/lib/python3.6/site-packages/homeassistant/util/__init__.py", line 318, in wrapper
    result = method(*args, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/homeassistant/util/__init__.py", line 318, in wrapper
    result = method(*args, **kwargs)
  File "/config/custom_components/media_player/alexa.py", line 129, in update_devices
    devices = devices.json()['devices']
  File "/usr/local/lib/python3.6/site-packages/requests/models.py", line 896, in json
    return complexjson.loads(self.text, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/simplejson/__init__.py", line 518, in loads
    return _default_decoder.decode(s)
  File "/usr/local/lib/python3.6/site-packages/simplejson/decoder.py", line 370, in decode
    obj, end = self.raw_decode(s)
  File "/usr/local/lib/python3.6/site-packages/simplejson/decoder.py", line 400, in raw_decode
    return self.scan_once(s, idx=_w(s, idx).end())
simplejson.errors.JSONDecodeError: Expecting value: line 8 column 1 (char 7)

Any idea what that means?

2 Likes

Getting exactly the same error as you lweberru

But for UK, I get the captcha then all I see is that error every minute or so, I tried some changes in the python like en-US to en-GB and different URLS - just ends up not working with no error messages,

Anyone any ideas ?

Cheers

I’m getting this error on 0.7.1 and the captcha also not working in this version. On 0.7 its working fine.
image

@keatontaylor brilliant works superbly. Is it possible you could add BBC as a media content as echo/dot still showing idle when BCC radio is playing (BBC is the default player in UK )

many thanks for all your work