Templating help with if/or

Hi, today I have a template that is used to control if the alarm should be armed or not, it is based on if we are home or not, untill it has only been the who of us, me and my wife. But now I need to adapt it to my kid and I seem to run into issues, se code below:

# Alarm sensor true if all are away
  - platform: template
        friendly_name: "away"
        value_template: >-
          {% if is_state('person.1', 'home')
             or is_state('person.2', 'home')       
             or is_state('person.3', 'home')%}
          {% else %}
          {% endif %}

It seems the “if” statement does not consider the third case, only two are allowed, am I missing something?

It will (or at least should) consider the third case and you are allowed as many as you want, remembering that the template will render false on the first if/or in the list that is true.

You could of course simply create a group which would achieve the same thing:

  name: away
  icon: mdi:home
    - person.1
    - person.2
    - person.3