Echo Devices (Alexa) as Media Player - Testers Needed

Is the component meant to enter the captcha after every reboot?

YES, for now, without a doubt.
From my understanding, for the component to work it has to have access to your account on which the devices a registered to. For that, the component needs to login to your amazon account, in your place, using your credentials you specified in your config. But as soon as Home Assistant is given the restart command, that “link” needs to be closed, because otherwise it means that you will remain logged in, until kicked out by amazon’s servers or some form of timeout (like when you close the amazon tab in Chrome, without logging out … “someone” will log you out eventually). When Home Assistant restarts, that “link” needs to be made again, so another login sequence must begin, hence … the capcha. … I hope I’m at least 50% right … :slight_smile:

when using the hassio plug in I didn’t manually need to enter the captcha. Guess its a learning process now.

The captcha will absolutely expire if not entered quickly after HA boot. I do plan on fixing this where the session is saved to disk so that you only have to enter the captcha when the session times out or when the cookies file is deleted.

The reason the captcha currently asks on boot each time isn’t because of some amazon limitation, but because I have not implemented saving it yet.

For those experiencing issues with 0.7.1 not working but 0.7 working, it might be due to the fact that my code checking if a login was successful isn’t properly wrapped in a try/catch statement. I’ll try and fix that soon.

Right now I am busy finishing my last two summer classes to complete my Bachelors degree, so I might be MIA for a week or so.

4 Likes

Thank you, good luck, and take your time!! :slight_smile:

Great job on the component. Is there a file in the config folder we can delete so the component works again? I enter the captcha and the media players do not show up. I want to bring it to default and try again.

please disregard I have gotten it to work.

@keatontaylor - do you have an expected ETA for this dummy update, enabling us to uninstall the add-on and using your latest PY version instead ?

3 Likes

I added some debugging to see why the request response cant be converted to json and printed the response to the log. So its true, the result of this get device list request is not a json, but a normal HTML site, containing again the login informations

<title dir="ltr">Amazon Anmelden</title>

So this error is only a follow up error of a missed login.

I am also wondering, why I am getting a captcha at all using the component.
If I login by browser, I dont get a captcha and after login, I also get the list of devices as json.
So probably the captcha handling is also a problem, for those without 2fa enabled.

The only version which is working right now, is the one based on the add-on.

Regards

I wonder if you had the same issue i have !?.

Like everyone i followed instructions, & i didn’t see any media players.
Could you explain a little bit more?

I haven’t had any luck with the captcha route, (no media_players discovered).

In config I tried using quotes, no quotes, restarting devices, different domains but no luck.

Been a week with no action whereas I was able to use it successfully a few versions back where you login through the addon. Would you recommend I downgrade to when it was working?

I am in the same boat with you no luck with captcha if I manage to catch in time before it times out but no media players are ever added.

Enter any string and, if it is incorrect, you will get another captcha.

Same with me. How to fix it?

1 Like

I do that and the capture never pops up again

This is great! I have been trying to find a way to get Alexa to speak without being spoken to.

I have to admit that I haven’t read all 375 posts yet, so I may be duplicating the information, but here is what I needed to do to get the prerequisites installed on Raspbian:

apt-get install python3-bs4
sudo -u homeassistant -H -s
source /srv/homeassistant/bin/activate
pip3 install beautifulsoup4
pip3 install lxml

(I did my Home Assistant install following https://www.home-assistant.io/docs/installation/raspberry-pi/)

Great work on this component. I am also running into a couple issues. I am running hassio 0.74.1 and 0.7.1 of your code, and am based in the US. I have no quotes around my login or url. I am able to preform the captcha but… no media player appears, even in services. Checking the logs this is the error I have.

2018-07-24 22:35:58 ERROR (MainThread) [homeassistant.core] Error doing job: Future exception was never retrieved
Traceback (most recent call last):
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 173, in setup_alexa
update_devices()
File “/usr/local/lib/python3.6/site-packages/homeassistant/util/init.py”, line 318, in wrapper
result = method(*args, **kwargs)
File “/usr/local/lib/python3.6/site-packages/homeassistant/util/init.py”, line 318, in wrapper
result = method(*args, **kwargs)
File “/config/custom_components/media_player/alexa.py”, line 129, in update_devices
devices = devices.json()[‘devices’]
File “/usr/local/lib/python3.6/site-packages/requests/models.py”, line 896, in json
return complexjson.loads(self.text, **kwargs)
File “/usr/local/lib/python3.6/site-packages/simplejson/init.py”, line 518, in loads
return _default_decoder.decode(s)
File “/usr/local/lib/python3.6/site-packages/simplejson/decoder.py”, line 370, in decode
obj, end = self.raw_decode(s)
File “/usr/local/lib/python3.6/site-packages/simplejson/decoder.py”, line 400, in raw_decode
return self.scan_once(s, idx=_w(s, idx).end())
simplejson.errors.JSONDecodeError: Expecting value: line 8 column 1 (char 7)

Keep up the great work and good luck in your last three classes.

Not working with domain CO.JP. :frowning: no capcha screen showed.
I removed py cache…

Just updated to 7.1, I get a Captcha. After I solve it, I get this error:

    Error doing job: Future exception was never retrieved

Traceback (most recent call last):
  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 173, in setup_alexa
    update_devices()
  File "/usr/local/lib/python3.6/site-packages/homeassistant/util/__init__.py", line 318, in wrapper
    result = method(*args, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/homeassistant/util/__init__.py", line 318, in wrapper
    result = method(*args, **kwargs)
  File "/config/custom_components/media_player/alexa.py", line 129, in update_devices
    devices = devices.json()['devices']
  File "/usr/local/lib/python3.6/site-packages/requests/models.py", line 896, in json
    return complexjson.loads(self.text, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/simplejson/__init__.py", line 518, in loads
    return _default_decoder.decode(s)
  File "/usr/local/lib/python3.6/site-packages/simplejson/decoder.py", line 370, in decode
    obj, end = self.raw_decode(s)
  File "/usr/local/lib/python3.6/site-packages/simplejson/decoder.py", line 400, in raw_decode
    return self.scan_once(s, idx=_w(s, idx).end())
simplejson.errors.JSONDecodeError: Expecting value: line 8 column 1 (char 7)

Thats the error we all get… no solution so far.