Jinja gurus - help needed please

Hi all

Need some help with jinja.

I have an automation that has been turned off. so I get the status using:

{{ is_state("automation.test_automation", "off") }} - This returns the value of TRUE.

Now using that same logic I want to turn that automation ON, how can I do that?

I tried these:

{% if (is_state("automation.test_automation", "off")) -%} automation.turn_on {%- endif %}

or

{% if (is_state("automation.test_automation", "off")) -%} automation.turn_on.test_automation {%- endif %}

can I execute this from developers menu?

Thank you for your help.

Hi,
jinja is (abstract spoken) a template engine, which renders a string from input data. Its not a programming or script language that can be used to execute something.

So, what do you need that for? probably there is another way.

Hi
Thanks.
I want to create a template that gets the status of the automation and if that automation is OFF, then turn it ON.

For some reason, I associated Templates with Jinja and I take your point.

For your purpose you can create an automation.

So, to clarify, you want to create an automation that you want to take the action to turn on another automation as soon as that other automation turns off? Or is there something else you want to trigger the automation with?

Notice the italicized bits for hints.

finity,

I have number of Lights automations, those are triggered using “Time Patterns” To stop those automations, I turn them off about 22:00.
At midnight I want to have an automation or script that checks the status of each automation, if it is turned off then turn it on
I am checking the status using:

{{ is_state("automation.test_automation", "off") }}

and then I want to turn the automation ON or do nothing based on the answer above.

Why don’t you just create an automation that turn every automation on at midnight.
Every automation that is off will turn on and every automation that is on stays on?

Hi

Yes, I can do that.

Point here was to learn something new and learn more about Jinja, Templating etc. I asked for help to extend my knowledge a lit bit, but instead I am being judged. ( Notice the italicized bits for hints)

Nobody is judging you.

What you asked for wasn’t help with a template. you already had the template to check the status of the automation. The question was specifically about creating a way to turn on an automation that was turned off.

For that you need another automation. Instead of just coming out and saying it and telling you how to do it I tried to lead you to the answer. I guess I could have added a smiley to clarify that my intent was more light hearted than you took it.

Besides that you didn’t really didn’t give us much to go on except some vague reference to a template that you were trying to work on in the dev tools.

So are you asking for help with the automation or are you asking for help with the template?

Hi finity

Sorry, I didn’t explain myself properly.
I need a help with templating and/or automation. As I said earlier, this exercise is to broaden the knowledge as to how to simplify some of the automations I have.
The template I have that checks the status of an entity, if it is ON or OFF. But I don’t know what to do with that answer. How do I go about changing a state of that entity? I tried these 2 things but that is not working:
{% if (is_state("automation.test_automation", "off")) -%} automation.turn_on {%- endif %}

or

{% if (is_state("automation.test_automation", "off")) -%} automation.turn_on.test_automation {%- endif %}
how do I correct this? so it turns the automation ON? The “automation can be anything”, it could be a light or a switch etc.