Motion, Presence, and Home Modes: Home, Night, Away, Guests

Motion, Presence, and Home Modes: Home, Night, Away, Guests

Module 18 · Lesson 8

Motion, Presence, and Home Modes: Home, Night, Away, Guests

In Lesson 6 you set home mode by hand. In Lesson 7, weather changed the meaning of open windows. Now Home Assistant will help recognize whether someone's home: and in many situations switch home mode before a manual mistake leads to a false alarm.

This lesson is about context, not "a magic sensor that knows everything." A phone, a PIR sensor, and a presence sensor all give different signals. You decide which one you trust when switching between Away and Home mode.

Plan on about 90 to 105 minutes. Start with one person and one phone. Then add Night mode and garage motion.

The rule for this lesson
Home mode should reflect reality.
Presence is a supporting signal: it doesn't replace contact sensors, locks, or common sense.

A real-life problem: you're back, but the house still thinks you're away

In Lesson 6, you built an alarm for openings in Away mode. You set Away in the morning and left. You come home after work, open the door: and the mode is still Away, because you forgot to change it. The system reasonably treats this as an intrusion and triggers the escalation from Lesson 3.

The second scenario: you leave the house, but the mode stays Home. An open window during rain won't send the urgent alert from Lesson 7, because the system thinks someone's home. Both problems come from the same root cause: home mode falling out of sync with reality.

How Home Assistant knows someone's home

This lesson uses example entity names. Yours might come from a mobile app, a router, a PIR motion sensor, an mmWave presence sensor, or a GPS zone. What matters most is understanding the difference between "something moved" and "someone's home."

Source Good for Risk
Phone (Companion app) Automatic Home/Away on arrival and departure. GPS delay, phone left at home, dead battery.
PIR motion sensor An alert for motion in the garage, hallway, or basement at night. Detects any motion: including a cat, curtains, a robot vacuum.
mmWave presence sensor Detects someone standing or sitting still. More expensive, needs good mounting and calibration.
Door contact sensor A reliable signal of entry and exit through the door. On its own, doesn't say whether it's a household member or an intruder.

Motion isn't the same as presence
A PIR sensor says: "something moved a moment ago." It doesn't say: "Marek has been home for an hour." For automatic Away mode, it's better to use a phone or a person entity. Save PIR for nighttime alerts and motion scenarios in a specific room.

A phone at home doesn't always mean you're home
If you leave your phone on the charger and go out without it, the system may think you're still home. That's why, with more than one household member, you should use a person entity for each person and check the "everyone away" logic, rather than relying on a single phone.

Which signals to trust

Not every source is fit for the same job. A phone and a PIR sensor can be in the same house, but they play different roles. The table below helps you pick the right signal: no guesswork.

Signal Trust level Best use
Person / phone Medium Home/Away mode with a delay
Door contact sensor High for the fact of an opening Entry/exit, an opening alarm
PIR Low as home presence, good as local motion Motion in the garage, hallway, basement
mmWave Good for a room, not for the whole house Presence in the living room, office, bathroom

What's actually the risk

PIR as the only presence signal: a cat in the hallway blocks Away mode, or triggers false alerts.

Instant Away after leaving: one household member goes for a walk, and the mode jumps to Away even though someone else is home.

No entry delay: you come home, GPS lags, you open the door while it's still Away mode: an alarm.

Automation with no kill switch: guests, renovation, a late-night party: the system switches modes at the worst possible time.

An overly aggressive Night mode: switching at 10:30 PM while you're still in the garden or garage.

Home modes: now with presence

The input_select.home_mode helper from Lesson 6 stays. What changes is who switches it: instead of clicking manually, presence-based automations do it. Manual changes still work and take priority when you disable the automation.

Mode When we set it automatically What it changes
Home Someone returns to the home zone Openings = reminders, weather = context from Lesson 7
Night After a nighttime hour, if someone's home Doors and motion = more urgent alerts
Away Every household member away for a set time A critical opening = an alarm with escalation
Guests Manual: for now Less aggressive alerts for normal activity

