Hello everyone,
I’ve been trying on the templates for a few days.
I have already managed a lot with it, but I fail because of the following task:
I try to turn on the light automatically when a person arrives at home. However, the condition should be that this only happens with the first person.
As a condition, I wrote the following template:
condition:
- condition: template
value_template: |-
{% set personCount = cycler(0, 1, 2) %}
{% for person in states.person if person.state == 'home' %}
{% if personCount.current < 2 %}
{{ personCount.next() }}
{% endif %}
{% endfor %}
{% if personCount.current <= 1 %}
{{ true }}
{% else %}
{{ false }}
{% endif %}
Now ‘true’ appears in the template editor, which should consider the condition to be met.
However, this template does not continue in automation and automation ends.
Did I miss something? Or is there a function that I have not seen in the references?
Thank you very much for your help!