I don't understand why this automation is not working

In the automation below when I leave my home zone, even though jane and bernie_iii are not home, the away part does not work. Essentially, I have for conditions:

if triggered by Away
if bernie is Away
if jane is Away
if bernie_iii is Away

I only want to enable the security alarm when all three of us are away. I looked at the trace and these conditions did not seem to execute at all. Can someone tell me what the problem is here?

-Thanks

alias: Geolocation NFC
description: ""
triggers:
  - trigger: state
    entity_id:
      - person.bernie
      - person.jane
      - person.bernie_iii
    to:
      - home
    id: Home
  - trigger: state
    entity_id:
      - person.bernie
      - person.jane
      - person.bernie_iii
    to:
      - not_home
    id: Away
conditions: []
actions:
  - choose:
      - conditions:
          - condition: trigger
            id:
              - Home
        sequence:
          - action: input_boolean.turn_off
            metadata: {}
            target:
              entity_id: input_boolean.security_alarm_switch
            data: {}
          - action: input_boolean.turn_off
            metadata: {}
            data: {}
            target:
              entity_id: input_boolean.doorbell
            enabled: true
          - action: input_boolean.turn_off
            metadata: {}
            target:
              entity_id: input_boolean.front_camera_switch
            data: {}
          - delay:
              hours: 0
              minutes: 5
              seconds: 0
              milliseconds: 0
            enabled: true
          - action: input_boolean.turn_on
            metadata: {}
            data: {}
            target:
              entity_id: input_boolean.doorbell
            enabled: true
          - action: input_boolean.turn_on
            metadata: {}
            target:
              entity_id: input_boolean.front_camera_switch
            data: {}
      - conditions:
          - condition: trigger
            id:
              - Away
          - condition: state
            entity_id: person.bernie
            state:
              - not_home
          - condition: state
            entity_id: person.jane
            state:
              - not_home
          - condition: state
            entity_id: person.bernie_iii
            state:
              - not_home
        sequence:
          - action: input_boolean.turn_on
            metadata: {}
            target:
              entity_id: input_boolean.security_alarm_switch
            data: {}
mode: single

Did you see an actual trigger in the trace?
And what does it say at the choose option?

Step details will tell you what didnt work

For example:

Here’s the away trace. It just seemed to bypass everything:

Are you clicking the “test” button? If yes, test only runs actions and therefore there are no triggers. Meaning the conditions will fail.

No test, this was actually when I left home this morning (And my wife and kid had left). See my trace above it just seemed to bypass everything.

download the trace and post it here.

I can’t, it contains personal information like our full names. I edited the names in the script I posted above.

Then we can’t really tell you why it didn’t run. If you want, you can dm me the trace.

I changed the names in the trace output. I was going to upload the file but I don’t see how to do that so I pasted it below.