Why Guests stays manual
Home Assistant doesn't know you have guests, a renovation crew, or a pet sitter. A household member's phone might be away while someone is still legitimately inside. That's why we set Guests mode manually and treat it as a safe exception to automatic Away mode.

Presence doesn't arm or disarm on its own
Don't set Away the instant one phone leaves the zone: GPS, battery, and location tracking can all fail. Automatic arming needs: everyone away + a delay + no motion + closed doors + easy cancellation.

A phone in the home zone alone shouldn't disarm anything. It's safer this way: presence prepares for entry, opening the door starts a delay, and a household member consciously disarms. For countdowns, consider a timer helper instead of a plain boolean.

In this lesson we deliberately don't use the security alarm script to switch modes. Modes are context. The alarm stays exactly where it was in Lesson 6: triggered by an opening in Away mode.

Which entities we're watching

Entity Meaning
person.marek A household member, with a home zone (home / not_home)
device_tracker.marek_phone The phone location source for that person
input_select.home_mode The mode from Lesson 6: now automatic too
binary_sensor.front_door The house entrance: a supporting signal
binary_sensor.garage_motion PIR in the garage: a nighttime alert
binary_sensor.living_room_presence Optional mmWave: presence in the living room

Entity names are examples
Yours might be person.anna, with a phone named device_tracker.iphone_anna. Before pasting in an automation, check Settings → People and Zones to make sure the home zone has a sensible radius and the phone is actually reporting its location.

Helpers and the entry delay

In Lesson 6 you had leaving_home_in_progress: 90 seconds to leave calmly after setting Away. Now we add a mirror-image entry delay: entering_home_in_progress. It only works when your return is detected before you open the door in Away mode: GPS limitations are discussed below.

input_boolean:
  automatic_home_modes:
    name: "Automatic home modes"
    icon: mdi:home-automation
    initial: true

  entering_home_in_progress:
    name: "Entering home in progress"
    icon: mdi:home-import-outline

  automatic_modes_test:
    name: "Automatic modes test"
    icon: mdi:test-tube

input_number:
  away_delay_minutes:
    name: "Away-mode delay after leaving"
    min: 5
    max: 60
    step: 5
    initial: 15
    unit_of_measurement: "min"
    icon: mdi:timer-outline

automatic_home_modes is the main kill switch. For guests, a renovation, or a test: turn off the helper and set the mode by hand, just like in Lesson 6. We keep the away_delay_minutes helper on the dashboard for later tuning: in the main YAML, we start with a hard-coded 15 minutes, since that's clearer for debugging.

A timed helper shouldn't stay stuck on ON
The entry and exit helpers are meant to run briefly. If Home Assistant restarts mid-delay, the helper can get stuck on. It's worth clearing entering_home_in_progress and leaving_home_in_progress after the system starts.

A fix for the Lesson 6 automation: the Away alarm

Add a third condition to the "opening in Away mode" automation from Lesson 6. The alarm shouldn't fire during either an exit or an entry:

      - condition: state
        entity_id: input_boolean.leaving_home_in_progress
        state: "off"
      - condition: state
        entity_id: input_boolean.entering_home_in_progress
        state: "off"

Detecting the phone alone might be too late
If the phone only reports arrival after the door has already opened, the Lesson 6 alarm can fire before the mode switches to Home. That's why a real entry alarm setup uses an entry delay: a door opening in Away mode doesn't trigger the siren immediately, it gives a short window to recognize a household member or manually confirm. We'll build this out more fully with a simple supporting alarm in Lesson 9.

The entering_home_in_progress helper only protects you when the person entity switches to home before the door opens. If GPS lags, the helper alone isn't enough: at that point, the entry delay on the alarm (Lesson 9) or manually setting Home mode before you go in is what matters.

Automation 1: returning home and the entry delay

