Hi there!
I have this automation that sometimes triggers even though it shouldn’t. Probably, sometimes, phone give wrongs info to HA and my lights turn off even if I’m home.
The automation is this one:
alias: Set Away Based on Device States
description: Aggiorna il contatore su Home in base allo stato combinato dei dispositivi
triggers:
trigger: state
entity_id:
person.manuel
person.noemi
to: null
from: home
conditions:
condition: state
entity_id: person.noemi
state: not_home
condition: or
conditions:
condition: state
entity_id: person.manuel
state: not_home
actions:
I use the counter Away/home to trigger other automations, but it seems it’s not reliable.
I’m thinking to add a delay of a couple of minutes before it checks if me or Noemi are actually at home, hoping that in the meanwhile the state home/not_home is actually true.
Is it possible to add a delay before the “and if”?
Do you have better ideas to implement this?
Thanks guys
Do you want your condition to run if neither of you are home, or only if both of you are not home? The way you have included the or condition is having no effect, because it only applies to conditions nested inside of it. You only have one condition nested inside, so it’s the same as if the or wasn’t there at all.
It seems like it would be better to address the trigger…
If your goal with is have the trigger fire when everyone has left home, you should use a trigger based on the zone.home entity. A zone entity’s state reflects the number of person entities that are currently located in that zone.
You can add a duration to some triggers so that they are required to be true for a given amount of time before they fire. This will, in effect, "add a delay before the ‘and if’ ". The configuration variable for is used to set the duration.
Combining those for a better trigger would be:
triggers:
- alias: When all people have left the zone and stayed gone for 5 minutes
trigger: numeric_state
entity_id: zone.home
below: 1
for: "00:05:00"