{
  "trace": {
    "last_step": "action/0/choose/1/conditions/3/entity_id/0",
    "run_id": "84cfa173c42d5b68a8350635183f0399",
    "state": "stopped",
    "script_execution": "finished",
    "timestamp": {
      "start": "2026-04-15T13:32:24.911354+00:00",
      "finish": "2026-04-15T13:32:24.912603+00:00"
    },
    "domain": "automation",
    "item_id": "1776183830102",
    "trigger": "state of person.bernie",
    "trace": {
      "trigger/1": [
        {
          "path": "trigger/1",
          "timestamp": "2026-04-15T13:32:24.911402+00:00",
          "changed_variables": {
            "this": {
              "entity_id": "automation.geolocation_new",
              "state": "on",
              "attributes": {
                "id": "1776183830102",
                "last_triggered": "2026-04-15T11:02:50.086320+00:00",
                "mode": "single",
                "current": 0,
                "friendly_name": "Geolocation NFC"
              },
              "last_changed": "2026-04-15T00:23:43.993803+00:00",
              "last_reported": "2026-04-15T11:02:50.087161+00:00",
              "last_updated": "2026-04-15T11:02:50.087161+00:00",
              "context": {
                "id": "01KP8CXQZ62EQKZWGQN1TYJDFZ",
                "parent_id": "01KP8CXQZ5T7FBFC5V18JGZP40",
                "user_id": null
              }
            },
            "trigger": {
              "id": "Away",
              "idx": "1",
              "alias": null,
              "platform": "state",
              "entity_id": "person.bernie",
              "from_state": {
                "entity_id": "person.bernie",
                "state": "home",
                "attributes": {
                  "editable": true,
                  "id": "bernie",
                  "device_trackers": [
                    "device_tracker.pixel_8"
                  ],
                  "latitude": 35.9976654,
                  "longitude": -83.7896118,
                  "gps_accuracy": 5,
                  "source": "device_tracker.pixel_8",
                  "user_id": "aa1efda901144228bf92c42651bfc168",
                  "friendly_name": "Bernard Barton"
                },
                "last_changed": "2026-04-14T19:42:00.846264+00:00",
                "last_reported": "2026-04-14T19:42:00.846264+00:00",
                "last_updated": "2026-04-14T19:42:00.846264+00:00",
                "context": {
                  "id": "01KP6R7NMEGT68FWJD3TZJ93ER",
                  "parent_id": null,
                  "user_id": null
                }
              },
              "to_state": {
                "entity_id": "person.bernie",
                "state": "not_home",
                "attributes": {
                  "editable": true,
                  "id": "bernie",
                  "device_trackers": [
                    "device_tracker.pixel_8"
                  ],
                  "latitude": 35.99757,
                  "longitude": -83.788475,
                  "gps_accuracy": 5,
                  "source": "device_tracker.pixel_8",
                  "user_id": "aa1efda901144228bf92c42651bfc168",
                  "friendly_name": "Bernard Barton"
                },
                "last_changed": "2026-04-15T13:32:24.910775+00:00",
                "last_reported": "2026-04-15T13:32:24.910775+00:00",
                "last_updated": "2026-04-15T13:32:24.910775+00:00",
                "context": {
                  "id": "01KP8NFMEEZR5F7VK9F83JB6GT",
                  "parent_id": null,
                  "user_id": null
                }
              },
              "for": null,
              "attribute": null,
              "description": "state of person.bernie"
            }
          }
        }
      ],
      "action/0": [
        {
          "path": "action/0",
          "timestamp": "2026-04-15T13:32:24.911810+00:00",
          "changed_variables": {
            "context": {
              "id": "01KP8NFMEF22GFPHP2WQAEBMEW",
              "parent_id": "01KP8NFMEEZR5F7VK9F83JB6GT",
              "user_id": null
            }
          }
        }
      ],
      "action/0/choose/0": [
        {
          "path": "action/0/choose/0",
          "timestamp": "2026-04-15T13:32:24.911918+00:00",
          "result": {
            "result": false
          }
        }
      ],
      "action/0/choose/0/conditions/0": [
        {
          "path": "action/0/choose/0/conditions/0",
          "timestamp": "2026-04-15T13:32:24.911962+00:00",
          "result": {
            "result": false
          }
        }
      ],
      "action/0/choose/1": [
        {
          "path": "action/0/choose/1",
          "timestamp": "2026-04-15T13:32:24.912025+00:00",
          "result": {
            "result": false
          }
        }
      ],
      "action/0/choose/1/conditions/0": [
        {
          "path": "action/0/choose/1/conditions/0",
          "timestamp": "2026-04-15T13:32:24.912061+00:00",
          "result": {
            "result": true
          }
        }
      ],
      "action/0/choose/1/conditions/1": [
        {
          "path": "action/0/choose/1/conditions/1",
          "timestamp": "2026-04-15T13:32:24.912096+00:00",
          "result": {
            "result": true
          }
        }
      ],
      "action/0/choose/1/conditions/1/entity_id/0": [
        {
          "path": "action/0/choose/1/conditions/1/entity_id/0",
          "timestamp": "2026-04-15T13:32:24.912124+00:00",
          "result": {
            "result": true,
            "state": "not_home",
            "wanted_state": "not_home"
          }
        }
      ],
      "action/0/choose/1/conditions/2": [
        {
          "path": "action/0/choose/1/conditions/2",
          "timestamp": "2026-04-15T13:32:24.912170+00:00",
          "result": {
            "result": true
          }
        }
      ],
      "action/0/choose/1/conditions/2/entity_id/0": [
        {
          "path": "action/0/choose/1/conditions/2/entity_id/0",
          "timestamp": "2026-04-15T13:32:24.912196+00:00",
          "result": {
            "result": true,
            "state": "not_home",
            "wanted_state": "not_home"
          }
        }
      ],
      "action/0/choose/1/conditions/3": [
        {
          "path": "action/0/choose/1/conditions/3",
          "timestamp": "2026-04-15T13:32:24.912233+00:00",
          "result": {
            "result": false
          }
        }
      ],
      "action/0/choose/1/conditions/3/entity_id/0": [
        {
          "path": "action/0/choose/1/conditions/3/entity_id/0",
          "timestamp": "2026-04-15T13:32:24.912258+00:00",
          "result": {
            "result": false,
            "state": "unknown",
            "wanted_state": "not_home"
          }
        }
      ]
    },
    "config": {
      "id": "1776183830102",
      "alias": "Geolocation NFC",
      "description": "",
      "triggers": [
        {
          "trigger": "state",
          "entity_id": [
            "person.bernie",
            "person.jane_barton",
            "person.bernie_iii"
          ],
          "to": [
            "home"
          ],
          "id": "Home"
        },
        {
          "trigger": "state",
          "entity_id": [
            "person.bernie",
            "person.jane",
            "person.bernie_iii"
          ],
          "to": [
            "not_home"
          ],
          "id": "Away"
        }
      ],
      "conditions": [],
      "actions": [
        {
          "choose": [
            {
              "conditions": [
                {
                  "condition": "trigger",
                  "id": [
                    "Home"
                  ]
                }
              ],
              "sequence": [
                {
                  "action": "input_boolean.turn_off",
                  "metadata": {},
                  "target": {
                    "entity_id": "input_boolean.security_alarm_switch"
                  },
                  "data": {}
                },
                {
                  "action": "input_boolean.turn_off",
                  "metadata": {},
                  "data": {},
                  "target": {
                    "entity_id": "input_boolean.doorbell"
                  },
                  "enabled": true
                },
                {
                  "action": "input_boolean.turn_off",
                  "metadata": {},
                  "target": {
                    "entity_id": "input_boolean.front_camera_switch"
                  },
                  "data": {}
                },
                {
                  "delay": {
                    "hours": 0,
                    "minutes": 5,
                    "seconds": 0,
                    "milliseconds": 0
                  },
                  "enabled": true
                },
                {
                  "action": "input_boolean.turn_on",
                  "metadata": {},
                  "data": {},
                  "target": {
                    "entity_id": "input_boolean.doorbell"
                  },
                  "enabled": true
                },
                {
                  "action": "input_boolean.turn_on",
                  "metadata": {},
                  "target": {
                    "entity_id": "input_boolean.front_camera_switch"
                  },
                  "data": {}
                }
              ]
            },
            {
              "conditions": [
                {
                  "condition": "trigger",
                  "id": [
                    "Away"
                  ]
                },
                {
                  "condition": "state",
                  "entity_id": "person.bernie",
                  "state": [
                    "not_home"
                  ]
                },
                {
                  "condition": "state",
                  "entity_id": "person.jane",
                  "state": [
                    "not_home"
                  ]
                },
                {
                  "condition": "state",
                  "entity_id": "person.bernie_iii",
                  "state": [
                    "not_home"
                  ]
                }
              ],
              "sequence": [
                {
                  "action": "input_boolean.turn_on",
                  "metadata": {},
                  "target": {
                    "entity_id": "input_boolean.security_alarm_switch"
                  },
                  "data": {}
                }
              ]
            }
          ]
        }
      ],
      "mode": "single"
    },
    "blueprint_inputs": null,
    "context": {
      "id": "01KP8NFMEF22GFPHP2WQAEBMEW",
      "parent_id": "01KP8NFMEEZR5F7VK9F83JB6GT",
      "user_id": null
    }
  },
  "logbookEntries": [
    {
      "name": "Geolocation NFC",
      "message": "triggered by state of person.bernie",
      "source": "state of person.bernie",
      "entity_id": "automation.geolocation_new",
      "context_id": "01KP8NFMEF22GFPHP2WQAEBMEW",
      "domain": "automation",
      "when": 1776259944.9114895
    }
  ]
}

