Echo Devices (Alexa) as Media Player - Testers Needed

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.

@keatontaylor Feature request:

Add exclude/include entities option.

I know this is a little edge case but I’m in an Amazon Household with parents who are in another property.(sharing Prime)
Unfortunately the way Amazon handles that is to merge all devices together. So after getting this component working, I have all my parents devices in my HA which isn’t really desirable.

Perfect solution to be able to exclude devices.

Thanks for considering it.

1 Like

This was added in the latest version. Sorry I haven’t posted here about the “release”

1 Like

Is there a change log or release info for the new version somewhere? Sorry I’m struggling to find one.

Hope @keatontaylor doesn’t mind me replying on their behalf. You can use the GitHub history which seems be be pretty well documented and hopefully you can work out what you need from that. Looks like you just need to specify the device name (i presume as listed in the Alexa app) with exclude_devices in the media_player entry of your configuration.yaml. Have a look at: https://github.com/keatontaylor/custom_components/commits/master/media_player/alexa.py

Any clues on the syntax @keatontaylor?

Just a little testing:

- platform: alexa
  email: [email protected]
  password: secret
  url: amazon.com
  exclude_devices:
    - media_player.remcos_alexa_apps
    - media_player.this_device
    - media_player.this_device_2

Does not work.

  exclude_devices:
    - remcos_alexa_apps
    - this_device
    - this_device_2

And

exclude_devices: media_player.remcos_alexa_apps

Also does not work.

1 Like

This code was added by someone other than me to exclude devices. The code looks like it excludes based on the name of your echo in the Alexa app. Can someone give that a try?

Hi Justin,

This looks great! I also plan on connecting a dot to whole house audio and this type of setup looks like it would work well. Could you share your card that calls this flow? I have my head around Node-RED a bit, but haven’t figured out how to connect cards to it other than calling flows via URLs.

Thanks!

FYI, a media_content_type of SIRIUSXM (if you have the skill setup) will also work when playing music.

{
“media_content_id”: “The Blend”,
“media_content_type”: “SIRIUSXM”,
“entity_id”: “media_player.kitchen”
}

This is a great addition and I’m glad I found it! Thank you for all your hard work, Keaton!

1 Like