Echo Devices (Alexa) as Media Player - Testers Needed

Alexa Guard now available in the United States – Would be curious if anyone finds the sequence cmds to turn this on automatically.

6 Likes

Would be great to to be able to toggle home / away mode through this addon since home assistant already knows if i’m home or away.

2 Likes

I think until Amazon allows Alexa Guard to be activated via a routine, I’ll use a Google Home Mini to say, “Alexa, I’m Leaving” to one of our more out of the way Dots such as the one in the laundry room or the garage. Anyone have a more elegant solution?

2 Likes

Was able to do it via IOBroker ( and nodered to filter things out !) best decision ever!!!

Hi everone,
first thank you for your great job, this forum / community is awesome.

I installed the alexa custom component from GitHub - keatontaylor/alexa_media_player: This is a custom component to allow control of Amazon Alexa devices in Home Assistant using the unofficial Alexa API., added lines in configuration.yaml, successfully completed captcha and double authentication process.
I can see my 2 Alexa devices in HA states, but both are “unavailable” with the following errors in the log:

Update for media_player.this_device fails.
Traceback (most recent call last):
File “/srv/homeassistant/lib/python3.5/site-packages/homeassistant/helpers/entity.py”, line 220, in async_update_ha_state
await self.async_device_update()
File “/srv/homeassistant/lib/python3.5/site-packages/homeassistant/helpers/entity.py”, line 377, in async_device_update
await self.hass.async_add_executor_job(self.update)
File “/usr/lib/python3.5/asyncio/futures.py”, line 380, in iter
yield self # This tells Task to wait for completion.
File “/usr/lib/python3.5/asyncio/tasks.py”, line 304, in _wakeup
future.result()
File “/usr/lib/python3.5/asyncio/futures.py”, line 293, in result
raise self._exception
File “/usr/lib/python3.5/concurrent/futures/thread.py”, line 55, in run
result = self.fn(*self.args, **self.kwargs)
File “/home/homeassistant/.homeassistant/custom_components/alexa_media/media_player.py”, line 447, in update
no_throttle=True)
File “/srv/homeassistant/lib/python3.5/site-packages/homeassistant/util/init.py”, line 224, in wrapper
result = method(*args, **kwargs)
File “/srv/homeassistant/lib/python3.5/site-packages/homeassistant/util/init.py”, line 224, in wrapper
result = method(*args, **kwargs)
File “/home/homeassistant/.homeassistant/custom_components/alexa_media/media_player.py”, line 275, in refresh
self._last_called = self._get_last_called()
File “/home/homeassistant/.homeassistant/custom_components/alexa_media/media_player.py”, line 376, in _get_last_called
[‘serialNumber’]))
TypeError: ‘NoneType’ object is not subscriptable.

Any help would be nice, thank you again.
SoL

I edit myself and hope this could help others.

I solved all errors by changing the ‘url’ of amazon. I inserted the correct one in the first attempt but captcha authentication didnt work, I switched to amazon.com and double authentication worked but with those errors listed. I went back to my correct amazon url and now everything is fine.
It looks like it requires a ‘first authentication’ in amazon.com, then a switch to your amazon.xx server.

Hope it helps,
SoL

Updated to 0.93 service “notify.alexa_media” stop working.
No error in a log.
Downgrade back to 0.92.2 working with no problems.

Maybe give it another try…I just tried notify.alexa_media in 0.93.0 and it worked

Hi, i wanted to check if there is a way to use the nice traffic images (fastest route) that are shown in the alexa app. Maybe adding them on the homescreen as an image or to push them on the phone.

The URL changes with every new request but looks like this (in DE):
https://layla.amazon.de/api/traffic/commute/"UNIQUEID"/fastest_route_image?height=600;width=600

Not sure if I am missing something, but if I play music on my echos from Spotify, track info etc shows up in the media card in HA. If I listen to any radio it stays showing “standby”
Any ideas ?

Updated to 93.1 today and this has started to work !

Hello all. I’ve searching for the better part of 3 days trying to figure out what I am doing wrong but haven’t figured it out yet. Short version, notify.alexa_media service doesn’t load/exist.

Hass.io: v0.93.1
Alexa Media Player v1.2.5

I followed all the instructions on the wiki. Created the directory under config, put the alexa_media where it is supposed to. Updated my configuration.yaml. Now in HA log I do see this but I have no clue whats causing it but I do believe this is why the service isn’t loading. Should also note I am not even getting a captcha and tbh I am not certain where I’d even be shown that? I have a test script I can run and a node-red automation I can run but neither have presented me with anything.

Alexa Setup

alexa_media:
accounts:
- email: !secret amazon_user
password: !secret amazon_pass
url: amazon.com
debug: true