When a household member returns to the home zone, we turn on the entry delay and switch the mode to Home. For 60 seconds, the Away alarm won't respond to the door opening: but only if the return was detected before the door opened.

automation:
  - alias: "Security: returning home and the entry delay"
    description: "Sets Home mode and gives 60 s to enter without the Away alarm"
    mode: restart
    triggers:
      - trigger: state
        entity_id: person.marek
        to: "home"
      - trigger: state
        entity_id: input_boolean.automatic_modes_test
        to: "on"
    conditions:
      - condition: state
        entity_id: input_boolean.automatic_home_modes
        state: "on"
    actions:
      - action: input_boolean.turn_on
        target:
          entity_id: input_boolean.entering_home_in_progress
      - action: input_select.select_option
        target:
          entity_id: input_select.home_mode
        data:
          option: "Home"
      - action: script.notify_household
        data:
          title: "Returning home"
          message: >
            {% if trigger.entity_id == 'input_boolean.automatic_modes_test' %}
            This is an automatic-modes test. Check that the mode switched to Home.
            {% else %}
            A return home was detected. Mode set to Home.
            {% endif %}
      - delay:
          seconds: 60
      - action: input_boolean.turn_off
        target:
          entity_id: input_boolean.entering_home_in_progress
      - choose:
          - conditions:
              - condition: template
                value_template: "{{ trigger.entity_id == 'input_boolean.automatic_modes_test' }}"
            sequence:
              - delay:
                  seconds: 2
              - action: input_boolean.turn_off
                target:
                  entity_id: input_boolean.automatic_modes_test

The automatic_modes_test helper in this lesson only tests the return-home path, i.e. switching to Home. You test Away separately, either by changing the person's state or by temporarily setting the mode by hand and checking the dashboard.

Automation 2: everyone away → Away mode

We only set Away mode once a household member has been away for a set amount of time. To start, we use a hard-coded 15 minutes: it's clearer and easier to debug than a template inside for:.

automation:
  - alias: "Security: everyone away sets Away mode"
    description: "Switches to Away mode 15 minutes after the last person leaves"
    mode: single
    triggers:
      - trigger: state
        entity_id: person.marek
        to: "not_home"
        for:
          minutes: 15
    conditions:
      - condition: state
        entity_id: input_boolean.automatic_home_modes
        state: "on"
      - condition: state
        entity_id: person.marek
        state: "not_home"
    actions:
      - action: input_select.select_option
        target:
          entity_id: input_select.home_mode
        data:
          option: "Away"
      - action: script.notify_household
        data:
          title: "Away mode enabled"
          message: "A household member has been away for 15 minutes. Mode set to Away."

We start with a hard-coded 15 minutes because it's clearer and easier to debug. Once the logic is running stably, you can move this time into the input_number.away_delay_minutes helper and adjust it from the dashboard: the same way you did with weather thresholds in Lesson 7.

One person versus multiple people

The simplest example works for one person. In a real household, Away mode should only turn on once every household member is away. If one person left while another is still in the living room, the house isn't empty.

# A two-person variant: excerpt from the Away automation:
triggers:
  - trigger: state
    entity_id:
      - person.marek
      - person.anna
    to: "not_home"
    for:
      minutes: 15
conditions:
  - condition: state
    entity_id: input_boolean.automatic_home_modes
    state: "on"
  - condition: template
    value_template: >
      {{ is_state('person.marek', 'not_home')
         and is_state('person.anna', 'not_home') }}

The Lesson 6 automation will still turn on leaving_home_in_progress for 90 seconds after switching to Away. In the return-home automation, add both person entities to the trigger: it takes just one person coming back for the mode to switch to Home.

Automation 3: Night mode and morning

We only set Night mode when someone's home. In the morning we switch back to Home: otherwise the alerts from Lessons 6 and 7 will behave like it's the middle of the night.

