Echo Devices (Alexa) as Media Player - Testers Needed

i use this custom component for sending tts message from HA to Alexa.
but i want to trigger a skill.
skill is
https://alexa.amazon.co.uk/spa/index.html#skills/dp/B07H3LFKW1/?ref=skill_dsk_skb_ys
got the skill id - 33256ba0-d14b-4eb3-a3b5-d6a040485131
i want this skill to be triggered when HA meets a condition.
eg. when xiaomi room temp is 15 deg, i want my climote heating to be switched on.
i usually tell alexa - Alexa ask climote to turn on the heating
how can i do this from home assistant using this alexa media player?
can i send a message to alexa to trigger a skill?
i saw this link but still dont know how to send the exact command to switch on heating


anyone who can help me with the steps to configure and use this?
entity_id: meida_player.my_echo_dot
media_content_id:
media_content_type: skill
how to send my message to alexa - Alexa ask climote to turn on the heating

got to know on reddit HA forum that this can be used for custom skills only along with alexa actions.
is that correct? can we not use this to call regular skills?

Is it possible to see if an echo device was called right in the moment? I want to pause my TV when it is called.

Yes…notification appears

New login is not allowed. Captcha doe not show and 2fa challenge never popup. Reboots not change this

If occur third time I submit bug report

You want an event when you speak to a specific echo device? You can probably monitor the last_called attribute and see when that goes true and whether the last_called_timestamp changes. Someone else will have to explain the implementation but it’s probably similar to the Last Alexa templates people have made. We may be able to expose an event too, but it’s basically detected as described above.

I don’t know what “not allowed” means. If it’s a blank captcha, enter anything and it should refresh it. Regardless, logs are necessary to debug further.

I found this was an easy way to trigger a skill:
In the alexa app (eg. iOS), create a Routine that runs a skill.
Then use this integration to run your Routine.

Data fields (eg. node red)

{
    "media_content_type": "routine",
    "media_content_id": "ghjkp"
}

In my case I use HA, not spoken words, to run this routine + skill, so the routine setting for “When you say” is a random character identifier:

When you say:
Alexa, ghjkp

Works nicely, and no fussing with skill IDs.

thanks for the help.
unfortunately i cant use routine because, routine can only open a skill.
i cant send the message in routine for eg - ask climote what is the temperature

Yes that.
Entering anything failed. It just reappeared blank.

Yes correct! Exposing it as an event might be easier for me since I don’t really know how to monitor the attributes.

Accessing the last_called attribute works like this:

    - service: alexa_media.update_last_called
    - delay: "00:00:01"
    - service: light.turn_on
      data_template:
        entity_id: >
          {% if is_state('sensor.last_called_alexa','media_player.wohnzimmer') %}
             light.wohnzimmer
          {% elif is_state('sensor.last_called_alexa','media_player.gastezimmer') %}
             light.gastezimmer
          {% elif is_state('sensor.last_called_alexa','media_player.office') %}
             light.office
          {% elif is_state('sensor.last_called_alexa','media_player.kuche') %}
             light.kuche
          {% elif is_state('sensor.last_called_alexa','media_player.fitnessraum') %}
             light.fitnessraum
          {% elif is_state('sensor.last_called_alexa','media_player.schlafzimmer') %}
             light.schlafzimmer
          {%- endif %}

and the last changed attribute is this: {{ states.sensor.last_called_alexa.last_changed }}

2 Likes

Thanks a lot! Now I just created a sensor and took attributes.

The second step would be to resume the TV if the call is not active anymore (Alexa not listening and done responding). Is this possible?

Sorry, I have definitely no idea. But in the end it is like alandtse mentioned. Good idea for two events, incoming call and call stopped

No. We do not know when Alexa is finished with a call. All you will be able to tell from the API is that someone has interacted with an Alexa.

Hi guys,

I just installed this component from HACS and while notifications work fine I have 2 issues:

  1. I can’t seem to exclude devices:
alexa_media:
  accounts:
    - email: !secret amazon_user
      password: !secret amazon_password
      url: amazon.com
      include_devices:
        - Kitchen
      exclude_devices:
        - Downstairs
        - Upstairs
        - "L's Fire TV stick"
  1. The sensors associated with the devices are all disabled:
Kitchen do not disturb switch - grayed out
Kitchen next Alarm - Unavailable
Kitchen next Reminder - Unavailable
Kitchen next Timer - Unavailable
...all others grayed out

Any ideas?

Maybe try using either include or exclude but not both.

I did try that as well - I am wondering if it might have something to do with the fact that I had it installed manually before?

I was able to get Pandora to stream to my Amazon Spot with the code below. The first press of the button starts the stream, but there is no way to stop it unless I verbally tell Alexa to stop. Any suggestions on how to fix this.

entity: media_player.echo_spot
icon: 'mdi:guitar-electric'
name: Golden Oldies
show_state: false
tap_action:
  action: call-service
  service: media_player.play_media
  entity: media_player.echo_spot
  service_data:
    entity_id: media_player.echo_spot
    media_content_id: Golden Oldies
    media_content_type: PANDORA
type: 'custom:button-card'

So I updated to 0.112 Beta, and got the configure prompt and keep getting “Failed to call service configurator/configure. /ap/cvf/approval/poll”
Tried downgrading both HA to 0.111.4 as well as Alexa Media Player (after just downgrading HA didn’t work) to 2.8.6, both now back to latest (2.8.7 and 0.112 beta) since the downgrade didn’t resolve
This is in the log:

Traceback (most recent call last):
  File "/srv/homeassistant/lib/python3.7/site-packages/homeassistant/components/websocket_api/commands.py", line 130, in handle_call_service
    connection.context(msg),
  File "/srv/homeassistant/lib/python3.7/site-packages/homeassistant/core.py", line 1260, in async_call
    task.result()
  File "/srv/homeassistant/lib/python3.7/site-packages/homeassistant/core.py", line 1295, in _execute_service
    await handler.func(service_call)
  File "/srv/homeassistant/lib/python3.7/site-packages/homeassistant/components/configurator/__init__.py", line 235, in async_handle_service_call
    await self.hass.async_add_job(callback, call.data.get(ATTR_FIELDS, {}))
  File "/home/homeassistant/.homeassistant/custom_components/alexa_media/configurator.py", line 28, in configuration_callback
    setup_platform_callback, hass, config_entry, login, callback_data
  File "/home/homeassistant/.homeassistant/custom_components/alexa_media/configurator.py", line 177, in setup_platform_callback
    await login.login(data=callback_data)
  File "/srv/homeassistant/lib/python3.7/site-packages/alexapy/helpers.py", line 104, in wrapper
    return await func(*args, **kwargs)
  File "/srv/homeassistant/lib/python3.7/site-packages/alexapy/alexalogin.py", line 431, in login
    site, data=self._data, headers=self._headers, ssl=self._ssl,
  File "/srv/homeassistant/lib/python3.7/site-packages/alexapy/aiohttp/client.py", line 506, in _request
    traces=traces,
  File "/srv/homeassistant/lib/python3.7/site-packages/alexapy/aiohttp/client_reqrep.py", line 308, in __init__
    self.update_host(url)
  File "/srv/homeassistant/lib/python3.7/site-packages/alexapy/aiohttp/client_reqrep.py", line 369, in update_host
    raise InvalidURL(url)
alexapy.aiohttp.client_exceptions.InvalidURL: /ap/cvf/approval/poll

Anyone with any ideas how to fix?

I’m guessing at what the actual issue is because your config would only allow discovery of the media player for the kitchen and excludes everything else. So I’d say your’e pretty successful at excluding devices.

If you include both include_devices and exclude_devices you will only be able to exclude what is in your include list. The reason is include is more restrictive and only items in there will be included. So with your config, you’ve only included the Kitchen so only that media player will be discovered.

Please see the documentation.

Multiple potential issues.

  1. You must include every sensor you want if you are using include_devices. Right now your config will only include the base media player and none of the extra switches/sensors. So the fact they even appear is probably because at one point they were discovered before you applied the filters but now are dead because you didn’t say you wanted them included again.
  2. The next sensors only populate with data if there is actually a next alarm, reminder, or timer. Otherwise they are unavailable so you can hide them.
  3. You are logged in the wrong domain so they’re not getting information so will appear as unavailable.

Use the media_player.media_stop command. But this would only work if the stop command works in a routine in the Alexa app. I haven’t tested it with pandora so if doesn’t work there, then we can’t do anything.

You found a new Amazon login page apparently. File a bug report and provide the requested logs so we can examine the page. Until we handle it, your only workaround is hoping Amazon gives you another login page.

Thanks - I removed the include_devices section and now I can see that the do no disturb sensor is now available for my Kitchen echo. I originally had it like that (without an include section) in an attempt to get excluding to work as I expected - that items listed wouldn’t show up as devices. However it still shows all of the excluded devices?