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.