hi this will work? i only want to run this if nobody is home
- alias: Chegar a Casa
initial_state: 'on'
trigger:
- platform: state
entity_id: person.x, person.y
to: home
condition:
- condition: state
entity_id: person.x, person.y
from: 'not_home'
action:
- wait_template: '{{ is_state("binary_sensor.hall_entrada_sensor_porta_42", "on") }}'
- delay: '00:00:05'
- data:
entity_id: media_player.x_s_echo
media_content_id: i'm back
media_content_type: routine
service: media_player.play_media
As I see it, when a person gets home wait for the motion detector to trigger, then announce via media player? Remove the condition and add from not_home to the trigger.
- alias: Chegar a Casa
initial_state: 'on'
trigger:
- platform: state
entity_id: person.x, person.y
to: home
from: not_home
Not sure if it’s what you’re after, this will run if either person comes home.
You could also put all the people in a group and then monitor the state change of the group.
Good to know:
A group will be ‘not_home’ only when all individuals are ‘not_home’, but it will be home as soon/long as one individual comes/is home. This means the state change from not_home to home will only trigger when nobody was home, i.e. the first individual comes home after everybody was gone - and that conveniently works with as many individuals in your group as you like.
group:
humans:
name: People & Devices
entities:
- device_tracker.him
- device_tracker.her
automation:
- alias: Chegar a Casa
initial_state: 'on'
trigger:
- platform: state
entity_id: group.humans
from: 'not_home'
to: 'home'
Hope that works - just made up the code from what I did quite a while ago.
I use with groups and work!
Thanks
1 Like