Sonos_say not working properly

I’m trying to call the sonos_say script from another script and when I call the script from HA it runs the first time then it errors out and won’t run anymore. Can someone please take a look and see what i’m missing?

Error:

Error executing service <ServiceCall script.sonos_say: sonos_entity=media_player.dining_room, volume=0.4, message=Good afternoon. 
  Stacie is currently at SkyHigh Trampolines. If she leaves now, it will take her 33 mins to get home.>
Traceback (most recent call last):
  File "/usr/src/app/homeassistant/core.py", line 1006, in _event_to_service_call
    await service_handler.func(service_call)
  File "/usr/src/app/homeassistant/components/script.py", line 160, in service_handler
    if script.is_on:
AttributeError: 'NoneType' object has no attribute 'is_on'

sonos_say script

alias: Sonos TTS Script
sequence:
  - service: media_player.sonos_snapshot
    data_template:
      entity_id: "{{ sonos_entity }}"
  - service: media_player.sonos_unjoin
    data_template:
      entity_id: "{{ sonos_entity }}"
  - service: media_player.volume_set
    data_template:
      entity_id: "{{ sonos_entity }}"
      volume_level: "{{ volume }}"
  - service: tts.google_say
    data_template:
      entity_id: "{{ sonos_entity }}"
      message: "{{ message }}"
  - delay: "{{ delay }}"
  - service: media_player.sonos_restore
    data_template:
      entity_id: "{{ sonos_entity }}"

My script

alias: Locate Vince
sequence:
  - service: script.sonos_say
    data_template:
      sonos_entity: media_player.dining_room
      volume: 0.40
      message: >
        {% if now().strftime("%H")|int < 12 %}
        Good morning.
        {% elif now().strftime("%H")|int < 18 %}
        Good afternoon.
        {% else %}
        Good evening.
        {% endif %}
          Vince is currently at {{states.sensor.vince_using_ios.state}}. If he leaves now, it will take her {{states.sensor.vince_to_home.attributes.duration_in_traffic}} to get home.

I’m not sure what’s going on.

My TTS notification scripts haven’t been functional since 0.65.0. I initially thought the issue was Google Play integration, but this has since been fixed. When run, my scripts notify as intended, but then just replay the notification instead of resuming the music.

It seems that sonos_snapshot or sonos_restore isn’t working.

i wonder if there has to be a delay set or wait until an action completes before the next section starts.

Yes, with that script you need to set a delay, like delay: 00:00:10 (you can place it after the volume setting).

That will probably not make it work, though. Your detailed report helped me find a bug with the sonos_unjoin service call: PR #13248