Stuck on some conditional rendering if/else in automation

Hey Folks,

So really struggling with some pretty strait forward templating in an automation, wondering if anyone can spot the obvious error?

All I’m trying to do is check a load of input_boolean are off, if so turn off another input_boolean, with an else that turns off a different one, simples, apparently not . .

Here’s the config file.

- id: '1643027728920'
  alias: Day/Away Presence
  description: ''
  trigger:
  - platform: state
    entity_id: input_boolean.gareth
  - platform: state
    entity_id: input_boolean.kate
  - platform: state
    entity_id: input_boolean.freddie
  - platform: state
    entity_id: input_boolean.guest
  condition: []
  action:
    - data_template:
        entity_id: >
          {% if is_state('input_boolean.gareth', 'off') && is_state('input_boolean.kate', 'off') && is_state('input_boolean.freddie', 'off') && is_state('input_boolean.guest', 'off')%}
          input_boolean.away
          {% else %}
          input_boolean.day
          {% endif %}
      service: input_boolean.turn_on
  mode: single

Thanks in advance!

Literally posted this and realised I was being an idiot, too long in other languages and using the wrong comparison operators . . . .

- id: '1643027728920'
  alias: Day/Away Presence
  description: ''
  trigger:
  - platform: state
    entity_id: input_boolean.gareth
  - platform: state
    entity_id: input_boolean.kate
  - platform: state
    entity_id: input_boolean.freddie
  - platform: state
    entity_id: input_boolean.guest
  condition: []
  action:
  - service: input_boolean.turn_on
    target:
      entity_id: >
        {% if is_state('input_boolean.gareth', 'off') and is_state('input_boolean.kate', 'off') and is_state('input_boolean.freddie', 'off') and is_state('input_boolean.guest', 'off')%}
        input_boolean.away
        {% else %}
        input_boolean.day
        {% endif %}
  mode: single

An alternative is create a group containing the four input_booleans. When the group’s state is off it means all four input_booleans are off (conversely if the group’s state is on it means at least one of its members, not necessarily all, is on).

- id: '1643027728920'
  alias: Day/Away Presence
  description: ''
  trigger:
  - platform: state
    entity_id: group.people
  condition: []
  action:
  - service: input_boolean.turn_on
    target:
      entity_id: "input_boolean.{{ 'away' if trigger.to_state.state == 'off' else 'day' }}"
  mode: single

Oh that’s nice, and much neater, thanks!