See below for a small update with the option to save 10 messages to reuse as a TTS message
First I’m not a developer and no specialist, so when my wife asked “create me something that I not only can send predefined messages to the speakers in the house but also something so that I can create easily messages myself” and don’t forget I’m not a technical person and don’t want to be one, so make it simple!!
First request of the wife so I did off course my freaking best
How I built it…
Create a couple of helpers…
1. TTS: input_text.tts (the text field to put the message in)
2. TTS media players: input_select.tts_media_players (the select option for the media players in your house)
3. TTS Media players text: input_text.tts_media_players_text (I created this because I wanted to use normal names for the speakers in the select list (TTS media players) and not the entity id’s, remember keep it simple
4. TTS Taal: input_select.tts_taal (select the language for the message tts)
5 TTS Volume choice: (set the volume of the speaker, use the speaker volume service option 0.*)
Set-up your TTS option in your configuration
- I use: ReversoTTS-HA (GitHub - rt400/ReversoTTS-HA: ReversoTTS component for HomeAssistant) as my main TTS because it has a Belgium voice and Nabu Casa for now has not (can be easily added true HACS: https://hacs.xyz/)
- For the other languages I use the Nabu Casa (Cloud TTS) cloud TTS option
Example reversotts, the Nabu Casa part we handle in the send script
tts:
- platform: reversotts
language: "Sofie-Belgian-Dutch"
pitch: "100"
bitrate: "128k"
STEP 1: we have to create a simple automation that sets the media player value (TTS Media players text) when you select one from the select list (TTS media players)
alias: 'TTS BLANK: mediaplayer select option'
description: ''
trigger:
- platform: state
entity_id: input_select.tts_media_players
condition: []
action:
- choose:
- conditions:
- condition: state
entity_id: input_select.tts_media_players
state: Hub master
sequence:
- service: input_text.set_value
data:
value: media_player.nest_hub_master
target:
entity_id: input_text.tts_media_players_text
- conditions:
- condition: state
entity_id: input_select.tts_media_players
state: Hub woonkamer
sequence:
- service: input_text.set_value
data:
value: media_player.nest_hub_woonkamer
target:
entity_id: input_text.tts_media_players_text
- conditions:
- condition: state
entity_id: input_select.tts_media_players
state: Mini Bureau
sequence:
- service: input_text.set_value
data:
value: media_player.nest_mini_bureau
target:
entity_id: input_text.tts_media_players_text
- conditions:
- condition: state
entity_id: input_select.tts_media_players
state: Michael mini
sequence:
- service: input_text.set_value
data:
value: media_player.nest_mini_michael
target:
entity_id: input_text.tts_media_players_text
- conditions:
- condition: state
entity_id: input_select.tts_media_players
state: Mini wasruimte
sequence:
- service: input_text.set_value
data:
value: media_player.google_mini_wasruimte
entity_id: input_text.tts_media_players_text
- conditions:
- condition: state
entity_id: input_select.tts_media_players
state: Sonos badkamer
sequence:
- service: input_text.set_value
data:
value: media_player.sonos_badkamer
entity_id: input_text.tts_media_players_text
- conditions:
- condition: state
entity_id: input_select.tts_media_players
state: Sonos Bureau
sequence:
- service: input_text.set_value
data:
value: media_player.sonos_bureau
entity_id: input_text.tts_media_players_text
- conditions:
- condition: state
entity_id: input_select.tts_media_players
state: Sonos dressing
sequence:
- service: input_text.set_value
data:
value: media_player.sonos_dressing
entity_id: input_text.tts_media_players_text
- conditions:
- condition: state
entity_id: input_select.tts_media_players
state: Sonos master
sequence:
- service: input_text.set_value
data:
value: media_player.sonos_master
entity_id: input_text.tts_media_players_text
- conditions:
- condition: state
entity_id: input_select.tts_media_players
state: Sonos Michael
sequence:
- service: input_text.set_value
data:
value: media_player.sonos_michael
entity_id: input_text.tts_media_players_text
- conditions:
- condition: state
entity_id: input_select.tts_media_players
state: Sonos woonkamer
sequence:
- service: input_text.set_value
data:
value: media_player.sonos_woonkamer
entity_id: input_text.tts_media_players_text
default: []
mode: single
STEP 2: the script to clear the text and set some default values to the card
alias: 'SCRIPT TTS NOTIFICATION: blank clear'
sequence:
- service: input_text.set_value
data:
value: ''
entity_id: input_text.tts
- service: input_select.select_option
data:
option: Kies media player
entity_id: input_select.tts_media_players
- service: input_select.select_option
data:
option: '0.4'
target:
entity_id: input_select.tts_volume_choice
- service: input_text.set_value
data:
value: ''
entity_id: input_text.tts_media_players_text
- service: input_select.select_option
data:
option: Nederlands
entity_id: input_select.tts_taal
mode: single
STEP 3: Script to send the message to the speaker
alias: 'SCRIPT TTS NOTIFICATION: send the TTS message'
sequence:
- service: media_player.volume_set
data:
entity_id: '{{ states("input_text.tts_media_players_text" ) }}'
volume_level: '{{ states("input_select.tts_volume_choice") }}'
- delay:
hours: 0
minutes: 0
seconds: 1
milliseconds: 0
- choose:
- conditions:
- condition: state
entity_id: input_select.tts_taal
state: Nederlands
sequence:
- service: tts.reversotts_say
data:
cache: false
entity_id: '{{ states("input_text.tts_media_players_text" ) }}'
message: '{{ states("input_text.tts") }}'
- conditions:
- condition: state
entity_id: input_select.tts_taal
state: Engels
sequence:
- service: tts.cloud_say
data:
entity_id: '{{ states("input_text.tts_media_players_text" ) }}'
message: '{{ states("input_text.tts") }}'
language: en-US
options:
gender: female
- conditions:
- condition: state
entity_id: input_select.tts_taal
state: Nederlands cloud vrouw
sequence:
- service: tts.cloud_say
data:
entity_id: '{{ states("input_text.tts_media_players_text" ) }}'
message: '{{ states("input_text.tts") }}'
language: nl-NL
options:
gender: female
default: []
mode: single
STEP 4: Create the Lovelace card
Dutch version:
type: grid
cards:
- type: entities
entities:
- entity: input_select.tts_media_players
- entity: input_select.tts_taal
- entity: input_select.tts_volume_choice
name: Volume media speler
icon: 'mdi:volume-vibrate'
- entity: input_text.tts
name: Wat wil je melden?
tap_action:
action: none
hold_action:
action: none
icon: 'mdi:message-text-outline'
state_color: false
header:
type: picture
image: /local/images/tts.png
tap_action:
action: none
hold_action:
action: none
show_header_toggle: false
- type: markdown
content: >-
<ha-icon
icon="mdi:message-text-outline"></ha-icon> {{
states("input_text.tts") }}
- type: entities
entities:
- entity: script.1613345332186
name: Bericht leeg maken
icon: 'mdi:message-settings-outline'
tap_action:
action: none
hold_action:
action: none
- entity: script.1613743070220
name: Bericht verzenden
icon: 'mdi:message-arrow-right-outline'
tap_action:
action: none
hold_action:
action: none
square: false
columns: 1
English version:
type: grid
cards:
- type: entities
entities:
- entity: input_select.tts_media_players
name: TTS Media player
- entity: input_select.tts_taal
name: TTS language
- entity: input_select.tts_volume_choice
name: Volume media player
icon: 'mdi:volume-vibrate'
- entity: input_text.tts
name: What's your message?
tap_action:
action: none
hold_action:
action: none
icon: 'mdi:message-text-outline'
state_color: false
header:
type: picture
image: /local/images/tts.png
tap_action:
action: none
hold_action:
action: none
show_header_toggle: false
- type: markdown
content: >-
<ha-icon
icon="mdi:message-text-outline"></ha-icon> {{
states("input_text.tts") }}
- type: entities
entities:
- entity: script.1613345332186
name: Clear message
icon: 'mdi:message-settings-outline'
tap_action:
action: none
hold_action:
action: none
- entity: script.1613743070220
name: Send message
icon: 'mdi:message-arrow-right-outline'
tap_action:
action: none
hold_action:
action: none
square: false
columns: 1
Updated version: Create a couple of extra helpers…
TTS Messages chooser: input_select.tts_messages_chooser (select your saved message)
TTS Message 1 to TTS Message 10 (to save the message for future use)
TTS Message text: input_text.tts_message_text (to preview the message and select for use)
STEP 1: automation to preview selected message (input_select.tts_messages_chooser )
alias: 'TTS BLANK: Message selector'
description: ''
trigger:
- platform: state
entity_id: input_select.tts_messages_chooser
condition: []
action:
- choose:
- conditions:
- condition: state
entity_id: input_select.tts_messages_chooser
state: Opgeslagen bericht 1
sequence:
- service: input_text.set_value
data:
value: '{{ states("input_text.tts_message_1") }}'
target:
entity_id: input_text.tts_message_text
- conditions:
- condition: state
entity_id: input_select.tts_messages_chooser
state: Opgeslagen bericht 2
sequence:
- service: input_text.set_value
data:
value: '{{ states("input_text.tts_message_2") }}'
target:
entity_id: input_text.tts_message_text
- conditions:
- condition: state
entity_id: input_select.tts_messages_chooser
state: Opgeslagen bericht 3
sequence:
- service: input_text.set_value
data:
value: '{{ states("input_text.tts_message_3") }}'
target:
entity_id: input_text.tts_message_text
- conditions:
- condition: state
entity_id: input_select.tts_messages_chooser
state: Opgeslagen bericht 4
sequence:
- service: input_text.set_value
data:
value: '{{ states("input_text.tts_message_4") }}'
target:
entity_id: input_text.tts_message_text
- conditions:
- condition: state
entity_id: input_select.tts_messages_chooser
state: Opgeslagen bericht 5
sequence:
- service: input_text.set_value
data:
value: '{{ states("input_text.tts_message_5") }}'
target:
entity_id: input_text.tts_message_text
- conditions:
- condition: state
entity_id: input_select.tts_messages_chooser
state: Opgeslagen bericht 6
sequence:
- service: input_text.set_value
data:
value: '{{ states("input_text.tts_message_6") }}'
target:
entity_id: input_text.tts_message_text
- conditions:
- condition: state
entity_id: input_select.tts_messages_chooser
state: Opgeslagen bericht 7
sequence:
- service: input_text.set_value
data:
value: '{{ states("input_text.tts_message_7") }}'
target:
entity_id: input_text.tts_message_text
- conditions:
- condition: state
entity_id: input_select.tts_messages_chooser
state: Opgeslagen bericht 8
sequence:
- service: input_text.set_value
data:
value: '{{ states("input_text.tts_message_8") }}'
target:
entity_id: input_text.tts_message_text
- conditions:
- condition: state
entity_id: input_select.tts_messages_chooser
state: Opgeslagen bericht 9
sequence:
- service: input_text.set_value
data:
value: '{{ states("input_text.tts_message_9") }}'
target:
entity_id: input_text.tts_message_text
- conditions:
- condition: state
entity_id: input_select.tts_messages_chooser
state: Opgeslagen bericht 10
sequence:
- service: input_text.set_value
data:
value: '{{ states("input_text.tts_message_10") }}'
target:
entity_id: input_text.tts_message_text
default: []
mode: single
STEP 2: automation select (button) the message and forward it to the TTS message field for reuse (input_text.tts)
alias: 'TTS BLANK: Set message text to tts text'
description: ''
trigger: []
condition: []
action:
- choose:
- conditions:
- condition: state
entity_id: input_select.tts_messages_chooser
state: Opgeslagen bericht 1
sequence:
- service: input_text.set_value
data:
value: '{{ states("input_text.tts_message_text") }}'
target:
entity_id: input_text.tts
- conditions:
- condition: state
entity_id: input_select.tts_messages_chooser
state: Opgeslagen bericht 2
sequence:
- service: input_text.set_value
data:
value: '{{ states("input_text.tts_message_text") }}'
target:
entity_id: input_text.tts
- conditions:
- condition: state
entity_id: input_select.tts_messages_chooser
state: Opgeslagen bericht 3
sequence:
- service: input_text.set_value
data:
value: '{{ states("input_text.tts_message_text") }}'
target:
entity_id: input_text.tts
- conditions:
- condition: state
entity_id: input_select.tts_messages_chooser
state: Opgeslagen bericht 4
sequence:
- service: input_text.set_value
data:
value: '{{ states("input_text.tts_message_text") }}'
target:
entity_id: input_text.tts
- conditions:
- condition: state
entity_id: input_select.tts_messages_chooser
state: Opgeslagen bericht 5
sequence:
- service: input_text.set_value
data:
value: '{{ states("input_text.tts_message_text") }}'
target:
entity_id: input_text.tts
- conditions:
- condition: state
entity_id: input_select.tts_messages_chooser
state: Opgeslagen bericht 6
sequence:
- service: input_text.set_value
data:
value: '{{ states("input_text.tts_message_text") }}'
target:
entity_id: input_text.tts
- conditions:
- condition: state
entity_id: input_select.tts_messages_chooser
state: Opgeslagen bericht 7
sequence:
- service: input_text.set_value
data:
value: '{{ states("input_text.tts_message_text") }}'
target:
entity_id: input_text.tts
- conditions:
- condition: state
entity_id: input_select.tts_messages_chooser
state: Opgeslagen bericht 8
sequence:
- service: input_text.set_value
data:
value: '{{ states("input_text.tts_message_text") }}'
target:
entity_id: input_text.tts
- conditions:
- condition: state
entity_id: input_select.tts_messages_chooser
state: Opgeslagen bericht 9
sequence:
- service: input_text.set_value
data:
value: '{{ states("input_text.tts_message_text") }}'
target:
entity_id: input_text.tts
- conditions:
- condition: state
entity_id: input_select.tts_messages_chooser
state: Opgeslagen bericht 10
sequence:
- service: input_text.set_value
data:
value: '{{ states("input_text.tts_message_text") }}'
target:
entity_id: input_text.tts
default: []
mode: single
STEP 3: script to save the message to the selected message field TTS Message 1 to TTS Message 10
alias: 'TTS BLANK: save message'
sequence:
- choose:
- conditions:
- condition: state
entity_id: input_select.tts_messages_chooser
state: Opgeslagen bericht 1
sequence:
- service: input_text.set_value
data:
value: '{{ states("input_text.tts") }}'
target:
entity_id: input_text.tts_message_1
- service: input_select.select_option
target:
entity_id: input_select.tts_messages_chooser
data:
option: Kies een opgeslagen bericht...
- service: input_select.select_option
target:
entity_id: input_select.tts_messages_chooser
data:
option: Opgeslagen bericht 1
- conditions:
- condition: state
entity_id: input_select.tts_messages_chooser
state: Opgeslagen bericht 2
sequence:
- service: input_text.set_value
data:
value: '{{ states("input_text.tts") }}'
target:
entity_id: input_text.tts_message_2
- service: input_select.select_option
target:
entity_id: input_select.tts_messages_chooser
data:
option: Kies een opgeslagen bericht...
- service: input_select.select_option
target:
entity_id: input_select.tts_messages_chooser
data:
option: Opgeslagen bericht 2
- conditions:
- condition: state
entity_id: input_select.tts_messages_chooser
state: Opgeslagen bericht 3
sequence:
- service: input_text.set_value
data:
value: '{{ states("input_text.tts") }}'
target:
entity_id: input_text.tts_message_3
- service: input_select.select_option
target:
entity_id: input_select.tts_messages_chooser
data:
option: Kies een opgeslagen bericht...
- service: input_select.select_option
target:
entity_id: input_select.tts_messages_chooser
data:
option: Opgeslagen bericht 3
- conditions:
- condition: state
entity_id: input_select.tts_messages_chooser
state: Opgeslagen bericht 4
sequence:
- service: input_text.set_value
data:
value: '{{ states("input_text.tts") }}'
target:
entity_id: input_text.tts_message_4
- service: input_select.select_option
target:
entity_id: input_select.tts_messages_chooser
data:
option: Kies een opgeslagen bericht...
- service: input_select.select_option
target:
entity_id: input_select.tts_messages_chooser
data:
option: Opgeslagen bericht 4
- conditions:
- condition: state
entity_id: input_select.tts_messages_chooser
state: Opgeslagen bericht 5
sequence:
- service: input_text.set_value
data:
value: '{{ states("input_text.tts") }}'
target:
entity_id: input_text.tts_message_5
- service: input_select.select_option
target:
entity_id: input_select.tts_messages_chooser
data:
option: Kies een opgeslagen bericht...
- service: input_select.select_option
target:
entity_id: input_select.tts_messages_chooser
data:
option: Opgeslagen bericht 5
- conditions:
- condition: state
entity_id: input_select.tts_messages_chooser
state: Opgeslagen bericht 6
sequence:
- service: input_text.set_value
data:
value: '{{ states("input_text.tts") }}'
target:
entity_id: input_text.tts_message_6
- service: input_select.select_option
target:
entity_id: input_select.tts_messages_chooser
data:
option: Kies een opgeslagen bericht...
- service: input_select.select_option
target:
entity_id: input_select.tts_messages_chooser
data:
option: Opgeslagen bericht 6
- conditions:
- condition: state
entity_id: input_select.tts_messages_chooser
state: Opgeslagen bericht 7
sequence:
- service: input_text.set_value
data:
value: '{{ states("input_text.tts") }}'
target:
entity_id: input_text.tts_message_7
- service: input_select.select_option
target:
entity_id: input_select.tts_messages_chooser
data:
option: Kies een opgeslagen bericht...
- service: input_select.select_option
target:
entity_id: input_select.tts_messages_chooser
data:
option: Opgeslagen bericht 7
- conditions:
- condition: state
entity_id: input_select.tts_messages_chooser
state: Opgeslagen bericht 8
sequence:
- service: input_text.set_value
data:
value: '{{ states("input_text.tts") }}'
target:
entity_id: input_text.tts_message_8
- service: input_select.select_option
target:
entity_id: input_select.tts_messages_chooser
data:
option: Kies een opgeslagen bericht...
- service: input_select.select_option
target:
entity_id: input_select.tts_messages_chooser
data:
option: Opgeslagen bericht 8
- conditions:
- condition: state
entity_id: input_select.tts_messages_chooser
state: Opgeslagen bericht 9
sequence:
- service: input_text.set_value
data:
value: '{{ states("input_text.tts") }}'
target:
entity_id: input_text.tts_message_9
- service: input_select.select_option
target:
entity_id: input_select.tts_messages_chooser
data:
option: Kies een opgeslagen bericht...
- service: input_select.select_option
target:
entity_id: input_select.tts_messages_chooser
data:
option: Opgeslagen bericht 9
- conditions:
- condition: state
entity_id: input_select.tts_messages_chooser
state: Opgeslagen bericht 10
sequence:
- service: input_text.set_value
data:
value: '{{ states("input_text.tts") }}'
target:
entity_id: input_text.tts_message_10
- service: input_select.select_option
target:
entity_id: input_select.tts_messages_chooser
data:
option: Kies een opgeslagen bericht...
- service: input_select.select_option
target:
entity_id: input_select.tts_messages_chooser
data:
option: Opgeslagen bericht 10
default: []
mode: single
STEP 4: New script to clear the form with the extra options
alias: 'SCRIPT TTS BLANK: clear form'
sequence:
- service: input_text.set_value
data:
value: ''
entity_id: input_text.tts
- service: input_select.select_option
data:
option: Kies media player
entity_id: input_select.tts_media_players
- service: input_select.select_option
data:
option: '0.4'
target:
entity_id: input_select.tts_volume_choice
- service: input_text.set_value
data:
value: ''
entity_id: input_text.tts_media_players_text
- service: input_select.select_option
data:
option: Nederlands
entity_id: input_select.tts_taal
- service: input_text.set_value
data:
value: ''
target:
entity_id: input_text.tts_message_text
- service: input_select.select_option
target:
entity_id: input_select.tts_messages_chooser
data:
option: Kies een opgeslagen bericht...
mode: single
New Lovelace cards:
Dutch version:
type: grid
cards:
- type: entities
entities:
- entity: input_select.tts_media_players
name: TTS Media speler
- entity: input_select.tts_taal
name: TTS taal
- entity: input_select.tts_volume_choice
name: Volume media speler
icon: 'mdi:volume-vibrate'
- entity: input_text.tts
name: Wat is het bericht?
tap_action:
action: none
hold_action:
action: none
icon: 'mdi:message-text-outline'
state_color: false
header:
type: picture
image: /local/images/tts.png
tap_action:
action: none
hold_action:
action: none
show_header_toggle: false
- type: markdown
content: >-
<ha-icon
icon="mdi:message-text-outline"></ha-icon> {{
states("input_text.tts") }}
- type: entities
entities:
- entity: input_select.tts_messages_chooser
name: Selecteer een opgeslagen bericht...
- type: markdown
content: >-
<ha-icon
icon="mdi:message-text-outline"></ha-icon> {{
states("input_text.tts_message_text") }}
- type: grid
cards:
- type: button
tap_action:
action: toggle
entity: script.1615819007412
icon: 'mdi:text-box-search-outline'
name: Selecteer
- type: button
tap_action:
action: toggle
entity: script.1615819315672
icon: 'mdi:content-save-move-outline'
name: Opslaan
- type: button
tap_action:
action: toggle
entity: script.1613345332186
icon: 'mdi:text-box-remove-outline'
name: Leeg
- type: button
tap_action:
action: toggle
entity: script.1613743070220
icon: 'mdi:send'
name: Verstuur
square: false
columns: 4
square: false
columns: 1
English version:
type: grid
cards:
- type: entities
entities:
- entity: input_select.tts_media_players
name: TTS Media player
- entity: input_select.tts_taal
name: TTS language
- entity: input_select.tts_volume_choice
name: Volume media player
icon: 'mdi:volume-vibrate'
- entity: input_text.tts
name: What's your message?
tap_action:
action: none
hold_action:
action: none
icon: 'mdi:message-text-outline'
state_color: false
header:
type: picture
image: /local/images/tts.png
tap_action:
action: none
hold_action:
action: none
show_header_toggle: false
- type: markdown
content: >-
<ha-icon
icon="mdi:message-text-outline"></ha-icon> {{
states("input_text.tts") }}
- type: entities
entities:
- entity: input_select.tts_messages_chooser
name: Choose a saved message...
- type: markdown
content: >-
<ha-icon
icon="mdi:message-text-outline"></ha-icon> {{
states("input_text.tts_message_text") }}
- type: grid
cards:
- type: button
tap_action:
action: toggle
entity: script.1615819007412
icon: 'mdi:text-box-search-outline'
name: Select
- type: button
tap_action:
action: toggle
entity: script.1615819315672
name: Save
icon: 'mdi:content-save-move-outline'
- type: button
tap_action:
action: toggle
entity: script.1613345332186
icon: 'mdi:text-box-remove-outline'
name: Empty
- type: button
tap_action:
action: toggle
entity: script.1613743070220
icon: 'mdi:send'
name: Send
square: false
columns: 4
square: false
columns: 1
That’s it, can be probably a lot simpler, better but hey it works fine, and most important the wife loves it