Echo Devices (Alexa) as Media Player - Testers Needed

Something else I noticed is that when the pycache directory gets created it is created by root. I’m not sure why that is.

My HA and docker user are both finity and the alexa.py file is owned by finity.

Could a permissions issue be causing the login failure problem I’m having? and why is the pycache folder created and owned by root?

I am as well.

You can ignore it. It should stop appearing in the next version. A check for file existence was removed so it’s always assuming the file was there even if it wasn’t.

So that error would be unrelated to why it isn’t working for me? I put in the captcha and then the configurator disappears, but it doesn’t seem to work as no new media player entities appear. Any ideas?

at least your configurator is disappearing.

i just get endless login failures and the configurator just stays put.

Hello ptdalen,

Here is the full script that I used for my audio announcement. I wish that I could use group however, I tested it at least once and it did not work, perhaps I’ll try it again. However, here is my full audio_notify script:

audio_notify:
  alias: My TTS
  sequence: 
    - service: media_player.alexa_tts
      data_template:       
        entity_id: >
          {% if (mplayer == "all") %}
            media_player.bedroom,media_player.bathroom,media_player.office,media_player.kitchen,media_player.family_room,media_player.fire_tv
          {% elif (mplayer == "downstairs_media_players") %}
            media_player.kitchen,media_player.family_room,media_player.fire_tv
          {% else %}
            media_player.{{ mplayer }}
          {% endif %} 
        message: "{{ tts_msg }}" 
6 Likes

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 174, in setup_alexa
update_devices()
File “/usr/local/lib/python3.6/site-packages/homeassistant/util/init.py”, line 325, in wrapper
result = method(*args, **kwargs)
File “/usr/local/lib/python3.6/site-packages/homeassistant/util/init.py”, line 325, in wrapper
result = method(*args, **kwargs)
File “/config/custom_components/media_player/alexa.py”, line 130, 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)

this component hates me sadly

I spoke too soon, now I’m getting the exact same issue as you finity where I’m in an endless captcha loop with login failure…

Edit: Can you try updating please? You’re on 0.7.1 before we (hopefully) resolved this bug.

Are you able to log in for a short period? The debug error you are getting should only happen if you’ve managed to log in once. We don’t have any logic for the update_devices yet to try to relogin, but it’s in the queue.

@finity:
@keatontaylor merged in my changes for version 0.9.0. It should have more debugging that can be enabled in the logger to explain what it thinks is failing.

If you are comfortable editing python directly, there are some commented out debugging statements that could be helpful in figuring out exactly where things break. I don’t keep them on for general builds because it’d populate sensitive things into the logs like your password, etc. For example:

  • Lines 698-699 writes the file alexa_mediapost.html to your config directory that shows what happens after you submit any data to Amazon. If you load it in the browser, you can see what Amazon is asking you for directly. (It won’t actually let you login through that webpage as it’s considered a separate browser login)
  • Line 693 will print all the values submitted to Amazon. This can show the username and password to make sure it’s not getting changed (@finity:I can confirm it’s not the # character as long as it’s not the first character in the string. If it is, use quotes in your secrets.yaml file).

I just updated to the latest version and it worked flawlessly with 2FA.
This is amazing!
Thank you!!

I installed the update, uncommented the lines (they were around 676-677 in my file) and opened the resulting alexa_mediapost.html file in my browser.

the result was just another amazon login page. It already had my email address populated so I filled in my password and the captcha info and it went straight to the amazon.com site without any issue. I’m not sure what is necessary from there.

But the component still isn’t working. It’s still saying login failure in HA

Just for S&G I even tried to change the owner of the pycache directory and the file it contains to my HA user and it still failed.

EDIT:

I just opened the html page again and i noticed at the top that it’s asking me to re-enter my login details. Is that the problem?

ex

and I don’t know if it means anything but I notice a second configurator line pop up for just a second right after I enter the captcha in HA. Then it immediately goes away.

Could that second one be the result of it asking to re-enter my credentials? But, if so, then it doesn’t stay on the screen for me long enough for me to click on it to re-enter anything.

Yes, it was working perfectly before, until a restart.

After any restart I have to enter the captcha again every time. But this time after multiple tries I’m still getting the same errors.
Also I only have one chance to enter the captcha then the box goes away until I restart again.
Smartmedia said they have no issues but I’m not sure what platform they are using. I’m using HassOs/Hassio if that helps. I absolutely appreciate all the hard work from everybody and love this. I will do whatever I can to help out.

When I try to use the dialog box in home assistant to do text to speak, it says that is calls “google_say”

How do i get it to call the alexa tts instead?
i do have a tts: line in my configuration yaml that specifies to use google. is that it? what should read?

That does not work with this yet (AFAIK). You need to use a script/automation. or json with the services section on the UI

I’m new to this awesome component, just installed 0.9.0. After entering the captcha everything looks ok, but when firing a service call, Alexa remains silent…

media_player:
  - platform: alexa
    email: "[email protected]"
    password: "**"
    url: "amazon.co.uk"

I made some changes to the script to intercept the send_tts post response, Amazon responded with:

Statuscode: 200
Headers: {‘Server’: ‘Server’, ‘Date’: ‘Fri, 10 Aug 2018 14:24:38 GMT’, ‘Transfer-Encoding’: ‘chunked’, ‘Connection’: ‘keep-alive’, ‘Vary’: ‘Content-Type,Accept-Encoding,User-Agent’}
Body:
HTTP/1.1 0 x-amzn-RequestId: 1d409d60-9ca9-11e8-a454-6d96b0a5a825
Date: Fri, 10 Aug 2018 14:24:38 GMT
Connection: close

Everything looks ok to me…?

Thanks @ptdalen. Yes, the scripts i wrote are working fine, which is the main part.

Is there a way to choose the speech rate of Alexa. TTS she seems to race through voice scripts to a point it’s not very natural sounding.

weird, for me she speaks at the normal rate of speech as if I had asked her a question.

I’m using node-red to fire off the automations I will try just with normal yaml and see if there is a difference.