Presence for 2 people not working and im not sure how to fix it

I have an 2 automations for this and they are pretty basic. Its using the companion app on my phone to detect presence.

One is when myself or my wife arrives, and obviously the other is for when we depart. We dont always arrive and depart together and this is the main problem.

When it was just me on the automation it worked flawlessly FWIW, albeit was only a week. When I added the companion app to my wife’s phone and added her to the automation, things did not go well. If she is home and I am away, the garage door starts to freak out going up and down, etc. Its clear that i dont have the automation set up properly so I was hoping someone here may already have this squared away.

Again, this presense is set up just using the companion app and its location service.

Here is the yaml for it:

description: ""
trigger:
  - platform: state
    entity_id:
      - person.wife
    from: not_home
    to: home
    enabled: true
  - platform: state
    entity_id:
      - person.me
      from: not_home
    to: home
    enabled: true
  - platform: state
    entity_id:
      - input_boolean.dbmf
    from: "off"
    to: "on"
    for:
      hours: 0
      minutes: 0
      seconds: 0
    enabled: false
condition:
  - condition: time
    after: "07:00:00"
    before: "22:00:00"
    weekday:
      - sun
      - mon
      - tue
      - wed
      - thu
      - fri
      - sat
action:
  - service: cover.open_cover
    target:
      entity_id: cover.carport
    data: {}
  - service: lock.unlock
    target:
      entity_id: lock.garage_door_lock
    data:
      code: ""
mode: single```

I was under the impression that triggers use OR rather than AND, so I am not sure why it is trying to react to both of our states,  Im sure I am missing something simple.  Thanks you in advance for any help.

You are right, the triggers are “OR” - so either trigger will activate the automation.
That means the cover will go up when your wife comes home - and it will go up again once you come home (and your wife is already home).

You probably have a problem with your wifes phone geo-location.

When it looses the phones position, it sees your wife not_home - as soon as it gets contact again it will switch her to home and activate the automation again.

What do the traces in the automation say when this happens?

I am guessing you have an automation for when you are both gone?
If yes can you also post it?

Group perhaps and just cut out the complexity?

The add to Frank’s response above…

It is often best not to rely on single source for presence detection. Attaching multiple device trackers to each person entity can dramatically increase the reliability of presence detection. Take a look at the other Device tracker and Presence Detection integrations. If your router has an integration, that is usually a good place to start.

1 Like

I wasn’t able to see at the time as I was at work and just shut down the automation. I will try it again and see what happens. I am noticing her phone kinda sucks compared to mine for geolocation.

Mine did too when I was using a samsung phone. I use a pixel now and it seems to be much better.

I dont have an automation for both home or both away as I kind of thought the two that I had would suffice?

At any rate, I will report back when it happens again. Thank you.

Im not following. Could you elaborate a little more?

Indeed it is, and I have a custom solution that has worked for years when I was using hubitat. Honestly, nothing has matched its dependability ever. I have the python script redone and working in home assistant, but I would like to get this figured out first before added layers of complexity to it.

He means something like this (shamelessly stolen from a similar post on this forum)

group:
  awesome_people:
    name: "Awesome People"
    entities:
      - device_tracker.dad_smith
      - device_tracker.mom_smith

Set your automation to trigger on the state of the group instead of an individual person.
Alternatively, just use the numeric state of your home, which will trigger as soon as the number of detected persons in your home is 1 or above:

mode: single
trigger:
  - platform: numeric_state
    entity_id:
      - zone.home
    for:
      hours: 0
      minutes: 1
      seconds: 0
    above: 0
condition:
  - condition: time
    after: "07:00:00"
    before: "22:00:00"
    weekday:  #I don't think you need this part if it's running every day
      - sun
      - mon
      - tue
      - wed
      - thu
      - fri
      - sat
action:
  - service: cover.open_cover
    target:
      entity_id: cover.carport
    data: {}
  - service: lock.unlock
    target:
      entity_id: lock.garage_door_lock
    data:
      code: ""

oh ok, that looks doable, but I am thinking presence via geofencing isnt going to work with her phone so I will just go back to the python script I run on a raspberry pi zero w. its flawless nearly. the reason i didnt just use it out of the gate is because it didnt work in home assistant like it did in hubitat.

I just need to have the mqtt message it sends trigger an input_boolean and I should be set.

many thanks to everyone!