Automation

Home Assistant Presence Detection: A Home-Mode Design That Survives GPS Jitter

Written with AI assistance by the editorial team.
Updated November 25, 2026 8 min read

The hardest automation to get right in a Home Assistant install often isn’t a complicated dashboard or a fancy energy-balancing routine. It’s “is anyone home?”.

This isn’t a beginner walkthrough. It covers two iterations of the design and the specific failure modes that break each one.

What “presence detection” actually means

When people say “presence detection” in HA they usually mean one of three things, and conflating them is the source of about half the bugs:

  1. Person tracking. Where is each individual person, right now? GPS-driven, comes from the HA companion app on a phone.
  2. Home occupancy. Is anyone home at all? Boolean. Drives “lock the doors when nobody’s here” and “turn off all the lights when the house is empty.”
  3. Room occupancy. Is the kitchen occupied? Driven by motion sensors, mmWave radar, BLE beacons. Drives “turn the lights on when someone walks in.”

This post is about the second one — home occupancy — because that’s the one that is easiest to get wrong. Person tracking via the companion app is mostly a solved problem (it works as well as your phone’s GPS works). Room occupancy is its own rabbit hole, mostly about sensor placement.

The hard part is collapsing several people’s individual locations into a single “house occupied” boolean and using that to drive automations that don’t fire at the wrong time.

A note on the examples: the entity names (person.adult_one, person.adult_two), zone names and timings below are placeholders that show the pattern. Substitute your own and pick thresholds that suit your household.

Iteration 1: Naive person.<name>.state == 'home'

The first version is the obvious one. A binary_sensor.home_occupied template that returns true if any tracked person is in the home zone:

template:
  - binary_sensor:
      - name: "Home Occupied"
        state: >
          {{ is_state('person.adult_one', 'home') or
             is_state('person.adult_two', 'home') }}

This breaks in three different ways:

Failure mode 1: Phone GPS jitter. The companion app can briefly report not_home for ten or twenty seconds when GPS lock gets fuzzy — typically while the phone is sitting indoors. The boolean flips to false, an automation fires (“nobody’s home, turn off the lights”), the lights go dark with someone standing under them, then GPS re-acquires and the boolean flips back.

Failure mode 2: Welcome-home firing without an arrival. A “welcome home” automation that triggers on state changed from not_home to home also fires on a drive past the house — the GPS bounces through the home zone for thirty seconds and triggers the automation with nobody actually arriving.

Failure mode 3: Battery-saver mode killing updates. If a phone goes into battery saver, location updates slow to a crawl. The boolean stays home for hours after its owner has left, because nothing is telling HA the phone has moved.

Bandages such as debounce delays, “for: 5 minutes” conditions and longer state checks help, but new edges keep appearing. The fundamental problem is using a transient phone GPS reading as the source of truth for an ambient state.

Iteration 2: Home mode as a manual switch

The other direction is a manual input_select.home_mode with three states (Home, Away, Sleep), changed only by explicit triggers. The companion app reports location, but it doesn’t get to set the home mode. Setting Away happens when every tracked phone has been outside the home zone for a sustained period; setting Home happens when any tracked person crosses the home zone boundary heading inward.

input_select:
  home_mode:
    name: Home Mode
    options:
      - Home
      - Away
      - Sleep
    initial: Home
    icon: mdi:home

This is a big improvement. Automations condition on input_select.home_mode instead of raw person.X.state, and the input_select only changes when an automation explicitly sets it. That means GPS jitter no longer flips the world out from under you — it might briefly cause a person sensor to say not_home, but unless that state persists, no mode change happens.

Most of the file is the logic that decides when to flip modes:

- id: 'auto_away_mode'
  alias: Auto Away Mode
  triggers:
    - trigger: state
      entity_id:
        - person.adult_one
        - person.adult_two
      to: 'not_home'
      for:
        minutes: 10   # example value; tune it
  conditions:
    # Everyone must be away
    - condition: template
      value_template: >
        {{ not is_state('person.adult_one', 'home') and
           not is_state('person.adult_two', 'home') }}
    # Don't flip if already Away
    - condition: not
      conditions:
        - condition: state
          entity_id: input_select.home_mode
          state: 'Away'
  actions:
    - action: input_select.select_option
      target:
        entity_id: input_select.home_mode
      data:
        option: 'Away'

