Lovelace Voice Card: Text-to-Speech from Dashboard

I’ve just reworked my code for announcing messages, and I thought I’d share it. There are blueprints available for this functionality, but I find my approach much cleaner and more streamlined. Let me know if you have any thoughts!


Home Assistant: Announce Messages with Google Home

This guide helps you set up a feature in Home Assistant where:

  1. A user types a message into a text input field.
  2. The message is announced on a Google Home speaker when the “Send” button is pressed.
  3. After the message is announced, the input field resets to blank.

Step 1: Configure the Input Field

Create a text input for users to enter messages.

  1. Open your configuration.yaml file or use the Helpers UI in Home Assistant.

  2. Add the following configuration:

    input_text:
      message_to_bedroom:
        name: What You Got to Say?
        initial: ""
        max: 255
    
  3. Restart Home Assistant to apply the changes.


Step 2: Create the Script

The script will:

  • Announce the entered message using TTS.
  • Reset the input field after sending.
  1. Go to Settings > Automations & Scenes > Scripts.

  2. Create a new script and paste the following YAML:

    alias: Announce TTS Message
    description: Announce a typed message to the bedroom Google Home speaker
    mode: single
    sequence:
      - service: tts.cloud_say
        data:
          entity_id: media_player.YOURS
          message: "{{ states('input_text.message_to_bedroom') }}"
      - service: input_text.set_value
        target:
          entity_id: input_text.message_to_bedroom
        data:
          value: ""
    
  3. Save the script.


Step 3: Add the Lovelace Card

Create a card with:

  • A text input field for entering the message.
  • A “Send” button to trigger the script.
  1. Edit your Lovelace dashboard.

  2. Add a Manual Card and use the following configuration:

    type: horizontal-stack
    cards:
      - type: entities
        entities:
          - entity: input_text.message_to_bedroom
            name: What You Got to Say?
            icon: mdi:chat
      - type: custom:button-card
        icon: hass:send
        show_icon: true
        show_name: false
        styles:
          card:
            - height: 90px
            - width: 90px
        tap_action:
          action: call-service
          service: script.turn_on
          service_data:
            entity_id: script.announce_tts_message
    
  3. Save the card.


Step 4: Test the Setup

  1. Open your dashboard.
  2. Enter a message in the text field (e.g., “Wake Up Time!”).
  3. Press the Send button.
  4. The message should:
    • Be announced on the Google Home speaker.
    • Reset the text field to blank.
6 Likes

Was looking for something exactly like this. Thanks!

1 Like

Just wanted to share my gratitude hahaha, this is perfect! The wife is happy that she can send me a message when I’m in the garage again. Migrating from Wyze to ubiquity camera’s i did not get 2 way audio camera’s so she said that was missing. Life saver right here!

For anyone that wants to do this entirely locally and open source, I’ve modified the script to use the Piper integration, which you will have to add to your home assistant if you have not already. Its also included in the Wyoming Protocol Integration.

intercom_script:
  alias: Intercom Custom Text - Default Female
  description: Says whatever text is in input helper
  mode: single
  sequence:
    - action: tts.speak
      data:
        cache: true
        media_player_entity_id: media_player.YOURS
        message: "{{ states('input_text.intercom_text') }}"
        options:
          voice: "en_US-hfc_female-medium"
      target:
        entity_id: tts.piper
    - delay:
        hours: 0
        minutes: 0
        seconds: 15
        milliseconds: 0
    - action: media_player.clear_playlist
      metadata: {}
      data: {}
      target:
        entity_id: media_player.YOURS

There are several voices in piper to choose from, just replace it in the “voice:” line.

The last two steps in my script (delay and clear playlist) might not be necessary for you, but my media players will repeat all the previous inputs if I don’t clear its playlist every time.

Thanks to the original author for giving me a jumpstart on this project!

2 Likes

I picked up hass voice, i will have a look at this. Thanks!

Isn’t easier just to use the Google Home broadcast feature?
I guess this is useful if the other person doesn’t have their phone with them or you can’t speak for whatever reason.

I might do this anyway as an option I guess, I don’t think it will get much use though. If I do, I will add an input_select helper dropdown for the destination media player.

I’m sure assist will do this one day though! Probably before I get around to it myself :smiley: