I have automations that should send an alert if my wife and I are both not home, so they have a condition:
condition:
condition:
- condition: and
conditions:
- condition: not
conditions:
- condition: state
entity_id: person.myself
state: home
- condition: not
conditions:
- condition: state
entity_id: person.my_wife
state: home
I have a markdown card on lovelace to show our states:
Myself: {{ states('person.myself') }}
My Wife: {{ states('person.my_wife') }}
Currently it displays: Myself: not_home My Wife: home
The expectation is that the automation should not perform the action (raise an alert) unless both of us are not ‘home’, yet action is always taken when it is triggered. No change in behavior when I put home in quotes in the condition (‘home’).
This will work as long as you don’t have other zones defined:
condition:
- condition: state
entity_id: person.myself
state: not_home
- condition: state
entity_id: person.my_wife
state: not_home
If you do have other zones, you will have to use:
condition:
- condition: not
conditions:
- condition: state
entity_id: person.myself
state: home
- condition: state
entity_id: person.my_wife
state: home
I’ve simplified it as conditions are AND by default. This does not have to be declared.
Just tried the condition change, double checked the indentation levels- it’s identical to the second option you provided but the action still executes when triggered.
Triggering manually skips all conditions and goes straight to the actions. There’s a trigger automation service you can use in the developer tools services menu where you can specify that the conditions not be skipped.
And at least one you is not home and you have this?
condition:
- condition: not
conditions:
- condition: state
entity_id: person.myself
state: home
- condition: state
entity_id: person.my_wife
state: home
Hang on. I might have the logic wrong. When do you want the alert?
I want it to alert only when both of us are not home and the trigger fires, otherwise it should be ignored (as is current state because one of us is home).
So that’s really strange. Can you post your conditions please?
You could try this:
condition:
- condition: not
conditions:
- condition: state
entity_id: person.myself
state: home
- condition: not
conditions:
- condition: state
entity_id: person.my_wife
state: home
- id: '1583167744310'
alias: Front Door Opened
description: ''
trigger:
- entity_id: binary_sensor.front_door
from: 'off'
platform: state
to: 'on'
condition:
- condition: not
conditions:
- condition: state
entity_id: person.myself_thomas
state: 'home'
- condition: state
entity_id: person.my_wife_thomas
state: 'home'
action:
- data:
message: Front Door Opened
data:
priority: 2
retry: 1800
expire: 3600
service: notify.house_hassio
I must apologize- in the snippets I posted, I changed our actual names to ‘myself’ and ‘my_wife’- it turns out that in the markdown card I was using our correct real ‘person’ names, but in the automation I was using an older version of them that is slightly different. Correcting that appears to have fixed the issue.