That trace shows that it ran the automation, choosing the path of you arriving home and turning everything off.

Nevermind, you posted a new trace. Let me look at it

But what did strike me in the automation itself: A persons state can be other things than home or not_home. If you defined zones, a person’s state could also be “Work” or some other zone name, failing the conditions.

It also seems like you are replicating “first person coming home” and “last person leaving home” the hard way. You can do this by examining the state of zone.home, which is a count of the number of persons at home.

That trace shows the 3rd person has a state unknown in this list:

FYI this info is available in the UI. You have to manually click through each condition in the trace to see it in the results page.

Is there any reason you are not using the numeric trigger on zone.home being more than 0 or less than 1 as the trigger?
That is what people usually use

Thank you. I guess the question is why is that state unknown. I just installed HA on my son’s Apple phone last night. He was at school, maybe his phone was off? Could that cause an unknown condition?

I just tested it in the UI and the condition “Did not pass”, even though he’s at school.

-Thanks again.

I used it because HA has a state trigger specifically for Home or Away. It seems purpose built for this situation.

Is location tracking on for HA? unknown means it hasn’t received a location yet. He may have blocked location tracking. There’s a number of reasons why that could happen.

That’s probably it! I did not explicitly enable location tracking on his phone. I just checked HA my phone and see that under Settings → Companion app → Sensors → Manage Sensors → Location zone is enabled. Is that the location setting you are referring to?

FYI, if I look at the map I can see his location, it’s the ‘i’ for iPhone.

-Thanks

Check his person entity and verify that the mobile app device tracker is attached to it. Secondly, there’s location settings in iOS that enable/disable location tracking on iPhone.

Yes, under people he did not have a device assigned to him. But even after assigning his iPhone, the condition still did not pass the test, even though he’s at school. I’ll check his iPhone location settings when he gets home.

Thanks again.

UPDATE: Actually, I entered my Pixel 8 phone in my son’s “Select an entity” option. After I selected his iPhone, it works as expected.