0

I have a simple TTS application that should respond with one of a few possible sentences after commanding the lights to turn on or off (trigger.event.data.state).

Unfortunately it currently reads literally "turning left curly bracket left curly bracket trigger dot event dot data dot state right curly bracket right curley bracket".

payload: '{{ ["ok", "turning \"{{ trigger.event.data.state }}\" "] | random }}'

I do need the outer ' ' quotes for home assistant. I also seem to need the " " quotes for the individual elements in the array.

How can I have a third level of quotes to get the trigger.event value in, so it reads "turning on" or "turning off" depending on the event?

I tried '' "" \" /", +, &, all sort of things to stitch that sentence together.

Any ideas?

Beezle-Bug
  • 167
  • 5
  • 13

1 Answers1

0

Use a block scalar:

payload: >-
  '{{ ["ok", "turning \"{{ trigger.event.data.state }}\" "] | random }}'

> starts a folded block scalar. All subsequent lines that are more indented are parsed literally without processing any special characters. Multiple lines are concatenated via a space character (unless separated with empty lines, which generate a newline character). The - modifier causes the final newline character of the last line to be stripped away (rather than being preserved, which is the default behavior).

flyx
  • 35,506
  • 7
  • 89
  • 126
  • Thanks for the quick answer. Probably would work for YAML, but rhasspy does not interpret it correctly unfortunately. I tried replacing " with ' and vice versa, without the desired result. – Beezle-Bug May 03 '20 at 09:31