I am trying to have some config files in custom_template which I intend to use in several scripts. However I can not figure out the syntax. This is an example with user data and a notify script
My sendmessage.yaml should look something like this
{% from 'people.jinja' import people %}
sendmessage:
fields:
username:
description: "Username of recipient"
example: "alice"
message:
description: "Content of message"
example: "Hello World"
sequence:
- variables:
id: {{ people[username].messengerid }}
- action: notify.threema
data:
target: "{{ id }}"
title: "Sent to {{ id }}"
message: message
This does not work as I can not figure out where to put {% from … import %}. I tried a bunch of places, but either the line is ignored or invalid. Looking at the templating documentation did not resolve this for me.
I appreciate your advice
I spent several hours on this and you solved it in a minute. Guess I still have a lot to learn.
Thanks a million! Will test this and then mark it as resolved
I have an additional question. As variables is a dictionary and id can only be set if people has been evaluated before, is this guaranteed to work in the foreseeable future?
I am asking because while lists are sequences, dictionaries are not. This may be different for the parser, though.
No, but it’s an ordered dictionary so it’s extremely unlikely to change. I have ~7 year old automations that rely on this and it hasn’t changed in that 7 years.
I just started Brave which opened the search page prefilled with my question about this topic. Today it responded with an AI generated answer that is obviously based on this thread.
That was quick