Echo Devices (Alexa) as Media Player - Testers Needed

Restart mate. Or reboot.

Try the capture a few times, dosnt always work first time for me
But you have to do the capture every time you restart at the moment
And it needs to be done just after restart or it dosnt take effect

You can press “CONFIRM” for the first time. After that, it will show captca.

Too true. Very embarrassed when I figured out what it was…

Running latest HA (Ubuntu 16.04, python 3.6 running in a venv)

I only got my echos to show up once a few days ago, but I’ve only been playing with this for a few days.

after a restart or two, I am able to get the captcha to seem to be accepted, but no media players for my echos appear.

Here is my errors in the log

Traceback (most recent call last):
  File "/usr/lib/python3.6/concurrent/futures/thread.py", line 56, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/home/homeassistant/.homeassistant/custom_components/media_player/alexa.py", line 120, in <lambda>
    track_utc_time_change(hass, lambda now: update_devices(), second=30)
  File "/srv/homeassistant/lib/python3.6/site-packages/homeassistant/util/__init__.py", line 325, in wrapper
    result = method(*args, **kwargs)
  File "/srv/homeassistant/lib/python3.6/site-packages/homeassistant/util/__init__.py", line 325, in wrapper
    result = method(*args, **kwargs)
  File "/home/homeassistant/.homeassistant/custom_components/media_player/alexa.py", line 129, in update_devices
    devices = devices.json()['devices']
  File "/srv/homeassistant/lib/python3.6/site-packages/requests/models.py", line 896, in json
    return complexjson.loads(self.text, **kwargs)
  File "/usr/lib/python3.6/json/__init__.py", line 354, in loads
    return _default_decoder.decode(s)
  File "/usr/lib/python3.6/json/decoder.py", line 339, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/lib/python3.6/json/decoder.py", line 357, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 8 column 1 (char 7)

I appologize if I’m asking repeat questions that other may have asked, but most of the recent comments seem to be dealing with hass.io, and i know the process is not exactly the same.

Thanks!

im getting the same error on Hassos

still the same code, ill keep trying thanks for the tip!

Today I finally got that error you and others keep getting annoyed by … :slight_smile:

It seems that something “on the Amazon side of things” had happened overnight, around 2:30AM … and the dev-log was spammed with “the error”, every few minutes or so, until this morning when I saw it.
I fired up my “test automation”, which reports some values from temp. & climate sensors and my Echo just stood there, silent … :slight_smile:

AHA !, I finally got “the virus” everyone is talking about ! … you know , the one ending with

JSONDecodeError: Expecting value: line 8 column 1 (char 7)

So, as you well know, I went on to open https://www.amazon.com and proceed with some sign-out, sign-in sequences, followed by a HA restart. HA restarted, captcha appeared, got it from first try (that’s a win) and fired up the automation again … still no sound.
Oh crap … so that’s how @gregbert feels … ok, back to amazon.

By trial and error, this is what I did, then restarted and everything is working, again.

  1. Went to amazon site

  2. I was presented again, with this:
    image

  3. Pressed Continue button

  4. Like never before, the Chrome tab flashed a bit, like a blink, did not log in and in the upper corner was this:
    image

  5. And the login screen got a little “add-on” (marked here in red)

  6. Went on and added amazon domain to flash allowed, in chrome settings:

  7. Checked that keep me signed in check-box, and signed in again.

  8. Once signed in, I clicked the “switch accounts” link and signed out of there also, signed in again

  9. I know it’s alot but … Restarted HA, the captcha appeared by itself in the middle of the screen, picture and everything (that’s a first) … until now, I had to click the configure button, but not this one time … anyway, I got past the captcha, and ran the test automation.
    The Echo went live (came back to life) and Alexa’s voice filled the room once again … :slight_smile:
    How long until I get the error again ?, I don’t know, (I switched to HA 0.75 last night), I’ll keep you posted.

Have a nice weekend @gregbert.

2 Likes

Is this an automation or something else setup in your echo?

Hi, sorry for the miss understanding I might have caused. The Echo’es are always “live”.
But in that context, you guessed it, it went “live” (figure of speach), as an effect of an automation … which meant for me that HA and alexa_tts component somehow got together again.

This automation (which is triggered by an input_boolean):

- id: tts_over_alexa_devices
  alias: 'Send TTS message to Alexa device of your choice'
  
  trigger:
    - platform: state
      entity_id: input_boolean.test_button_1
      to: 'on'

  condition:
    - condition: and
      conditions:
      - condition: state
        entity_id: input_boolean.test_button_1
        state: 'on'

  action:

# = Echo device = BATMAN = Livingroom/Sufragerie

    - service: media_player.alexa_tts
      data_template:
        entity_id: media_player.batman

        message: “ Hello Michael !, this is your climate and weather report, The outside temperature is {{states ('sensor.dark_sky_apparent_temperature') }} degrees, the home climate system states the following values for Livingroom, {{states.climate.sufragerie.attributes.current_temperature}}, Bedroom, {{states.climate.dormitor.attributes.current_temperature}}, and Kitchen, {{states.climate.bucatarie.attributes.current_temperature}} ”

@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!