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.
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:
- Go to Settings > Automations & scenes.
- Open an existing automation, or select Create automation > Create new automation.
- In the And if section, select Add condition.
- From the search box, search for and select Zone occupancy is detected.
- Under Zone, select the zone to check.
- 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.
- Select Save.
Options in the UI
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:
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.
Good to know
- A zone is occupied when its state is a number of
1or higher. - If the zone state is
unknownorunavailable, 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.
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)
-
Target: Front door contact sensor (
-
Condition: Zone occupancy is detected
-
Zone: Home (
zone.home)
-
Zone: Home (
- Condition: Sun is below horizon
-
Action: Turn on light
-
Target: Entry light (
light.entry)
-
Target: Entry light (
YAML example for turning on the entry light only if someone is home
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)
-
Zone: Office (
-
Action: Send a notification message
-
Target: My Device (
notify.my_device)
-
Target: My Device (
YAML example for an after-hours office occupancy notification
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.
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:
-
Zone occupancy is not detected: Tests if a zone is empty.
-
Is in zone: Tests if one or more people or device trackers are in a zone.