#Can variables reference each other?

12 messages · Page 1 of 1 (latest)

quaint basin
#

If I have an automation could I do something like

variables:
  foo: 1
  bar: "{{foo + 1}}"

Also does order matter when referencing?

next juniper
#

Hi @quaint basin,
Yes you can and the order does matter.

quaint basin
#

I also think I noticed variables don't work in the triggers?

#

Wonder if this stuff is in the docs. Will look around more closely. I feel like it always seemed tough to find docs on vars

next juniper
#

You can use trigger_vatiables and those are rendered before the trigger.
However limited template come into play then, and you can't do all the jinja things.

quaint basin
#

Ah cool that might actually work for my use case

#

I feel like automation docs are sort of split up cuz they're basically made up of different components? (triggers, actions)

next juniper
#

variables: are rendered after the trigger. trigger_variables before.

hidden comet
quaint basin
#

That looks about right then. I'll admit I didn't look too hard before leaving for the gym 😅

hidden comet
#

It's a bit hidden under the YAML config

#

I only know it exists because it was created for scripts, and when I noticed it was missing for automations I added it