Echo Devices (Alexa) as Media Player - Testers Needed

you dont set the TTS platform.

the mediaplayer adds a service called media_player.alexa_tts

Ok, I should just comment tts out then?

if you dont use google TTS or any other TTS then you dont need the TTS section.

Ok, sounds good. That was in my config file from day one, figured it was supposed to be used. When I get home tonight I’ll play with that.

Thabks for your help!

I figured that may be the case, but I’m curious as to what is used as an intermediary between Alexa and HASS/NodeRed. Do you create a switch and then get the routine to trigger that? Cheers.

a switch, an input_boolean, the brightness from a virtual light(none existing light created in HA), anything that can be set in home assistant that can be used to trigger an automation.

i use:

  • routine in alexa app changes brightness from a virtual light
  • emulated hue picks up the change
  • appdaemon app sees that the light changes (thats my automation)
  • appdaemon app does some stuff
  • appdaemon app sends TTS to alexa
  • appdaemon app switches the virtual light off again.

so thats my flow.

1 Like

Thats brilliant! Thank you kindly for spelling it out for me haha. A lot of sequences don’t seem immediately obvious so I’m still catching on. Thanks again.

1 Like

how do i get spotify to work on this i have got a file i have been trying but the echo is just saying about spotify connect. this is what i got.

 - service: media_player.play_media
       data:
        media_content_id: 'Alarm'
        media_content_type: 'SPOTIFY'
        entity_id: media_player.echo

is there a work around for having 2FA enabled on your amazon account?

The Node Red sequence is triggered when the Boolean is set to on. At first I just created a routine in Alexa to turn on the HA Boolean when you say, “Is the garage door open”. However later I found it worked better for me to create an HA script that updated the last_alexa sensor and then turns on the Boolean. I then set an Alexa routine to execute the HA script when I say, “Is the garage door open”. The script updates the last_alexa sensor and then turns on the Boolean which triggers the Node Red sequence.

I did this is because I wanted to increase the scan_interval of the last_alexa sensor and only update the sensor right before I needed it (I did this hoping to extend the life of the cookie that is required by Alexa_remote_control.sh; however I’m not sure it increased the cookie life).

The latest version of this media player supports 2FA, so I’m not sure what workaround you are asking about.

Any way to fix this ? Alexa as mediaplayer is not usable with this bug.

My Alexa media player also stopped working after HA upgrade from 0.83.3 to 0.84.5. Need help to fix this.

It works here, I only deleted the alexia.media.pickle file and the pycache directory, and a new CAPTCHA pairing was necessary. After that worked as usual.

I don’t know if i’m off topic, but, if it possible to create an automation to connect echo with a bluetooth speaker ( check first if the speaker is powered on/available) and talks trought it?

I did exactly that with Appdaemon. You can find the code here

1 Like

Thanks. I’ve never tried appdaemon. I’ll try it

i am sure that i am doing something really dumb!

i have installed the alexa.py in the following directory: /.homeassistant/custom_components/media player with the other custom components i have.

i have the following in the config file:

      - platform: alexa
        email: "xxxxxx"
        password: "xxxxxxxx"
        url: "amazon.co.uk" 

but i get this error:
Platform not found: media_player.alexa
and
Unable to find component media_player.alexa
I am sure i am doing soemthing silly

Hey there.

I recently had to start again with 0.84.6 because something went sideways with the upgrade to 0.84.2 previously and it was easier to start from my most recent snapshot. I’ve got everything back up and running except for my Alexa media players using this custom component.

My relevant config section looks like this:

media_player:
  - platform: alexa
    email: “email redacted”
    password: “password redacted”
    url: “amazon.com”

When I look at the logs I see:

018-12-22 12:12:04 ERROR (MainThread) [homeassistant.components.media_player] Error while setting up platform alexa
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/requests/models.py", line 350, in _get_idna_encoded_host
    host = idna.encode(host, uts46=True).decode('utf-8')
  File "/usr/local/lib/python3.6/site-packages/idna/core.py", line 361, in encode
    s = alabel(label)
  File "/usr/local/lib/python3.6/site-packages/idna/core.py", line 284, in alabel
    check_label(label)
  File "/usr/local/lib/python3.6/site-packages/idna/core.py", line 261, in check_label
    raise InvalidCodepoint('Codepoint {0} at position {1} of {2} not allowed'.format(_unot(cp_value), pos+1, repr(label)))
idna.core.InvalidCodepoint: Codepoint U+201C at position 1 of '“amazon' not allowed

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/requests/models.py", line 398, in prepare_url
    host = self._get_idna_encoded_host(host)
  File "/usr/local/lib/python3.6/site-packages/requests/models.py", line 352, in _get_idna_encoded_host
    raise UnicodeError
UnicodeError

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 519, in request
    prep = self.prepare_request(req)
  File "/usr/local/lib/python3.6/site-packages/requests/sessions.py", line 462, in prepare_request
    hooks=merge_hooks(request.hooks, self.hooks),
  File "/usr/local/lib/python3.6/site-packages/requests/models.py", line 313, in prepare
    self.prepare_url(url, params)
  File "/usr/local/lib/python3.6/site-packages/requests/models.py", line 400, in prepare_url
    raise InvalidURL('URL has an invalid label.')
requests.exceptions.InvalidURL: URL has an invalid label.

Does anyone have any guidance about how to troubleshoot from here?

Thanks.

More-or-less a newby here guys so no judging.

Trying to get TTS to work and I have done everything I think I am supposed to:

  1. Copied the alexa.py file to my custom_components/media_player folder

  2. In my media_player !include folder I have created a file called alexa.yaml and entered the following:

    • platform: alexa
      email: my email
      password: mypassword
      url: amazon.com
  3. Rebooted and I went through the authentication with the Captcha and can see all of my media_player devices (media_player.bathroom_echo_dot)

When I call up the media_player.alexa_tts service and enter

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

I get nothing from the echo. No lights, no sound. Log shows nothing either, it is as if the service is not being called even though it pops up in the lower left corner that it has been called.

Have tried other media players with the same result. TTS does not work, I get no spoken output.

I am getting pretty frustrated because I feel there is probably one minor detail I am missing somewhere, but I cannot figure it out.

Any help?