How can I add an action to a dashboard?

I need to do this every now and then and I don't want to go into developer tools and then choose the announce script.

but if I add the announce into a dashboard it just adds a button and it does not let me configure the two fields

is there any way to do this simply without writing a program to read specific fields and then call a script

Yes just add that action to an automation triggered with a helper button.

I need to be able to type a different message each time

Then you probably need a template and text helper but how I have no idea sorry, but I guess the Docs will help.

Quick and dirty basic solution:

  1. Go to Settings -> Devices & Services -> Helpers -> Create Helper -> Text and use the following:
  • Name: Announcement Text
  • Entity ID (generated automatically): input_text.announcement_text
  1. Create a script like this:
alias: "Send Announcement to Speakers"
icon: mdi:volume-high
sequence:
  # 1. Send the text to speakers as an announcement (keeps background music playing)
  - action: media_player.play_media
    target:
      entity_id:
        - media_player.kitchen_mini
        - media_player.restroom_mini
    data:
      media_content_id: >-
        media-source://tts/tts.home_assistant_cloud?message={{ states('input_text.announcement_text') }}
      media_content_type: music
      announce: true
      
  # 2. Automatically clear the input field after broadcasting
  - action: input_text.set_value
    target:
      entity_id: input_text.announcement_text
    data:
      value: ""
  1. Lovelace card of Your liking e.g. :
type: vertical-stack
cards:
  - type: entities
    title: Send Announcement
    show_header_toggle: false
    entities:
      - entity: input_text.announcement_text
        name: Announcement Message
        icon: mdi:comment-text-outline
    card_mod:
      style: |
        ha-card {
          border-radius: 12px 12px 0px 0px !important;
          border-bottom: none !important;
          box-shadow: none !important;
        }
  - type: button
    name: Broadcast to Speakers!
    icon: mdi:bullhorn
    icon_height: 30px
    tap_action:
      action: call-service
      service: script.send_announcement_to_speakers
    card_mod:
      style: |
        ha-card {
          background: var(--accent-color) !important;
          color: white !important;
          border-radius: 0px 0px 12px 12px !important;
          margin-top: -1px !important;
          box-shadow: none !important;
        }

Works for me and best, JR
And BTW You can omit card_mod etc. and use Your preferred TTS engine and media players of course :slight_smile:

And a small edit: if You want to resume something that was playing on some media player before (sorry, no Spotify :frowning: - do not use anyway) can give this a try:

alias: "Send Announcement to Speakers with Resume"
icon: mdi:volume-high
sequence:
  # 1. Take a snapshot of the current state and volume of the speakers
  - action: scene.create
    data:
      scene_id: speakers_state_before_announcement
      snapshot_entities:
        - media_player.kitchen_mini
        - media_player.restroom_mini

  # 2. Send the text to speakers as an announcement
  - action: media_player.play_media
    target:
      entity_id:
        - media_player.kitchen_mini
        - media_player.restroom_mini
    data:
      media_content_id: >-
        media-source://tts/tts.home_assistant_cloud?message={{ states('input_text.announcement_text') }}
      media_content_type: music
      announce: true

  # 3. Wait for the speaker to finish talking (change seconds if needed)
  - delay: "00:00:05"

  # 4. Restore the exact previous state of the speakers and resume music
  - action: scene.turn_on
    target:
      entity_id: scene.speakers_state_before_announcement

  # 5. Automatically clear the text box after the announcement
  - action: input_text.set_value
    target:
      entity_id: input_text.announcement_text
    data:
      value: ""

Best and happy testing, JR