Is there a way to use the values of one data_template’s variables in another template within the same entity?
Here’s an example (that doesn’t work):
(a script)
random_test:
alias: Random Test
sequence:
- service: persistent_notification.create
data_template:
message: >
{% set items =
{
"title one":"value 1",
"title two":"value 2",
"title three":"value 3",
"title four":"value 4",
}
%}
{% set index = items | list | random %}
The value is {{items[index]}}
title: The title is {{index}}
In this example, the message correctly gets a random element from “items”. But I’d like to use the index in the title for the persistent note.
Is there a way, within templates, for me to make that kind of scope work?