Echo Devices (Alexa) as Media Player - Testers Needed

Yes there is :slight_smile:
REQUIREMENTS = [‘xxxxx==x.x’]

Btw, getting same error using “amazon.com.au”

Traceback (most recent call last):
File “/usr/lib/python3.6/site-packages/requests/models.py”, line 346, in _get_idna_encoded_host
host = idna.encode(host, uts46=True).decode(‘utf-8’)
File “/usr/lib/python3.6/site-packages/idna/core.py”, line 361, in encode
s = alabel(label)
File “/usr/lib/python3.6/site-packages/idna/core.py”, line 284, in alabel
check_label(label)
File “/usr/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/lib/python3.6/site-packages/requests/models.py”, line 394, in prepare_url
host = self._get_idna_encoded_host(host)
File “/usr/lib/python3.6/site-packages/requests/models.py”, line 348, in _get_idna_encoded_host
raise UnicodeError
UnicodeError

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File “/usr/lib/python3.6/site-packages/homeassistant/helpers/entity_platform.py”, line 129, in _async_setup_platform
SLOW_SETUP_MAX_WAIT, loop=hass.loop)
File “/usr/lib/python3.6/asyncio/tasks.py”, line 358, in wait_for
return fut.result()
File “/usr/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 91, in setup_platform
login = AlexaLogin(url, email, password)
File “/config/custom_components/media_player/alexa.py”, line 474, in init
self.login()
File “/config/custom_components/media_player/alexa.py”, line 511, in login
resp = self._session.get(site)
File “/usr/lib/python3.6/site-packages/requests/sessions.py”, line 525, in get
return self.request(‘GET’, url, **kwargs)
File “/usr/lib/python3.6/site-packages/requests/sessions.py”, line 498, in request
prep = self.prepare_request(req)
File “/usr/lib/python3.6/site-packages/requests/sessions.py”, line 441, in prepare_request
hooks=merge_hooks(request.hooks, self.hooks),
File “/usr/lib/python3.6/site-packages/requests/models.py”, line 309, in prepare
self.prepare_url(url, params)
File “/usr/lib/python3.6/site-packages/requests/models.py”, line 396, in prepare_url
raise InvalidURL(‘URL has an invalid label.’)
requests.exceptions.InvalidURL: URL has an invalid label.

Just read 5 posts up mate.

@keatontaylor Im getting the same error now as others.

Tue Jul 17 2018 21:49:49 GMT-0400 (Eastern Daylight Time)

Error while setting up platform alexa
Traceback (most recent call last):
File "/usr/local/lib/python3.6/site-packages/requests/models.py", line 346, 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 394, in prepare_url
host = self._get_idna_encoded_host(host)
File "/usr/local/lib/python3.6/site-packages/requests/models.py", line 348, 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 129, 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 91, in setup_platform
login = AlexaLogin(url, email, password)
File "/config/custom_components/media_player/alexa.py", line 474, in __init__
self.login()
File "/config/custom_components/media_player/alexa.py", line 511, in login
resp = self._session.get(site)
File "/usr/local/lib/python3.6/site-packages/requests/sessions.py", line 525, in get
return self.request('GET', url, **kwargs)
File "/usr/local/lib/python3.6/site-packages/requests/sessions.py", line 498, in request
prep = self.prepare_request(req)
File "/usr/local/lib/python3.6/site-packages/requests/sessions.py", line 441, in prepare_request
hooks=merge_hooks(request.hooks, self.hooks),
File "/usr/local/lib/python3.6/site-packages/requests/models.py", line 309, in prepare
self.prepare_url(url, params)
File "/usr/local/lib/python3.6/site-packages/requests/models.py", line 396, in prepare_url
raise InvalidURL('URL has an invalid label.')
requests.exceptions.InvalidURL: URL has an invalid label. 

I have installed bs4 with the command and it was successful

pip3 install bs4

Running on Home Assistant 0.73.2 via Hass.io with the old addon uninstalled

No clue what to do at this point, I have been having issues with the addon and now the script.

OK I have figured out the encoding issue, It is the quotes in the instructions.

Change:

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

to:

media_player:
  - platform: alexa
    email: your amazon email
    password: your amazon password
    url: amazon.com

After you do that the addon will initialize and you will get the configure button on your Overview

Issue now is after entering captcha, The lightbox that shows up to input captcha goes blank after submit, and doesn’t seen to configure anything.

2 Likes

Same happened here. After a few tries it worked.

I still have this issue on Hassbian after installing BS4 using all methods I posted earlier. Any ideas?

Are you running Hassio? Did you just go into putty, when I try I get command not found error

I will try again tonight. Thank you so much.

For those getting the URL errors try removing the double quotes in the yaml config

url: amazon.com

Instead of:

url: "amazon.com"

How do I install beautiful soap on HASSIO? @keatontaylor

@Chewee

New version of the custom component adds requirements that will auto-install beautiful soup.

Please ensure that 0.6.1 is what is downloaded from my GitHub page.

[https://github.com/keatontaylor/custom_components/blob/master/media_player/alexa.py]

@keatontaylor just tried 0.6.1 on Hassbian, same error as earlier. Missing dependencies.

Error loading custom_components.media_player.alexa. Make sure all dependencies are installed
Traceback (most recent call last):
  File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/loader.py", line 86, in get_component
    module = importlib.import_module(path)
  File "/usr/lib/python3.5/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 986, in _gcd_import
  File "<frozen importlib._bootstrap>", line 969, in _find_and_load
  File "<frozen importlib._bootstrap>", line 958, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 673, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 673, in exec_module
  File "<frozen importlib._bootstrap>", line 222, in _call_with_frames_removed
  File "/home/homeassistant/.homeassistant/custom_components/media_player/alexa.py", line 14, in <module>
    from bs4 import BeautifulSoup
ImportError: No module named 'bs4'

I still get the same error too, even with 0.6.1

@Chewee yes Im running hassio. With hassio you have to connect to the container via ssh with the addon not not the host.

I have my host set at port 22 and port 23 set up for the home assistant container.

Use the community SSH addon or a terminal addon in the Hass,io menu

@keatontaylor the captcha image isnt even loading anymore. its just showing the broken image graphic instead of the actual captcha. Inspecting the source of the website shows its trying to pull the image from amazon but not successfully. maybe a caching problem

Ok so It logged in finally. I deleted the pycache directory that the script created in the custom components folder and restarted home assistant. Brought up captcha the first click and logged in successfully the first confirmation.

Something tells me we may see some issues arise from whatever was causing my issue

@J.eremy, my guess would be the pycache was caching something from the old alexa.py pre removal of the add-on

@keatontaylor I dunno, I deleted it between .5 and .6, then I just deleted it again between .6 and .6.1 then it worked.

weird

1 Like

I tried to uninstall the Add-on but it does not get removed? I want to try the alexa.py only approach.

Any advise on how the add-on getting removed ?

2 Likes

Same issue as @xx_Nexus_xx . Unable to remove add-on