I’m trying query the state of two trackers (my wife’s mobile phone, and mine) and ONLY display notifications for specific devices when both are not_home. Here is what I currently do have. Unfortunately, I made a mistake somewhere as HA tells me "incorrect type. Expected “object”
automation:
- alias: "Change Home Status to Away based on GPS"
trigger:
platform: state
entity_id: device_tracker.cel_stelar_2, device_tracker.alf
condition:
condition: and
conditions:
- condition: state
entity_id: device_tracker.cel_stelar_2
state: "not_home"
- condition: state
entity_id: device_tracker.alf
state: "not_home"
action:
- service: state.set
entity_id: zone.home
data:
state: 0
attributes:
friendly_name: "Away"
- service: binary_sensor.turn_on
entity_id: binary_sensor.0x00124b00251c19b6_contact
- service: binary_sensor.turn_on
entity_id: binary_sensor.0x00124b0028944398_contact
- alias: "Change Home Status to Home based on GPS"
trigger:
platform: state
entity_id: device_tracker.cel_stelar_2, device_tracker.alf
condition:
condition: or
conditions:
- condition: state
entity_id: device_tracker.cel_stelar_2
state: "home"
- condition: state
entity_id: device_tracker.alf
state: "home"
action:
- service: state.set
entity_id: zone.home
data:
state: 1
attributes:
friendly_name: "Home"
- service: binary_sensor.turn_off
entity_id: binary_sensor.0x00124b00251c19b6_contact
- service: binary_sensor.turn_off
entity_id: binary_sensor.0x00124b0028944398_contact
Anyone has an idea of what I’m doing wrong ? I really would like to only get notifications of my cameras and door sensors once we are both out of the house.
Why are you setting the zone.home state? That should work by itself if you have set up Person objects. Zone - Home Assistant
What are the binary_sensor entities, and why are you trying to set their values? Unless they are provided by an integration that adds the binary_sensor.turn_on etc services, you’re trying to call a non-existent service.
If you’re treating them as “flags”, use input_boolean entities instead, but I guess these are door sensors of some sort?
So in short, my wife and myself are running the home assistant companion app (which seem to update the gps state more often that the icloud integration).
I have several door sensors (sonoff zigbee) connected though Z2M, as well as several EZVIZ cameras.
Main idea is to say that when entities :
device_tracker.cel_stelar_2 AND device_tracker.alf are away, THEN and only THEN start getting notifications for the door sensors and cameras.
It’s pretty silly to receive door sensor notifications each time we open the front door or the garden door and I’d like to only get a notification about this when we are actually out of home.
So in short, when these two people are out, enable notifications for this and that entities status changes :
All you need to do is use a condition in your automations that notify you. A condition that either you or your wife are not home. You don’t need an automation. You add that condition to whatever is going to be notifying you.
condition:
condition: and
conditions:
- condition: state
entity_id: device_tracker.cel_stelar_2
state: "not_home"
- condition: state
entity_id: device_tracker.alf
state: "not_home"
Just put that condition in the automation that will ultimately be notifying you.
If you set up Persons aligned to your device trackers, zone.home will have a state representing the number of people at home (docs), so you could use the even simpler:
condition:
- condition: state
entity_id: zone.home
state: "0"
You have to create the automation that notifies you first. Have you created any automations that notify you? If the answer is no, then you need to understand that you aren’t going to get any notifications until you do that. So it’s a moot point until you create an automation.