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 }}
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.
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 }}"