TTS `speak` Service Fails Silently in Automation, but Works Perfectly in Developer Tools

Hi everyone,

I’m hoping for some help with a maddening issue that I’ve spent a lot of time on but can’t seem to solve.

I have an automation where a tts.speak service call is silently failing, even though the exact same service call works perfectly when executed from the Developer Tools.

The Goal:
I’ve built a “Welcome Home” sequence. The goal is:

  1. When a person arrives home, a helper (input_boolean) is turned on to “arm” the sequence.
  2. When motion is then detected in the living room, the main automation triggers.
  3. It should then play a TTS message to a Sonos speaker, run a 3-second light effect, and then disarm the helper.

The Problem:
The automation runs successfully from start to finish according to the trace. All steps show a green checkmark, including the tts.speak service call. The lights perform their actions correctly, but the TTS message never plays.

However, if I go to Developer Tools > Services and run the exact same tts.speak service call with the same message, speaker, and TTS engine, it works instantly and perfectly every time. This proves the TTS integration and the speaker are working correctly in isolation.


The Automation Code:
Here is the final version of the Welcome Home Greeting automation that is failing silently on the TTS step.

alias: Welcome Home Greeting
description: Greets an arriving person with a light sequence and a verbal announcement.
mode: restart

trigger:
  - platform: state
    entity_id: binary_sensor.hue_motion_sensor_2_motion
    to: 'on'

condition:
  - condition: state
    entity_id: input_boolean.welcome_greeting_pending
    state: 'on'

action:
  # This helper automation correctly identifies the arriving person
  - variables:
      arriving_person: >-
        {% if is_state('person.john_doe', 'home') and (now() - states.person.john_doe.last_changed).total_seconds() < 300 %}
          John
        {% elif is_state('person.margot_Doe', 'home') and (now() - states.person.margot_Doe.last_changed).total_seconds() < 300 %}
          Margot
        {% else %}
          friend
        {% endif %}

  # All of these Sonos and light actions work perfectly.
  - service: scene.create
    data:
      scene_id: before_welcome_snapshot
      snapshot_entities:
        - light.hue_tv_back_lightstrip
        - light.hue_tv_cabinet

  - service: media_player.volume_set
    target:
      entity_id: media_player.sonos
    data:
      volume_level: 0.15
  - delay: '00:00:02'

  # THIS IS THE STEP THAT FAILS SILENTLY
  - service: tts.speak
    target:
      entity_id: tts.openai_gpt_4o_mini_tts
    data:
      media_player_entity_id: media_player.sonos
      message: '{{ ["Welcome home, " ~ arriving_person ~ "."] | random | trim }}'
      options:
        voice: "ballad"

  # The automation continues and these light effects work perfectly.
  - delay: '00:00:05'
  - service: light.turn_on
    target:
      entity_id:
        - light.hue_tv_back_lightstrip
        - light.hue_tv_cabinet
    data:
      effect: prism
      brightness_pct: 100
  - delay: '00:00:03'
  - service: scene.turn_on
    target:
      entity_id: scene.before_welcome_snapshot
  - service: input_boolean.turn_off
    target:
      entity_id: input_boolean.welcome_greeting_pending

What I’ve Already Tried (Troubleshooting Steps):

  • Isolated Dev Tools Test: The tts.speak call works perfectly from Dev Tools every single time.
  • Changed TTS Engine: The silent failure happens with a custom OpenAI TTS integration AND with the standard tts.home_assistant_cloud. This suggests the issue is not with one specific engine.
  • Simplified the Message: The failure happens with both complex Jinja templates and simple strings like message: "Hello!".
  • Checked the Speaker: The media_player.sonos entity is correct. The volume is set correctly before the call. Manual tests to this speaker work.
  • Added Delays: I have tried delays from 1 to 5 seconds after setting the volume and before the TTS call to solve any potential “race conditions.” The TTS step still fails silently.
  • Checked Logs: Home Assistant logs show no errors. The automation trace shows the TTS step as successfully completed.

My Core Question:
Has anyone encountered a situation where a service call, specifically tts.speak, works flawlessly from the Developer Tools but fails silently (without errors) when placed inside an automation sequence? Is this a known bug, a subtlety with the Sonos integration, or a deeper timing issue within the automation engine itself that I’m not seeing?

Thank you so much for any insights you can provide!

I swear this is driving me nuts!

Don’t know if this would make any difference, but my voice: option is not in quotes.

1 Like

Thanks I’ll try this out!

Try using the tts examples in the Sonos documentation, rather than what you are doing.

If that doesn’t work, enable debug logging for Sonos and post the log file along with the timestamp of when the TTS announcement should have happened.

1 Like

I’ve had this happen before. I have an automation that says a phrase before playing some music, and sometimes the phrase would not be spoken.

I noticed an error in my logs, something to do with what looked like a cached mp3 file, so I ran a tts.clear_cache command and it worked perfectly.

Might be worth a go ?

1 Like