Echo Devices (Alexa) as Media Player - Testers Needed

@Matt_Vaughn

{“entity_id”: “media_player.bathroom_echo_dot”, “message”: “Test message”}

When I copied the above into the service dev tool, I get “invalid json”. It only works for me if I change your curly quotes to the plain straight ones in the line below.

{"entity_id": "media_player.bathroom_echo_dot", "message": "Test message"}

You may have other issues too, but the quotes you used will not work for me. Perhaps you originally typed that using a Word processor that changes plain double quotes to open quotes and closed quotes (aka curly quotes)?

1 Like

My config entry doesn’t have quotes around the url, email, or password. I know the first post example has quotes, but I’m thinking that caused me problems.

1 Like

So did the snapshot put the alexa.py back into the custom_components/media_player for you or did you have to download it again? If you downloaded it again, make sure you downloaded it from the RAW file:

https://raw.githubusercontent.com/keatontaylor/custom_components/master/media_player/alexa.py

1 Like

@PlayedIn

Thanks for the response. The quotes are fine, my copy and paste just didn’t show them correctly. I am not getting any “invalid json” errors.

Tried recopying the alexa.py and pasting into a new file to replace the old, but still no dice. Calling the service works fine, no errors in log, but no audio from echo.

Down under developer tools, under states, what is the State and also the Attributes of media_player.bathroom_echo_dot? Do you also have a Google Home with which TTS isn’t working? What other media_players are not working that should be? Are you on Hassio? What version of Home Assistant? 0.84.5?

I have a google home, but have not attempted tts with it yet. We have 3 echos, wanted to use them instead.

tts does not work on any media player. All other media players work fine otherwise.

On Hassio RP3 version 0.84.6

@PlayedIn

I have also tried having music playing on the echo when pushing the tts call, which should have muted the music, played the message, then unmuted. But it didn’t.

So when the echo is playing music, you can see what is playing on the media_player, correct? While its playing are you able to change the volume and pause the music with the media_player?

Thanks for the reply. The Alexa custom component was not part of the snapshot I reloaded. That was a component I had added after the snapshot, so I added back manually today. When I downloaded the file, I did download from raw.

Any other thoughts?

Yep, I can pause, skip, turn off, change volume and I get album art.

I see that you are using quotes around email, password, and url. I was never able to get it to work with quotes. YMMV

I even commented out my media_player: !include… in configuration and re-entered just this

media_player:

  • platform: alexa
    email: xxxxxxxxxxx
    password: yyyyyyyyy
    url: amazon.com

Still nothing

Dang it should be working. Any chance you at one time tried a different url instead of amazon.com? I’m assuming you’re in the U.S.? You might want to search this thread for “pickle” as I remember some have had to delete the pickle file to get TTS to work. Grasping at straws here.

In the US and have deleted the pycache and pickle file twice now, rebooted and went through the entire captcha authentication. The issue is not the discovery of my devices, but simply the routing of the tts through the echos.

I’m out of ideas. Maybe create an issue on Github so that @keatontaylor might help? May have to resort to the other method of TTS which is what I use for the last_alexa sensor which can be found here:

Thanks for the suggestion. I removed the quotes and restarted. That seemed to have resolved some of the issue, but now I’m getting a different error about not being able to connect to Amazon.

Also, I’ve not yet seen the Catcha appear on the frontend UI since my reinstall yesterday.

Here’s the error from the logs:

Log Details (ERROR)
Sun Dec 23 2018 06:28:52 GMT-0500 (Eastern Standard Time)

Error while setting up platform alexa
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/urllib3/connection.py", line 159, in _new_conn
    (self._dns_host, self.port), self.timeout, **extra_kw)
  File "/usr/local/lib/python3.6/site-packages/urllib3/util/connection.py", line 57, in create_connection
    for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM):
  File "/usr/local/lib/python3.6/socket.py", line 745, in getaddrinfo
    for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
socket.gaierror: [Errno -3] Try again

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/urllib3/connectionpool.py", line 600, in urlopen
    chunked=chunked)
  File "/usr/local/lib/python3.6/site-packages/urllib3/connectionpool.py", line 343, in _make_request
    self._validate_conn(conn)
  File "/usr/local/lib/python3.6/site-packages/urllib3/connectionpool.py", line 839, in _validate_conn
    conn.connect()
  File "/usr/local/lib/python3.6/site-packages/urllib3/connection.py", line 301, in connect
    conn = self._new_conn()
  File "/usr/local/lib/python3.6/site-packages/urllib3/connection.py", line 168, in _new_conn
    self, "Failed to establish a new connection: %s" % e)
urllib3.exceptions.NewConnectionError: <urllib3.connection.VerifiedHTTPSConnection object at 0x7010b490>: Failed to establish a new connection: [Errno -3] Try again

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/requests/adapters.py", line 449, in send
    timeout=timeout
  File "/usr/local/lib/python3.6/site-packages/urllib3/connectionpool.py", line 638, in urlopen
    _stacktrace=sys.exc_info()[2])
  File "/usr/local/lib/python3.6/site-packages/urllib3/util/retry.py", line 398, in increment
    raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='alexa.amazon.com', port=443): Max retries exceeded with url: /api/devices-v2/device (Caused by NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0x7010b490>: Failed to establish a new connection: [Errno -3] Try again',))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/homeassistant/helpers/entity_platform.py", line 128, in _async_setup_platform
    SLOW_SETUP_MAX_WAIT, loop=hass.loop)
  File "/usr/local/lib/python3.6/asyncio/tasks.py", line 358, in wait_for
    return fut.result()
  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 142, in setup_platform
    config.get(CONF_DEBUG))
  File "/config/custom_components/media_player/alexa.py", line 608, in __init__
    self.login_with_cookie()
  File "/config/custom_components/media_player/alexa.py", line 631, in login_with_cookie
    self.login(cookies=cookies)
  File "/config/custom_components/media_player/alexa.py", line 747, in login
    resp = self._session.get(site)
  File "/usr/local/lib/python3.6/site-packages/requests/sessions.py", line 546, in get
    return self.request('GET', url, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/requests/sessions.py", line 533, in request
    resp = self.send(prep, **send_kwargs)
  File "/usr/local/lib/python3.6/site-packages/requests/sessions.py", line 646, in send
    r = adapter.send(request, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/requests/adapters.py", line 516, in send
    raise ConnectionError(e, request=request)
requests.exceptions.ConnectionError: HTTPSConnectionPool(host='alexa.amazon.com', port=443): Max retries exceeded with url: /api/devices-v2/device (Caused by NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0x7010b490>: Failed to establish a new connection: [Errno -3] Try again',))

Any thoughts @keatontaylor? Thanks to everyone.

And how to use your code inside HA?

I don’t want to hijack this post. Be sure you understand how Appdaemon works and if you still have questions i am happy to help you via PM or an issue in my repo.

1 Like

I re-started again, got the Captcha, and was able to complete the setup. Not sure what happened before, but up and running now.

2 Likes

Did you get it working?
I’m having the same problem.