Zone occupancy is detected

The Zone occupancy is detected condition passes when the selected zone is occupied. Use it to make an automation continue only if at least one person is in a zone.

Labs

Requires the Purpose-specific triggers and conditions Labs preview feature. Enable it at Settings > System > Labs.

Using this condition from the user interface

If you prefer building automations visually, Home Assistant walks you through this condition step by step. You pick what to check, tweak a few options, and save. No YAML knowledge required.

To use this condition in an automation:

  1. Go to Settings > Automations & scenes.
  2. Open an existing automation, or select Create automation > Create new automation.
  3. In the And if section, select Add condition.
  4. From the search box, search for and select Zone occupancy is detected.
  5. Under Zone, select the zone to check.
  6. Under For at least, you can set how long the zone must have been occupied before the condition passes. Leave it at zero for the condition to pass immediately.
  7. Select Save.

Options in the UI

Zone (Required)

The zone to monitor.

For at least (Optional)

How long the zone must have been occupied before the condition passes. The default is zero, which passes immediately.

Using this condition in YAML

If you work directly in YAML, or you want to know exactly what Home Assistant does under the hood, this section has the technical reference. It lists the field names you use in YAML, their types, and which ones are required.

In YAML, refer to this condition as zone.occupancy_is_detected. A basic example looks like this:

ConditionConditions are an optional part of an automation that will prevent an action from firing if they are not met. [Learn more]
condition: zone.occupancy_is_detected
options:
  zone: zone.home

This passes when zone.home is occupied.

Options in YAML

YAML sometimes provides additional options for more complex use cases that are not available through the UI.

zone string Required

The zone to monitor.

for string

How long the zone must have been occupied before the condition passes. Accepts a duration string in HH:MM:SS format or a time period mapping in hours, minutes, and seconds.

Good to know

  • A zone is occupied when its state is a number of 1 or higher.
  • If the zone state is unknown or unavailable, the condition does not pass.
  • To check the opposite state, use Zone occupancy is not detected.

Try it yourself

Ready to test this? Go to Settings > Automations & scenes, open an automation, and add this condition. Trigger the automation with and without the condition met, and watch whether it continues or stops.

More examples

Real scenarios where this condition gates an automation. Copy any example and adapt it to your setup.

Tip

You don’t need to edit YAML to use these examples. Copy a YAML snippet from this page, open the automation editor in Home Assistant, and press Ctrl+V (or Cmd+V on Mac). Home Assistant automatically converts the pasted YAML into the visual editor format, whether it’s a full automation, a single trigger, a condition, or an action.

Automation: turn on the entry light only if someone is home

When the front door contact sensor turns on after sunset, this automation turns on the entry light only if the home zone is occupied.

  • Trigger: State changes to on
    • Target: Front door contact sensor (binary_sensor.front_door)
  • Condition: Zone occupancy is detected
    • Zone: Home (zone.home)
  • Condition: Sun is below horizon
  • Action: Turn on light
    • Target: Entry light (light.entry)
YAML example for turning on the entry light only if someone is home
AutomationAutomations in Home Assistant allow you to automatically respond to things that happen in and around your home. [Learn more]
alias: "Turn on the entry light if someone is home"
triggers:
  - trigger: state
    entity_id: binary_sensor.front_door
    to: "on"
conditions:
  - condition: zone.occupancy_is_detected
    options:
      zone: zone.home
  - condition: sun
    after: sunset
actions:
  - action: light.turn_on
    target:
      entity_id: light.entry

Automation: send a message if the office is occupied after hours

At 18:00, this automation sends a notification if the office zone is occupied.

  • Trigger: Time is 18:00
  • Condition: Zone occupancy is detected
    • Zone: Office (zone.office)
  • Action: Send a notification message
    • Target: My Device (notify.my_device)
YAML example for an after-hours office occupancy notification
AutomationAutomations in Home Assistant allow you to automatically respond to things that happen in and around your home. [Learn more]
alias: "Notify if the office is occupied after hours"
triggers:
  - trigger: time
    at: "18:00:00"
conditions:
  - condition: zone.occupancy_is_detected
    options:
      zone: zone.office
actions:
  - action: notify.send_message
    target:
      entity_id: notify.my_device
    data:
      message: "The office zone is occupied after hours."

Still stuck?

The Home Assistant community is quick to help: join Discord for real-time chat, post on the community forum with the condition you’re using and what you expected to happen, or share on our subreddit /r/homeassistant.

Tip

AI assistants like ChatGPT or Claude can also explain conditions or suggest the right one when you describe what you want in plain language.

Related conditions

These conditions work well alongside this one: