Echo Devices (Alexa) as Media Player - Testers Needed

@keatontaylor @davidlamd89 @goliath_2k @xx_Nexus_xx @planet4

Still having issues uninstalling the addon v. 0.5? Try this:

Hey y’all - if you’re still having problems removing the addon, here are the steps that worked for me. Note that the addon still shows somehow in the hassio panel (twice, actually), but these are safe to ignore. The custom_component by @keatontaylor now works just find and dandy. Thanks again to @keatontaylor for this!

First, enable debugging access to ResinOS. Instructions from the docs are here, but the steps are this:

  1. Generate an authorized key on the device you’d like to use to access ResinOS (see this). I’m doing this on my mac laptop.
  2. Important: On your computer, rename the id_rsa.pub file to authorized_keys without any extension. Usually this means that you’ll have to use your terminal. On mac, it’d be: mv .ssh/id_rsa.pub authorized_keys
  3. Take your hassio SD card. Put it in your computer. Move the authorized_keys file to the main directory of the SD card…
  4. Eject that SD card from your computer.
  5. Put that SD card back in the hassio machine
  6. ssh root@IPADDRESS -p 22222
  7. Change directory to /
  8. Now list files ls and you’ll see the resin-data directory.
  9. Change into the directory: cd resin-data
  10. Now we want to edit the addons.json. But first! Stop ha. Open another terminal window, and ssh into the docker machine: ssh root@IPADDRESS and enter the command: hassio ha stop
  11. Back to the editing terminal window, we’re in a basic shell so we have to use vi. Edit addons.json with vi by vi addons.json
  12. Scroll down, you’ll see where the alexa addon is described. Delete the entire entry line-by-line by pressing dd for each line. Make sure to retain JSON formatting for the stuffs you aren’t deleting.
  13. Keep scrolling down, there’s another section. Do the same thing.
  14. Exit vi by hitting ESC then : then wq then hit ENTER

Ok. We’re probably good now, but I went a bit further. There’s a few directories and files to clear out too.

  1. Change directory to addons by typing cd addons
  2. After listing directorys via ls you’ll see four directories: core, data, git, and local
  3. Go into each of these directories and see what remains from alexa. Delete 'em via rm -r FILE_OR_DIRECTORY

Bam. Now restart ha and move on with the life.

This worked for me. I hope this helps someone. Not sure why the addon still shows in HA, but whatever. I don’t much care. I’ve got alexa_tts and media control again thanks to @keatontaylor.

:+1:

Spot on BRO!!! Thanks so much!

I did put this into my browser: chrome://settings/content
And it brought up the flash settings, I added www.amazon.com to the allow list and restarted my HA, Thats when the magic happened and I heard her wonderful voice!

Thanks for sharing your workaround!

I’m happy to see you managed to get it working again too.
This is a beautiful component and its full potential is yet to come.
Glad I could help. Have a nice weekend @Corey_Maxim:slight_smile:

1 Like

You Too! I absolutely love this!!!

Can services be mixed?

I have a custom greeting, that I was wondering if it would work? Or if these a better way to format it.

script.yaml

say_greeting:
  sequence:
    service:
      - media_player.alexa_tts
      - tts.google_say
    data_template:
      entity_id: "{{ entity_id }}"
      message: "{{ message.replace('PERSON',person) }}"

automation.yaml

- id: family_greeting
  alias: Family Greeting
  trigger:
    platform: state
    entity_id:
      - binary_sensor.cameron_home
      - binary_sensor.corey_home
      - binary_sensor.courtney_home
      - binary_sensor.mom_home
      - binary_sensor.morgan_home
      - binary_sensor.wendy_home
      - binary_sensor.andy_home
      - binary_sensor.jasmine_home
      - binary_sensor.brandon_home
    from: 'off'
    to: 'on'
    for: '00:00:05'
  action:
    - wait_template: "{{ is_state('script.say_greeting', 'off') }}"
    - service: script.say_greeting
      data_template:
        entity_id:
          - "media_player.livingroom,media_player.bedroom,media_player.courtneys_room"
          - media_player.fire_speaker
        person: >
          {{ trigger.to_state.name }}
          {%- for s in states.binary_sensor
                |rejectattr('entity_id','eq',trigger.entity_id)
                |selectattr('state','eq','on')
                if '_home' in s.entity_id and
                   (now() - s.last_changed).total_seconds() < 60 -%}
            {{ (' and ' if loop.last else ', ') ~ s.name }}
          {%- endfor %}
        message: >
          {{ ["Welcome back home PERSON",
              "Guess who is home PERSON is!",
              "PERSON is now in the house.",
              "Welcome Home PERSON  We have missed you Or at least I did.",
              "Attention Everybody PERSON is home I repeat PERSON is home Welcome home PERSON",
              "Our home is now complete, Rest your head and relax your feet, Welcome Back PERSON",
              "Life is like a song, you’re back where you belong, Welcome home PERSON",
              "Hey there PERSON Welcome Home!",
              "Knock Knock. Who is There? PERSON is!",
              "PERSON, you are home!",
              "I know a secret. PERSON is home!",
              "PERSON it's nice to see you again. Right where you belong. Welcome home PERSON",
              "O M G it's PERSON. Oh how I missed your face. Welcome home",
              "Welcome back to the best house in th 3 3 0 PERSON",
              "Oh Goodie PERSON is home. Welcome back",
              "When PERSON is here we are complete. Its nice to see you PERSON"
              "Its not the same when PERSON isn't here, so from the MAXIM's welcome home"
             ] | random }}
1 Like

I’ve updated the PR that is pending to fix the JSON Decode bug.

It adds:

  1. Cookie support; should only get captcha once if you successfully log in.
  2. Updated messaging in the configurator to help address missing images.
  3. More verbose debug logs to hopefully help external debugging.
1 Like

@alandtse thanks for the PR. I submitted some comments.

Wow looks awesome,thanks for your hard work! One question, i am running hassio on a ubuntu server 18.4 VM on windows 10. Will it work, should i do anything different? Thanks for the help.

Installed this a few weeks ago and now I cannot uninstall “Alexa Media Player API” . Anyone have any idea how I can clean this up?

Scroll up a few posts. I’ve provided instructions for uninstalling the addon

Could you maybe walk a noob through how and where to enter this and set it up. I have everything else working but cant wrap my head around the tts part and that is what i want the most.
I am running hassio on a ubuntu server 18.4 vm under windows 10 home. Thanks for your help if you can find the time!

Tried to use this for my Hassio install and didn’t work. Anyone able to strip this out of a docker Hassio install>?

For everyone who is having trouble with the CAPTCHA when you reboot, here is what I’ve done that seems to work for me so far. Before I reboot, I delete the ----cache---- folder located the following path: .../custom_components/media_player
During the restart it will recreate the cache folder (and sometime I delete it again just for good measure, not sure it is necessary)

I’m running the latest HASSIO 0.74.2 and Alexa.py version 0.7.1. If you are not getting the CAPTCHA in the first place you may want to delete the cache, refresh your browser and reboot.

Happy automating.

updated my hass.io to 75.1 and now after i put the captcha in it says Error doing job: Future exception was never retrieved in my hass.io error log, and ive tried to restart and reset the raspberry pi but does the same every time.

@Smartmedia

(and for others, this is related to the JSON error many people are getting)

I did this, but i wasnt getting that flash error. However, all that said, it NOW WORKS
i was looking at your screenshot - where it has a button that says to send a code to login… then it hit me… 2-factor authentication. i disabled mine… and then did the elaborate login/logout/etc… and bam… .all works
also, its worth saying that I am NOT doing this from the computer where home assistant is installed. HA (not hass.io) is on an docker hosted on an archlinux system (in my house, but separate).

For everyone else, the JSON error (simplejson.errors.JSONDecodeError: Expecting value: line 8 column 1 (char 7)) effectively means that it FAILED to LOGIN.

I noticed that when I was success, i got another dialog box on my home assisstant front-end after the captcha… it had nothing in it - i had to X out. I believe we need a better ‘success’ message than this, and also better checking that we had a successful login… all it does now is see if the word ‘devices’ is included in the web page response!!! thats the real error here. should i code the correction? i learned python for this so i might as well use it!

now to see if i can re-enable 2-factor authentication…
ANSWER: No… Turning that back on breaks it directly.

Log Details (ERROR)
Sun Aug 05 2018 22:03:50 GMT+0100 (British Summer Time)

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 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 144, in update_devices
update_devices, url)
File “/config/custom_components/media_player/alexa.py”, line 209, in init
self.refresh(device)
File “/config/custom_components/media_player/alexa.py”, line 253, in refresh
self._media_image_url = self._session[‘mainArt’][‘url’]
KeyError: ‘url’

thats from my logs, cant get alexa to work again even after downgrading to 74.1 its now screwed :confused:

im having the same issue too, the echo lights up but no sound is heard.

This is fixed in the next version coming out. You’ve successfully logged in, but for some reason your Alexa device isn’t providing a URL for the artwork. If you need the fix early, see my earlier posts.

New Version 0.8.0

Big thanks to @alandtse who single handedly worked on getting changes in place to solve a lot of the lingering issues with login. Please report your findings and let us know if it is working better for you.

Note: Please ensure when downloaded you are grabbing: ‘VERSION: 0.8.0’

Other improvements:

  1. Session cookies stored in config, no longer required to type captcha in after HA reboot
  2. Linting fixed 100% for eventually submitting to home assistant
  3. Additional logging and catching of errors
  4. Captcha configurator now shows proper error messages.

Thanks again @alandtse for the changes! If you see anything else you want to add here that I overlooked let me know!

Just installed this (v 0.8.0 and am stuck in a constant captcha loop. My config is:

  - platform: alexa
    email: [email protected]
    password: password
    url: amazon.com

I don’t know if it makes a difference that I’m in Australia but my account is US. I just get a constant captcha loop, telling me it can’t login, even though I’m sure I’m doing the captcha right.

Thanks!