Echo Devices (Alexa) as Media Player - Testers Needed

@tman75 I updated the gist so it matches my current configuration… At some point I added a couple entity updates to the announce script.

Updated Announce Script
alias: Send Alexa Announcement
sequence:
  - service: homeassistant.update_entity
    data: {}
    target:
      entity_id: input_select.alexa_state
  - service: homeassistant.update_entity
    data: {}
    target:
      entity_id: input_text.announcement_text
  - service: notify.alexa_media
    data:
      data:
        type: announce
        method: speak
      target: '{{ states("sensor.alexa_selector") }}'
      message: '{{ states(''input_text.announcement_text'') }}'
mode: single

The next thing I would do is to paste all the inputs into the template editor to make sure they are returning the desired values:

Script Inputs
{{ states('input_select.alexa_state')}}
{{ states('sensor.alexa_selector')}}
{{ states('input_text.cmd_text')}}
{{ states('input_text.announcement_text')}}

If they all return the right information, then the problem is in the scripts.

Feel free to go ahead and post you edits if you still have issues

Thanks. I will take a look now. I did notice when spelling mistake which threw me for a loop! LOL

I get errors in the send Alexa command and stop Alexa command. But those are nice to have, the need to have is the announcement.

Here’s my configs.

config
#Alexa Announcement
  - platform: template
    sensors:
      alexa_selector:
        value_template: >
          {% set room = states("input_select.alexa_state") -%}
          {% set echo_select = dict([
              ('Kitchen', 'twilight_zone'),
              ('All', 'everywhere'),
          ]) %}
          {%- if room in echo_select -%}
            media_player.{{ echo_select[room] }}
          {%- endif %}
Scripts
send_alexa_command:
  alias: send_alexa_command
  sequence:
  - service: media_player.play_media
    data_template:
      entity_id: '{{ states("sensor.alexa_selector") }}'
      media_content_id: '{{ states("input_text.cmd_text") }}'
      media_content_type: custom
  mode: single
send_alexa_announcement:
  alias: send_alexa_announcement
  sequence:
  - service: homeassistant.update_entity
    data: {}
    target:
      entity_id: input_select.alexa_state
  - service: homeassistant.update_entity
    data: {}
    target:
      entity_id: input_text.announcement_text
  - service: notify.alexa_media
    data:
      data:
        type: announce
        method: speak
      target: '{{ states("sensor.alexa_selector") }}'
      message: '{{ states("input_text.announcement_text") }}'
  mode: single
stop_alexa_command:
  alias: stop_alexa_command
  sequence:
  - service: media_player.play_media
    data_template:
      entity_id: '{{ states("sensor.alexa_selector") }}'
      media_content_id: stop
      media_content_type: custom
  mode: single

When I run the text through the Lovelace card, no errors in the log viewer show up.

Hmmm… I do it like this:

instant_message:
  sequence:
    - service: notify.alexa_media
      data:
        target: "{{ states('input_select.message_target') }}"
        data:
          type: "{{ states('input_select.speech_mode') }}"
          method: all
        message: "{{ states('input_text.text1') }}"

image

1 Like

Wondering if anyone can help;

I have created a script to ask Alexa “how much petrol do I have left in my car”. This works fine if i ask my kitchen echo, which is what i put on the service bit.

But what i want to do is have Alexa reply on only the echo I speak to, so for example if i ask my living room echo “how much petrol do I have left in my car” she will only respond on that echo

I have seen you can create groups but alexa then reply’s on all my echos.

Hope this makes sense

1 Like

Do it like this:

question_outside_temperature:
  sequence:
    - service: alexa_media.update_last_called
    - delay: "00:00:01"
    - service: notify.alexa_media
      data:
        target: "{{ states('sensor.last_called_alexa') }}"
        data:
          type: tts
        message: >
          {% if states('sensor.outside_temperature') |length > 2 %}
             Die Temperatur im Garten beträgt {{ states('sensor.outside_temperature') |replace('.', ',') |round(1) }} Grad.
          {% else %}
              Die Temperatur im Garten beträgt {{ states('sensor.outside_temperature') }} Grad.
          {% endif %}
          {% if states('sensor.8_hour_rain_forecast_total') | float == 0 %}
            Regen ist nicht in Sicht.
          {% elif states('sensor.8_hour_rain_forecast_total') | float > 0 and states('sensor.8_hour_rain_forecast_total') | float < 1 %}
            Es wird leichter Regen erwartet
          {% else %}
            Es wird stärkerer Regen erwartet.
          {% endif %}

3 Likes

Thanks. this looks great. I’ll try it later. Right now I just use the mini media player and add all the dots that I want for my “PA” system.