Three things matter here:

  • A sustained for: on the trigger — a person must have been away for the whole window before the mode can flip. That’s the GPS-jitter killer. A spurious twenty-second not_home doesn’t propagate.
  • The template condition double-checks everyone at action time, not trigger time. If one person left in the morning and a second leaves later, the second person’s not_home trigger fires; the template confirms the first is also still away; mode flips. If the first person came back in between, the template fails and mode doesn’t flip even though the trigger fired.
  • The “don’t flip if already X” guard prevents the same automation from re-firing every time a trigger reaches the threshold. mode: single would also handle this, but the explicit guard makes the intent obvious to anyone reading the YAML six months later.

Failure mode 4: The zone-bounce on departure

The hardest pattern to find is this: a wider geofence zone (call it zone.close_to_home) around the house, and zone.home for the actual property. The welcome-home automation triggers on entering close_to_home. The departure path normally crosses close_to_home first, then home. But on the way back from a long trip, GPS sometimes reports an out-of-order sequence: the phone briefly registers as inside home before close_to_home, depending on which tower the GPS is fixing against.

That fires the welcome-home automation on departure too, because close_to_home gets an enter event after a brief leave-then-re-enter flicker. The fix is the home_mode condition: welcome-home only fires when mode is currently Away. On the way out — mode is Home, geofence flickers, condition fails, nothing happens. On the way in — mode is Away, geofence triggers, condition passes, action fires.

- id: 'welcome_home_actions'
  alias: Welcome Home Actions
  triggers:
    - trigger: zone
      entity_id: person.adult_one
      zone: zone.close_to_home
      event: enter
  conditions:
    # Must actually be away (not just leaving the house)
    - condition: state
      entity_id: input_select.home_mode
      state: 'Away'
  actions:
    - action: notify.mobile_app_your_phone
      data:
        title: "Welcome home"
        message: "Tap an action"
        data:
          actions:
            - action: "TURN_LAMP_ON"
              title: "Turn on lamp"
            - action: "SET_HOME_MODE"
              title: "Set Home mode"

The notification has actionable buttons. Each one is handled by a separate handler automation that listens for mobile_app_notification_action events and runs whatever that button stands for.

Action buttons are the safer design compared with doing things automatically on geofence entry. Given the false triggers described above, the cost of a spurious trigger should be one ignored notification, not an action taken on the house while nobody is there. Anything security-sensitive belongs behind a deliberate tap, if it is exposed to presence logic at all.

Failure mode 5: Battery-saver and the dead-phone problem

A for: window solves GPS jitter, but it doesn’t solve “what happens when a phone stops reporting at all.” If a phone goes into deep sleep, its person entity never changes state. If that person actually leaves and the phone never reports it, the auto-away automation never fires.

The usual answer is a backstop built on a second, independent signal rather than on more GPS logic. One example is a non-phone signal such as indoor motion or a mmWave presence sensor: if nothing has been detected for a long stretch while the mode is still Home, force a re-check of everyone’s state.

Treat any of these as a backstop, not a primary signal, and pick a window long enough that a quiet afternoon at home doesn’t look like an empty house.

What to build on a fresh install

Three rules for a fresh install:

  1. Start with input_select.home_mode from day one. Don’t condition automations on raw person.X.state ever. GPS jitter and battery saver are real and they will hurt you.
  2. Use for: aggressively. Anything triggered by GPS state or zone enter/leave needs a for: of at least a few minutes, sometimes longer. The cost is responsiveness; the benefit is sanity.
  3. Build the failure case first. Before the welcome-home automation, write the away automation. Before the away-mode flip, write the unit test (mentally if not literally) of every weird path: deep sleep, GPS bounce, brief disconnect, both phones losing signal at once, etc.

When it’s worth the investment

This takes several iterations to get right, which is a lot of time for “is anyone home.” The reason it’s worth it is that home occupancy is the single condition that drives the most other automations: lighting, climate, security, alerts, energy management. If it’s wrong, every downstream automation is wrong with it. If it’s right, you stop thinking about it and start trusting the rest of the stack.

A presence file grows long. It’s not complicated line by line. The edge cases are real, and most of the lines exist to handle them.


Related guides: Node-RED to native HA YAML · Fixing an unreliable Zigbee mesh

Tags #home-assistant #presence-detection #automation #geofencing
Share X / Twitter Facebook
Keep reading