I get how to create the basic automation but what I want to do is use it to greet whoever opens the door. This is easy for one entity but if there are 2 who open the door I don’t see how to do it. Tried creating a sensor that had both device trackers in it but this would immediately break if only 1 person comes home.
I’ve tried finding info but it seems so scarce and spread out I would have thought someone would have done this before
When a zone changes it updates state to count the person objects in zone. That person object should also switch to home from not_home (state change)
You can look back at the person object(s) state collect them on a template and sort by last changed and see if it/they changed within the last X minutes and make an assumption on person and announce.
I have a group that is updated on the fly as people enter the house. I then use a bit of Jinja to extract the names of the people who have come home and use those in my welcome greeting.
message: >
{% set arriving = expand('group.arriving') %} {% set people =
arriving | map(attribute='name') | join(' and ') %} {% set count
= arriving | count %}
{% if count == 1 %}
{% set is_are = 'is' %}
{% set has_have = 'has' %}
{% else %}
{% set is_are = 'are' %}
{% set has_have = 'have' %}
{% endif %}
{%- macro greeting_sentence(person, is_are, has_have) -%}
{{ [ person ~ ' ' ~ has_have ~ ' arrived.',
'My sensors are picking up the presence of additional humans — ' ~ person ~ ' ' ~ has_have ~ ' been identified as home.',
'Guess who is in the house? ' ~ person ~ ' ' ~ is_are ~ '!',
'I sense a disturbance in the Force — ' ~ person ~ ' must be back!',
person ~ ' ' ~ is_are ~ ' now in the house.',
person ~ ' ' ~ is_are ~ ' now here. Welcome home!',
'Just a quick announcement: ' ~ person ~ ' ' ~ has_have ~ ' arrived!',
person ~ ' ' ~ has_have ~ ' finally made it home.'
] | random }}
{%- endmacro -%}
{{ greeting_sentence(people, is_are, has_have) }}
Wait a couple of minutes then clear the group with