Home Assistant

Type a message on the dashboard and announce it on speakers

A script snapshots each player's volume, speaks a dashboard message at an announce volume with an optional chime, and restores the previous volumes. Typing in the text box runs it.

Difficulty · BeginnerSetup · 20–40 minutesHA · 2024.10 or newer
Get the pack · from $19Have us set it up

Typing a sentence on a dashboard should not mean opening a media player, setting a volume, and hoping the previous music comes back at the same level. This pack is a script that reads a message, turns the chosen speakers up or down to an announce volume, plays an optional chime, speaks, and puts each speaker’s previous volume back. An automation runs that script when the text helper changes, then clears the box so the next message starts empty.

Speakers that should duck because a voice satellite is listening, rather than because you typed something, are voice satellite media duck. A volume that should ramp across the day and survive a restart is restart-proof volume ramp. Finding a phone by making it ring is voice find my phone.

What problem it solves

You want a text box on the wall dashboard, a chime, a spoken message on one or more speakers, and the volume back where it was.

How it works

  1. The message. The script uses the message field when it is not blank. Otherwise it reads the text helper (the pack creates input_text.announcement_message). An empty string does nothing.
  2. Volumes. For each player it stores volume_level. Then it sets every player to the announce volume (default 0.45). A player that has no volume attribute is stored as that same announce volume, so the restore has a number to write.
  3. Chime. If the chime media id is not empty, the script plays it with announce: true and waits the chime delay (default 2 seconds). Players that reject announce are skipped for the chime (continue_on_error). Leave the id empty to speak with no chime.
  4. Speech. tts.speak on the TTS entity you pick, with the players in media_player_entity_id and announce: true. If nothing is playing a couple of seconds later, it tries once more without announce, for players that reject that key. It then waits until the players leave playing, or two minutes, whichever comes first.
  5. Restore. Each stored volume is written back, even when the speak step reported an error.
  6. The text box. The automation triggers when the helper changes to anything other than empty, runs the script, and sets the helper back to empty. The script copies the text at the start, so the clear does not erase the sentence mid-speech.
  7. The card. dashboard/announcer_card.yaml is a vertical stack: an entities card for the text helper, and a button that calls the script. With the automation on, typing is enough. The button is there for a dashboard where you turned that automation off. Change script.dashboard_announcer in the card to the script entity you actually created.

The script is queued (up to 3), so a second message waits instead of talking over the first.

Snippet

The speak step. The entity and the players are script inputs. announce: true is set on this call. The second call in the file omits it when the first one did not start playback.

- action: tts.speak
  target:
    entity_id: !input tts_entity
  data:
    media_player_entity_id: !input players
    message: !input message
    announce: true

Setup outline

  1. Copy helpers/dashboard_tts_announcer.yaml into config/packages/ and restart, or create an input_text named Announcement with a max length of 255. Copy the script blueprint into config/blueprints/script/edotdev/ and the automation blueprint into config/blueprints/automation/edotdev/. Reload blueprints.
  2. Create the script. Pick the text helper, the players, and the TTS entity. Set the announce volume. Leave the chime empty until speech works.
  3. Run the script once from Developer tools with a message in the field. The speakers should change volume, speak, and return to the old volume.
  4. Create the automation. Pick the same text helper and the script entity. Type into the helper from Developer tools → States, or from the dashboard card. It should speak and the box should clear.
  5. Paste dashboard/announcer_card.yaml into a dashboard (Edit, then the raw configuration, under a view’s cards:). Change the button’s script entity id if you did not name the script dashboard_announcer.

Troubleshooting

  • Nothing is said, and the box still clears. The script’s message field on the blueprint is a leftover sentence, and the helper was empty when the automation ran. The field wins when it is not blank. Clear the message field on the script so the helper is what gets spoken. The automation clears the helper after the script returns, including when the script stopped because the text was empty.
  • Volume stays at the announce level. The player has no volume_level attribute (some players only have a step up and down). The restore writes a number those players ignore. Set the announce volume to the level you are willing to leave, or pick a player that reports volume.
  • The chime plays and the message never does. The chime wait is longer than the clip, or tts.speak failed. The trace shows the error. A TTS entity that is not loaded, or a message the engine rejects, stops that step. The volume restore still runs.
  • It speaks twice. The first tts.speak used announce: true, the player ignored it and was slow to enter playing, and the fallback call ran too. Raise the two-second pause, or remove the fallback call in your copy if every player accepts announce.
  • Two dashboards clear each other’s text. They share input_text.announcement_message. Duplicate the helper for a second box.
  • The button does nothing. The card still says script.dashboard_announcer. Use the entity id from Settings → Automations & scenes → Scripts.
  • Music does not resume. This script restores volume. It does not resume a paused track. Players that stop playback in order to speak will stay stopped. That is the player, not the volume snapshot.

Credits

Saving a speaker’s volume, playing a message, and restoring the volume is the approach in Announce text-to-speech on a media player.

Changelog

v1.0 · Nov 2, 2026: First publish.