Only last service is called?

I created a script and want Home Assistant to speak two texts consecutively.
But only the last sentence works.
Is there a way I can let Google Cast to speak the first sentence, and then the second sentence?

say_english_and_chinese:
  alias: Cast to two sentences in two languages
  mode: queued
  max: 20
  sequence:
    - service: tts.google_translate_say
      data:
        entity_id: media_player.gu_ge_mini
        message: This is a test!
    - service: tts.google_translate_say
      data:
        entity_id: media_player.gu_ge_mini
        message: 这是一个测试!
        language: zh

Put a delay between the two messages long enough to finish the first message.

I’m not good with yaml automations, I can only do the basic stuff. But I believe there is a wait until you could use also.
So wait until state is idle, then play second message.

Here it is:

Thanks. Delay works. Here is the working version:


say_english_and_chinese:
  alias: Cast to prompt class starts in two languages
  mode: queued
  max: 20
  sequence:
    - service: tts.google_translate_say
      data:
        entity_id: media_player.gu_ge_mini
        message: This is a test!
    - delay: 3
    - service: tts.google_translate_say
      data:
        entity_id: media_player.gu_ge_mini
        message: 这是一个测试!
        language: zh

But having fixed delays means that in some cases you might have to wait for two seconds, and sometimes the next message will interrupt the first message.

You’re correct. It is a bit cumbersome to specify a fixed delays. I don’t know whether there is a better solution for this.

If you scroll up a few scrolls then you can read the rest of my first reply

Got it. I made a working script. Thanks a lot!
The trick is to first delay 1 seconds, and then wait until the media player is idle.

say_english_and_chinese:
  alias: Cast to prompt class starts in two languages
  mode: queued
  max: 20
  sequence:
  - service: tts.google_translate_say
    data:
      entity_id: media_player.gu_ge_mini
      message: This is a test!
  - delay: '1'
  - wait_template: '{{ is_state(''media_player.gu_ge_mini'', ''idle'') }}'
  - service: tts.google_translate_say
    data:
      entity_id: media_player.gu_ge_mini
      message: 这是一个测试!
      language: zh
1 Like