Google morning script help

hi,
im trying to set up a script that will give a weather update and then play a radio station.

both scripts work yet when combined i only get the radio station triggered

morning:
  sequence:
   - service: tts.google_say
     data_template:
       entity_id: media_player.googlehome8448
       message: >
         Good morning. It's currently {{states.sensor.dark_sky_summary.state}} and {{states.sensor.dark_sky_temperature.state|round}} degrees in Derby. Today will be {{states.sensor.dark_sky_hourly_summary.state|replace(".", "")}}, with a high of {{states.sensor.dark_sky_daily_high_temperature.state|round}} degrees.
   - service: media_player.play_media
     entity_id: media_player.googlehome8448
     data:
      media_content_id: http://vis.media-ice.musicradio.com/RadioXUKMP3
      media_content_type: audio/mp4

could some please tell me what im doing wrong

Try adding a delay after the tts to give it chance to be read - can’t quite get it working (it gives way too much detail when reading out the temp) but the tts followed by music does work with a delay

morning:
  alias: Good Morning Nottinghamshire!
  sequence:
- service: tts.google_say
  data_template:
    entity_id: media_player.kevs_home_mini
    message: >
     Good morning. It's currently {{states.sensor.yr_temperature|round}} degrees in Nottingham.
- alias: Pause a Bit
  delay:
    # supports seconds, milliseconds, minutes, hours
    seconds: 15
- service: media_player.play_media
  entity_id: media_player.kevs_home_mini
  data:
    media_content_id: http://20853.live.streamtheworld.com:3690/JACK_3_OXFORDSHIRE_HIAAC_SC
    media_content_type: audio/mp4

BTW - how do you trigger from Google Assistant? Can’t quite suss that one.?

1 Like

You need a wait_template before the second service to wait for the media player to become idle after speaking the message.

Delay will work too, but might cut the speech short or leave a big silence depending on what length of text is delivered by the template resolving.

1 Like

adding a wait or delay didn’t fix it, yet splitting them up and running them from a script which called one -delayed- then called the other did.

i say good morning which fires a ifttt which in turn fires HA

Not sure why the delay isn’t working for you, but the following works for me:-

The Initial delay is needed because it goes to a state of idle for about a second white starting the TTS, but by keeping that short and then having the wait_template means that the audio starts playing soon after the text has been spoken (this stream always takes forever to start, so the wait time has been minimised.

morning:
  alias: Good Morning Nottinghamshire!
  sequence:
    - service: tts.google_say
      data_template:
        entity_id: media_player.kevs_home_mini
        message: >
         Good morning. It's currently {{states.sensor.yr_temperature.state|round}} degrees in Nottingham.
    - alias: Pause a Bit
      delay:
        seconds: 2
    - wait_template: "{{ is_state('media_player.kevs_home_mini', 'idle') }}"
    - service: media_player.play_media
      entity_id: media_player.kevs_home_mini
      data:
        media_content_id: http://20853.live.streamtheworld.com:3690/JACK_3_OXFORDSHIRE_HIAAC_SC
        media_content_type: audio/mp4
1 Like

Thanks for this a lot cleaner than my approach.