notify:

  • platform: alexa_media
    name: alexa_media

2019-05-17 18:50:10 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
File “/usr/local/lib/python3.7/site-packages/homeassistant/components/notify/init.py”, line 114, in async_setup_platform
if hasattr(notify_service, ‘targets’):
File “/config/custom_components/alexa_media/notify.py”, line 102, in targets
[‘devices’][‘media_player’].items()):
KeyError: ‘devices’

Any help would be greatly appreciated at this point.

For anyone who came across my issue, the problem was I hadn’t completed the captcha. I never noticed the “Notification” on my dashboard to do this. Once I completed the captcha and rebooted, everything worked.

We’re discussing it here and I have a build that should work with one more piece of info. I’m actually stuck because I can’t figure out the right entityId to set the guard mode (we’re able to determine the state though). @eracknaphobia may have found it but I can’t get it to work in my environment. As soon as we identify the right entity, we’ll probably be able to add it.

I actually don’t know what you’re referring to. Screenshot?

Thats what im talking about:

Comes up when asking Alexa about the Traffic Situation

Ok, I see what you mean. Does your commuteId (the unique ID you mentioned) change if you ask again? The issue will be to find that commuteId somehow.

Yes correct, the picture changes every time it gets updated.And therefore also the uniqueID

Okay, so im lost once again, seems every time I do a fresh install, i manage to kill this component…

I have all 4 files in custom_components, and have the config set appropiately in the configuration.yaml as shown below, and before anyone asks, most recent version, copied the raw format, not the one i goofed on last time…

Im still managing to get the "Invalid Config: the following components and platforms could not be set up: - alexa_media Please check your config.

alexa_media:
  accounts: 
    - email: !secret alexa_user
      password: !secret alexa_pass
      url: amazon.com

Just set this up over the weekend and it let me do the captcha once, and then has shown this. I tried to delete the .pickle file to retry just to make sure I didnt fat finger the captcha, and its been stuck at this state since… any thoughts here?

You mentioned 4 files…there are now 6 files, two more were added to handle the new way HA deals with custom components.
Take a look at:
https://github.com/keatontaylor/alexa_media_player/tree/master/alexa_media

If you are using the custom updater, I believe this will add these two new files automagically.

Those two files were not added automatically by custom updater.

Had to add them manually.
Thanks!

I hope you guys can help me with an alexa tts automation isue. I have read everything I could find but I can’t get an automation working that has an if statement in the alexa message, even though the automation examples show that it should work.
So I have the two automations below of which the first one works fine but the second one just throws this error “Error while executing automation automation.goodmorning_weekday. Invalid data for call_service at pos 1: invalid template (TemplateSyntaxError: unexpected char '”’ at 267) for dictionary value @ data[‘message’]". Now I already tried changing the " to ’ and as in the examples tried both {% if is_state(“alarm_control_panel.lupusec_alarm”,“disarmed”) -%} and {% if states(“alarm_control_panel.lupusec_alarm”) == ‘disarmed’ -%}
Here are the automations from my automations.yaml, any ideas what I got wrong in the second automation?

- id: guten_morgen
  alias: Test Goodmorning Weekday
  trigger:
    platform: time
    at: '18:05:00'
  condition:
    - condition: time
      weekday:
        - mon
        - tue
        - wed
        - thu
        - fri
  action:
  - service: notify.alexa_media
    data:
      data:
        type: announce
      target: media_player.kuche
      message: 
        'Guten Morgen! Die Alarmanlage ist {{ (states("alarm_control_panel.lupusec_alarm") | replace("disarmed","deaktiviert")) | replace("armed_away","aktiviert")}}
        Die Wettervorhersage für heute ist {{ states("sensor.dark_sky_summary") }} bei einer Höchsttemperatur von {{ states("sensor.dark_sky_daytime_high_temperature_0d") | round(0) }} Grad.'

- id: guten_morgen
  alias: Goodmorning Weekday
  trigger:
    platform: time
    at: '18:15:00'
  condition:
    - condition: time
      weekday:
        - mon
        - tue
        - wed
        - thu
        - fri
  action:
  - service: notify.alexa_media
    data:
      data:
        type: announce
      target: media_player.kuche
      message: 
        'Guten Morgen! Die Alarmanlage ist {% if is_states("alarm_control_panel.lupusec_alarm","disarmed") -%} deaktiviert {%- else -%} aktiviert {%- endif %}.
        Die Wettervorhersage für heute ist {{ states("sensor.dark_sky_summary") }} bei einer Höchsttemperatur von {{ states("sensor.dark_sky_daytime_high_temperature_0d) | round(0) }} Grad.'