automation:
  - alias: "Security: Night mode after 10:30 PM"
    description: "Switches to Night mode when someone's home"
    mode: single
    triggers:
      - trigger: time
        at: "22:30:00"
    conditions:
      - condition: state
        entity_id: input_boolean.automatic_home_modes
        state: "on"
      - condition: state
        entity_id: person.marek
        state: "home"
      - condition: state
        entity_id: input_select.home_mode
        state: "Home"
    actions:
      - action: input_select.select_option
        target:
          entity_id: input_select.home_mode
        data:
          option: "Night"

  - alias: "Security: Home mode in the morning"
    description: "Returns to Home mode in the morning if someone's home"
    mode: single
    triggers:
      - trigger: time
        at: "07:00:00"
    conditions:
      - condition: state
        entity_id: input_boolean.automatic_home_modes
        state: "on"
      - condition: state
        entity_id: person.marek
        state: "home"
      - condition: state
        entity_id: input_select.home_mode
        state: "Night"
    actions:
      - action: input_select.select_option
        target:
          entity_id: input_select.home_mode
        data:
          option: "Home"

The home_mode = Home condition is deliberate. If you manually set Guests, the nighttime automation shouldn't overwrite it at 10:30 PM. This is an example of a rule: a user's manual decision takes priority on an unusual day.

Automation 4: motion in the garage at night

A garage PIR sensor is a good scenario for an urgent alert in Night mode. We don't use it to switch to Away: only to flag that something's moving where it shouldn't be at this hour.

A brief flicker of motion versus sustained motion
A single PIR trigger doesn't necessarily mean an intruder. That's why we use for: 30 seconds: the alert only fires once motion lasts longer than a passing shadow or a gust moving a curtain.

Pets and false alarms
PIR sees a cat, a dog, and a robot vacuum. Don't base "the house is empty" logic on PIR alone. Use the phone for Away mode. For a nighttime garage alert: PIR with a delay, and only in Night or Away mode, not Home.

automation:
  - alias: "Security: garage motion in Night mode"
    description: "An urgent alert for garage motion at night"
    mode: single
    triggers:
      - trigger: state
        entity_id: binary_sensor.garage_motion
        to: "on"
        for:
          seconds: 30
    conditions:
      - condition: or
        conditions:
          - condition: state
            entity_id: input_select.home_mode
            state: "Night"
          - condition: state
            entity_id: input_select.home_mode
            state: "Away"
    actions:
      - action: script.notify_household_urgent
        data:
          title: "Garage motion"
          message: "Motion detected in the garage in {{ states('input_select.home_mode') }} mode. Check what's going on."

In Away mode, garage motion could be a candidate for a full alarm, but in this lesson we leave it as an urgent alert. We'll build full alarm-zone logic in Lesson 9, so as not to mix presence with alarm arming.

Resetting timed helpers after an HA restart

automation:
  - alias: "Security: reset delays and test after HA startup"
    description: "Clears the entry, exit, and test helpers after Home Assistant restarts"
    mode: single
    triggers:
      - trigger: homeassistant
        event: start
    actions:
      - action: input_boolean.turn_off
        target:
          entity_id:
            - input_boolean.entering_home_in_progress
            - input_boolean.leaving_home_in_progress
            - input_boolean.automatic_modes_test

Resetting the test when automatic modes are disabled

The same pattern as in Lessons 6 and 7: if the test helper turns on and the automation doesn't run, the helper has to turn itself off.

automation:
  - alias: "Security: reset automatic-modes test"
    description: "Turns off the test helper when automatic modes are off"
    mode: single
    triggers:
      - trigger: state
        entity_id: input_boolean.automatic_modes_test
        to: "on"
    conditions:
      - condition: state
        entity_id: input_boolean.automatic_home_modes
        state: "off"
    actions:
      - delay:
          seconds: 2
      - action: input_boolean.turn_off
        target:
          entity_id: input_boolean.automatic_modes_test
      - action: script.notify_household
        data:
          title: "Automatic-modes test canceled"
          message: "Automatic home modes are disabled. Turn them on if you want to test switching."

