Beginner : Use variables in script

Hi all!
I’m a new user of home assistant and i’m trynig to use variables in script without success for now. I don’t really understand why, probably a simple syntax problem but i need you help to find where.

My calling script:

service: script.turn_on
target:
  entity_id: script.tts_google_home
data:
  variables:
    messagetxt: test message

The script receiving the variable:

service: tts.speak
data:
  cache: true
  media_player_entity_id: media_player.salle_a_manger
  message: {{ messagetxt }}
  language: fr
target:
  entity_id: tts.google_en_com

The receiving script seams to receive null value.

Could you explain me what i’m doing wrong?
Thanks in advance

Quote your single line templates:

message: "{{ messagetxt }}"

Great! it works as intended.I still need need some training regarding Yaml syntax. :smiley:

Many thanks for your help Tom!

1 Like