From time to time the status of the timers stops working. So e.g. the timers are unavailable, even if one is set. After restarting the integration, it is working again and the status is shown.

As I would like to automate the restart in such situations, I wonder if someone has any clue, how to “see” if the integration is currently not working.

E.g. one of the alexa entities is then in a whatever state, which it should not the case. Currently, I can only see that the other status are fine and working in such cases and there is no break or unavailability. Only the timers are not there/updatet.

To check just sensor.echo_dot_next_timer will not make any sense, because it is unavailable if it is not set and if the integration is not working, so I cannot distinguish between them.

I have been using Alexa plugin for awhile but one thing I cannot figure out is how to get it to discover my actual Alexa players. I was looking for a way to play messages or interact with my Alexa devices but when I searched for media_player entities I do not have any of my Alexa’s showing up. Am I missing a step? I linked the accounts and my Alexa’s do discover newly added items in Home Assistant so they must be connected somehow. Is there something I need to do to have all my Alexa’s discovered and added to HA?

By “Alexa plugin” you mean Alexa media player? If so then …
Does Configuration → Integrations show an Alexa Media Player integration?
If so what does it show when you click on devices within the integration?
These are your media players.
If you click on entities you will see all your Alexa entities including the media players

Is the anybody who encountered problems using the dummy light’s brightness? I recently get the error message

UndefinedError: ‘homeassistant.util.read_only_dict.ReadOnlyDict object’ has no attribute ‘brightness’

hey, i hope i’m right here.

i would like to play mp3’s via an automation.
it actually works very well so far.
they are all converted in the correct format.

service: notify.alexa_media
data:
  message: >-
    <audio
    src='https://loremipsum.com/files/mp3/003.mp3'/>
  data:
    type: tts
  target: media_player.my_echo_dot

I would like to play different mp3s in shuffle or randomly.

This will probably not work via the “notify.alexa_media” service. (at least nothing is known to me) ((alternative might be nodered here?!?))
But via the service: “media_player.play_media” it should also be possible to use this in automations?! In combination with Alexa?
And here you should be able to play MP3’s in shuffle.

service: media_player.play_media
data_template:
  entity_id:
    - media_player.my_echo_dot
  media_content_type: MP3
  media_content_id: |
    {{ ["https://loremipsum.com/files/mp3/003.mp3", 
        "https://loremipsum.com/files/mp3/004.mp3", 
        "https://loremipsum.com/files/mp3/005.mp3", 
        "https://loremipsum.com/files/mp3/006.mp3"] | random }}

```
But this doesen´t work.

It is not possible to play mp3 files or other formats with echo devices. You could use the music unlimited service via custom commands

Yes, it is possible to play mp3.

as “service: notify.alexa_media”

service: notify.alexa_media
data:
  message: <audio src='https://kt-montage.com/files/smarthomeyourself/mp3/001.mp3'/>
  data:
    type: tts
  target: media_player.nathalies_echo_dot

this works!

but unfortunately somehow ONLY from my server.
now i’ve tried to upload the whole thing to amazons3, for example, but then i get the error again: simon says eu skill…


edit:
I uploaded the same file to amazon s3, for example.
but is not played.
I can not understand that unfortunately

message: <audio src='https://ktamazons3.s3.eu-central-1.amazonaws.com/smarthomeyourself/001.mp3'/>

after a long time, i have started using alexa media player custom component.
i have logged-in to alexa account with 2fa with integration,
all my devices show in the list, but none of them are unavailable,
am i missing something?

1 Like

i am in India, and i have succesfully loddeg to my amazon account.
but i cant connect to devices attached to my amazon account.

edit,

i got it by changing amazon.com to amazon.in

my echo dot devices are avaialable now,
but my firestick tv still shows standby and nothing work.
can someone please guide.
thanks

I’m not having luck on my dedicated thread, so i thought i’d give this one a shot.
I’m trying to figure out how i can make an automation that triggers when a new timer is added or removed from the alexa timer sensor. One timer isn’t an issue (there’s also an example here on the github), the issue is when multiple timers are added in one go (low likelihood), or remove (very likely, especially when asking alexa to cancel all timers). I need to recognize which timer IDs were added/removed.

Can anyone lend a hand please?

Hi, after update to 2022.4.6 the states of my devices are not shown. I did not see set reminders or timers and after starting music, the media player entities are not reported as playing. Commands from HA to the devices and vice versa working as usual. TTS as well.
What’s wrong?

1 Like

Would it be possible to add device_class for temperature sensors reported from Alexa Devices?

I’ve just upgraded to Dwains Dashboard v3 and it requires the device_class: temperature to be set for it to show on the room tile.