Tsar
(Christian)
April 11, 2022, 6:06am
1
Hello,
I have a group of booleans. Each boolean gives the status if a person is at home. Now I want to count the people in my house, so I created this template :
- name: number_of_people_home
unit_of_measurement: "pers"
state: "{{ states|selectattr('entity_id','in',state_attr('group.group_my_people','entity_id'))|selectattr('state','eq','on')|list|count }}"
This works fine, but it is not updated when a one person leaves or comes home.
How can I resolve this ?
Tsar
(Christian)
April 11, 2022, 6:23am
3
Found a solution :
- trigger:
- platform: event
event_type: event_template_reloaded
- platform: homeassistant
event: start
- platform: state
entity_id:
- input_boolean.toggle_xxx_is_thuis
- input_boolean.toggle_yyyy_is_thuis
- input_boolean.toggle_zzz_is_thuis
sensor:
- name: number_of_people_home
unit_of_measurement: "pers"
state: "{{ states|selectattr('entity_id','in',state_attr('group.group_my_people','entity_id'))|selectattr('state','eq','on')|list|count }}"
aceindy
(Aceindy)
April 11, 2022, 6:28am
4
Yup, something like that.
(please mark as solved)
koying
(Chris B)
April 11, 2022, 3:28pm
5
Not sure if that’s exactly what you’re looking for, but as of 2022.4, zones like “home” have the number of persons in it as their states.
Welcoming new helpers to the UI, including groups! Helpers for switches with an identity crisis, updates, backups, performance improvements, and more!
1 Like