Echo Devices (Alexa) as Media Player - Testers Needed

Hey. Thanks for responding. I am using Notepad++ for my config :slight_smile:
I don’t get an config error when I do the config check. I just get the spinner forever. If I try to restart anyway HASSIO doesn’t let me. :confused:

EDIT: got it. I downloaded the wrong thing when I was trying to get the Alexa.py file. Oops!

Awesome, glad to hear that.

EDIT: I fixed it by removing the quotes around amazon.co.uk in the config file! :smile:
Thanks @keatontaylor! This is a great piece of work!

Original comment follows:

So, with the right Alexa.py file, I passed the config check and restarted ok-ish. But the Alexa component is not working. I get a lot of errors in my log. I really don’t understand how to parse this :frowning:
Any help much appreciated. I would love to get this component working!

2018-12-28 00:33:47 WARNING (MainThread) [homeassistant.loader] You are using a custom component for media_player.alexa which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you do experience issues with Home Assistant.
2018-12-28 00:33:49 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 146, in setup_platform
config.get(CONF_DEBUG))
File “/config/custom_components/media_player/alexa.py”, line 618, in init
self.login_with_cookie()
File “/config/custom_components/media_player/alexa.py”, line 641, in login_with_cookie
self.login(cookies=cookies)
File “/config/custom_components/media_player/alexa.py”, line 757, 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.

Hey How did you solve this with spotify ?

sorry, having real problems here. I have added the alexa.py file in config/custom_components/media player

i have added the following to the configuration.yaml file:

      - platform: alexa
        email: !secret alexa_email
        password: !secret alexa_password
        url: amazon.co.uk

when i “Check Config” i get the following:
Platform not found: media_player.alexa

I am sure I am doing something stupid, but I can’t see what!!

You are missing the
host: 192.xxxxx
line

sorry IK0ADR i must be missing somthing

i could not see that line in the instructions, which host? server? each dot?

sorry.

Yes, in my configuration (two dots) each one as his IP under host:

  - platform: alexa
    host: IP1
    email: _email
    password: _password
    url: _url        

  - platform: alexa
    host: IP2
    email: _email
    password: _password
    url: _url

at least here works!

no sadly not, same error:
Unable to find component media_player.alexa

are you under hass.io or hassbian?

After you added the alexa.py file did you restart home assistant before you added the config code?

IK0ADR neither - HA installed on an old laptop running pi OS - everything else runs fine
and
finity yes - and have restarted a number of times since - even tried rebooting the ‘PI’ also

Maybe the directory tree is the problem.
Under Hassbian, the alexa.py file is in the custom_components/media_player/ directory.
the custom_component dìrectory is where the configuration,yaml file is.

yes, that’s exactly where mine is saved and it has picked up the other custom components that I have in the custom_components directory.

Where do you see that you need to add a “host:”? Especially that you would need to add a different configuration for each dot?

In my configuration I don’t have any “host:” configured and mine works fine.

this is my configuration.yaml looks like and it works

media_player:
  - platform: alexa
    email: !secret Echo_email
    password: !secret Echo_password
    url: amazon.com

try adding media_player:

sorry all, i am an idiot

config /custom_components/media player

is different to

config /custom_components/media_player

that underscore made all the difference.

1 Like

Hi All

Love the idea of alexa media players

I have the .alexa p.y installed and have got my config up and going

Only problem is in the states they all show as unavailable

media_player.conservatory unavailable friendly_name: Conservatory supported_features: 23357
media_player.everywhere unavailable friendly_name: Everywhere supported_features: 23357
media_player.front_room unavailable friendly_name: Front Room supported_features: 23357
media_player.master_bedroom unavailable friendly_name: Master Bedroom supported_features: 23357
media_player.pauls_alexa_apps unavailable friendly_name: Paul’s Alexa Apps supported_features: 23357
media_player.pauls_fire_tv_stick standby is_volume_muted: false media_content_type: standby source: Local Speaker source_list: Local Speaker available: true friendly_name: Paul’s Fire TV stick supported_features: 23357
media_player.sony_bravia_tv off friendly_name: Front Room TV (Sony) supported_features: 19901
media_player.this_device standby is_volume_muted: false media_content_type: standby source: Local Speaker source_list: Local Speaker available: true friendly_name: This Device supported_features: 23357

My Config is as below

  • platform: alexa
    host: 192.168.0.4
    email: secret
    password: secret
    • platform: alexa
      host: 192.168.0.12
      email: secret
      password: secret
      url: amazon.com
    • platform: alexa
      host: 192.168.0.14
      email: secret
      password: secret
      url: amazon.com
    • platform: alexa
      host: 192.168.0.17
      email: secret
      password:secret
      url: amazon.com

ps. I have just changed my login and password to secret on here as I have nit set them up in the secrets file yet

what am I doing wrong anyone assist

The firs tv stick and this device are showing on standby

Paul

p.s the config is correct in the config file, and I only had two captcha requests for all the devices shown

First off… code formatting…

Next, Where is the requirement for using a “host:” in the config? Is this something new that I missed somewhere? Mine works fine without it and I have 5 echo’s that show up with only one config entry:

media_player:
  - platform: alexa
    email: !secret amazon_email
    password: !secret amazon_pass
    url: amazon.com

Thanks for the reply

Looks like your post was just a do it like this and not constructive
Being new to this we all have to find out stuff .

Glad you have it working. Others like myself don’t as you can see fron the states I have a couple that show as being unavailable

The guy that wrote this deserves a medal for his work

All I want to do is get mine working not be told off in condescending manners