Dashboard: presence and modes

type: entities
title: Presence and home modes
entities:
  - input_select.home_mode
  - input_boolean.automatic_home_modes
  - person.marek
  - device_tracker.marek_phone
  - input_boolean.entering_home_in_progress
  - input_boolean.leaving_home_in_progress
  - input_number.away_delay_minutes
  - binary_sensor.garage_motion
  - input_boolean.automatic_modes_test

Home mode has to be visible
Even with automation, show home_mode and automatic_home_modes at the top of your security dashboard. At a glance, you can see whether the system thinks you're home or away.

How to test, step by step

Test presence carefully
Don't jump straight to testing a full alarm with a siren. First set a short Away delay, watch the person entity in Developer Tools, and check just the home_mode switching. Only once the modes are working reliably should you connect them to the Lesson 6 alarm.

1. Check that the phone reports the home zone in Developer Tools.

2. Run automatic_modes_test and check the switch to Home.

3. Turn off automatic_home_modes and confirm the test resets with a message.

4. Set Away, turn on entering_home_in_progress, open the door: the alarm doesn't trigger.

5. Simulate the phone leaving the zone and check that Away kicks in once the delay passes.

6. Test garage motion in Night mode: the alert should be urgent, not a full life-safety alarm.

Common mistakes

PIR as presence: a false Away switch, or Away never triggering, because of pets.

No entry delay: an alarm on returning home, before the mode switches to Home.

Too short an Away delay: the mode jumps when someone just steps out briefly.

No kill switch for automatic modes: the system switches modes at the wrong moment and there's no way to stop it.

The test helper stays on: no reset when automatic modes are disabled.

An entry or exit helper stuck ON: an HA restart during the delay blocks the alarm, or mutes it permanently.

Don't base your home's security on the phone alone
A phone can be left at home, run out of battery, or stop reporting its location. Automatic modes are a convenience, not a replacement for contact sensors, locks, and consciously setting Away before an extended absence.

Presence is context, not an alarm
This lesson doesn't build a complete alarm yet. Presence helps set home mode, but a presence change alone shouldn't trigger a siren or escalation. We'll build the full logic for arming, entry delay, zones, and false alarms in Lesson 9.

Assignment: presence and home modes

To do

☐ Configure a person and a home zone for one phone.

☐ Add the automatic-modes, entry, test, and Away-delay helpers.

☐ Update the Away-alarm automation from Lesson 6 with the entering_home_in_progress = off condition.

☐ Paste in the automations for returning home, going Away, Night mode, and garage motion.

☐ Test a return: Away → entering home → Home with no false alarm.

☐ Test leaving: everyone away → Away after 15 minutes.

☐ Check how quickly the phone switches state from not_home to home on return.

☐ If two people live in the house, add a second person entity and test the "everyone away" rule.

☐ Check that Guests mode isn't overwritten by Night mode.

☐ Add a reset for the entry and exit helpers after a Home Assistant restart.

☐ Check the test reset when automatic modes are disabled.

☐ Update the risk map from Lesson 1 with your presence sources and automatic modes.

Key takeaways

Motion isn't presence: PIR for room-level alerts, a phone for Home/Away mode.

The entry delay protects you when your return is detected before the door opens: it doesn't fix a slow GPS.

Automatic modes need a kill switch: the automatic_home_modes helper saves you during guests and unusual days.

A phone is a convenience, not a guarantee: presence helps switch modes, but it doesn't replace contact sensors and locks.

Home mode is context for Lessons 6 and 7: it updates itself now, but you still verify it on the dashboard.

What's next

In Lesson 9 we'll build a simple supporting alarm in Home Assistant: zones, an entry delay for arming, a siren, and handling false alarms. That will close the loop on the logic from Lessons 6 and 8 into one coherent system.

After this lesson, your house doesn't just know a door is open and it's raining outside. It's also starting to know whether someone should be inside: and it adjusts its response to that context.

Finished this lesson?