Beginner question - execute command

Hello from this instruction page:

I want to transfer this command to my HA:

Entity_id : media_player.kitchen 
media_content_id : ' wie ist es ' 
spät media_content_type : custom

Unfortunately, I don’t know where to paste the code to make the command callable.
Can somebody help me with it?

Greetings Werner
Gruß Werner

You can use it in the action part of an automation or in scripts or as a button action.

1 Like

Hi there,

Thanks for the answer.
Just tried this like this (automation):

alias: Klingeln Test2
description: ''
trigger:
  - platform: state
    entity_id: binary_sensor.ewelink_ds01_ad45ff22_ias_zone
    to: 'off'
condition: []
action:
    entity_id: media_player.evas_echo_flex
    media_content_id: 'what time is it'
    media_content_type: custom

Unfortunately there comes an error message.
Is there a bug in the code?

That was nonsense:
And you can address multiple echoes there.
Example:

```
alias: Klingeln Test2
description: ‘’
trigger:
- platform: state
entity_id: binary_sensor.ewelink_ds01_ad45ff22_ias_zone
to: ‘off’
condition: []
action:
entity_id: media_player.evas_echo_flex
entity_id: media_player.echo_dot_bad
media_content_id: ‘what time is it’
media_content_type: custom

```

Greetings Werner

The automation action first needs a service call.

    action:
      - service: notify.alexa_media_echo_dotchen
        data:
          message: Die Katzentoilette wurde benutzt.<break time="500ms"/>Bitte reinige sie.
          data:
            type: tts
            method: speak

1 Like

In a button:


type: custom:button-card
name: Zeitansage
tap_action:
  action: call-service
  service: media_player.play_media
  service_data:
    media_content_id: wieviel Uhr ist es
    media_content_type: custom
    entity_id: media_player.echo_dotchen

1 Like

Hi there,

Thanks for the answer.
Do I see it correctly, with this command Alexa speaks the text specified in the command ?:

and with this command I give Alexa a voice command:

Is that so?
I want to be able to give an indirect voice command to Alexa via automation. Command could be “Alexa, turn on the radio”.
How can I use my example to do this?

Thanks very much.

Greetings Werner

Yes.

The service call notify.alexa_media is a simple message (Sprachnachricht) as if you would receive a message on the answering machine. It’s one-way.

The service media_player.play_media forces an action to be performed by Alexa.

In an automation it looks like this:


action:
  - service: media_player.play_media
    target:
      entity_id: media_player.echo_dotchen
    data:
      media_content_id: spiele Antenne Bayern
      media_content_type: custom

(There are alternative ways but in my opinion this is the easiest one)

And much much more here: https://github.com/custom-components/alexa_media_player/wiki#sequence-commands-versions–100

1 Like

Hi there,

unfortunately it doesn’t work for me.
Have the following automation create. The text is there as a routine, it also works as a voice command. However, the automation does not trigger the routine.
The test with “Spiele Antenne Bayern” did not work either.

alias: Klingeln an Alexa leiten
description: ''
trigger:
  - platform: state
    entity_id: binary_sensor.ewelink_ds01_ad45ff22_ias_zone
    to: 'off'
condition: []
action:
  - service: notify.alexa_media
    target:
      entity_id: media_player.evas_echo_flex
    data:
      message: Es klingelt
      media_content_type: custom
mode: single

What could be the reason?

Greetings Werner

The service notify.alexa_media is not always reliable. Use my example above:


    action:
      - service: notify.alexa_media_echo_dotchen
        data:
          message: Die Katzentoilette wurde benutzt.<break time="500ms"/>Bitte reinige sie.
          data:
            type: tts
            method: speak

would be:


    action:
      - service: notify.alexa_media_evas_echo_flex
        data:
          message: Es klingelt
          data:
            type: tts
            method: speak

1 Like

OK. Thanks.
would then use media_player.play_media.

Therefore, Antenne Bayern is played with the following automation:

alias: Klingeln an Alexa leiten
description: ''
trigger:
  - platform: state
    entity_id: binary_sensor.ewelink_ds01_ad45ff22_ias_zone
    to: 'off'
condition: []
action:
  - service: media_player.play_media
    target:
      entity_id: media_player.evas_echo_flex
    data:
      media_content_id: spiele antenne bayern
      media_content_type: custom

But if I enter the command of a routine there, it does not work:

alias: Klingeln an Alexa leiten
description: ''
trigger:
  - platform: state
    entity_id: binary_sensor.ewelink_ds01_ad45ff22_ias_zone
    to: 'off'
condition: []
action:
  - service: media_player.play_media
    target:
      entity_id: media_player.evas_echo_flex
    data:
      media_content_id: Es klingelt
      media_content_type: custom

Greetings Werner

Whew, got it done.
Thats how it works:

alias: Klingeln an Alexa leiten
description: ''
trigger:
  - platform: state
    entity_id: binary_sensor.ewelink_ds01_ad45ff22_ias_zone
    to: 'off'
condition: []
action:
  - service: media_player.play_media
    target:
      entity_id: media_player.evas_echo_flex
    data:
      media_content_id: Es klingelt
      media_content_type: routine

Thanks very much. Greetings Werner

I hope I can disturb you again. Just noticed that I can only output routines on one device. So I would like to use the following automation:
This works well so far.

Problem: I don’t know how to set the output on multiple devices.
I would still like to
media_player.evas_echo_flex
and
media_player.evas_echo_dot_bad

Add.

Greetings Werner

This is how it works with one device:

alias: Klingeln Ring the door bells
trigger:
  - platform: state
    entity_id: binary_sensor.down_ring_ding
    to: 'on'
action:
  - service: media_player.play_media
    data:
      entity_id: media_player.bose_smart_soundbar_300
      media_content_type: sound
      media_content_id: amzn_sfx_doorbell_chime_01
  - service: notify.alexa_media
    data:
      target:
        - media_player.bose_smart_soundbar_300
      data:
        type: tts
      message: Achtung.
mode: single

No problem.


- service: media_player.play_media
  target:
    entity_id:
      - media_player.1
      - media_player.2
  data:
    media_content_type: …
    media_content_id: …

  - service: notify.alexa_media
    data:
      target:
        - media_player.1
        - media_player.echo_2
      message: …
      data:
        type: tts

1 Like

Hi there,

now everything works great. Exactly as requested.
Thank you very, very, very much.
And a nice weekend.

Greetings Werner

Glad to hear. Nice weekend, too!

1 Like