Trigger to set when there is 1 person home

I am using the Homekit presence detection and now would like to create a trigger where when there is only 1 person presence at home, do this. I believe we need to create a group? This is my group.

  - platform: template
    sensors:
      people_home:
        value_template: >-
           {{ is_state('input_boolean.duc_home', 'on')
                 or is_state('input_boolean.eri_home', 'on')
                 or is_state('input_boolean.shion_home', 'on') }}

I tried using this code, but the integer always set to zero (0).

{{ states('binary_sensor.people_home') | int == 1 }}

That’s not a group. That’s a binary template sensor, or template sensor (depending on where you put it).

Do you want a numeric count of the number of people home so you can trigger an automation when there is only one?

Or do you want a sensor / group that is true / home if one or more people are home?

Yes, it is a binary_sensor and is placed in the groups.yaml.

No, I am looking for a numeric number of 1 (1 person in the home left) to trigger an action.
If there are 3 in the home, the automation does nothing. When any 2 given have left the house, I want the automation to do something.

Well you won’t get a number in a binary sensor. It’s state is either true or false.

If you want a count of the number of people home you have to use a sensor, not a binary sensor.

Try this:

  1. Put your input_booleans in a group:
group:
  people_home:
  entities:
    - input_boolean.duc_home
    - input_boolean.eri_home
    - input_boolean.shion_home
  1. Define this sensor:
sensor:
  - platform: template
    sensors:
      people_home:
        friendly_name: Number of people home
        unit_of_measurement: 'ppl'
        value_template: "{{ states|selectattr('entity_id','in',state_attr('group.people_home','entity_id'))|selectattr('state','eq','on')|list|count }}"