Zone occupancy cleared

The Zone occupancy cleared trigger fires when a selected zone changes from occupied to empty. Use it when an automation should run after everyone has left a place, without listing each person or device tracker in the trigger.

Labs

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

Using this trigger from the user interface

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

To use this trigger in an automation:

  1. Go to Settings > Automations & scenes.
  2. Open an existing automation, or select Create automation > Create new automation.
  3. In the When section, select Add trigger.
  4. From the search box, search for and select Zone occupancy cleared.
  5. Under Zone, select the zone to monitor.
  6. Under For at least, you can set how long the zone must stay empty before the trigger fires. Leave it at zero to fire immediately.
  7. Select Save.

Options in the UI

Zone (Required)

The zone to monitor.

For at least (Optional)

How long the zone must stay empty before the trigger fires. The default is zero, which fires immediately.

Using this trigger 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 trigger as zone.occupancy_cleared. A basic example looks like this:

TriggerA trigger is a set of values or conditions of a platform that are defined to cause an automation to run. [Learn more]
trigger: zone.occupancy_cleared
options:
  zone: zone.home

This fires when zone.home changes from occupied to empty.

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 stay empty before the trigger fires. 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 empty when its state is 0.
  • If the zone state is unknown or unavailable, Home Assistant does not treat the zone as empty.
  • This trigger fires when the zone changes from occupied to empty. It does not fire again while the zone stays empty.
  • To react when a zone becomes occupied, use Zone occupancy detected.

Try it yourself

Ready to test this? Go to Settings > Automations & scenes, create a new automation, and add this trigger. Save the automation, then change the state of the targeted entity to watch the trigger fire on your actual entitiesAn entity represents a sensor, actor, or function in Home Assistant. Entities are used to monitor physical properties or to control other entities. An entity is usually part of a device or a service. [Learn more].

More examples

Real scenarios where this trigger fires in automations and scripts. 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 off the office fan when home is empty

When the home zone has been empty for 5 minutes, this automation turns off the office fan.

  • Trigger: Zone occupancy cleared
    • Zone: Home (zone.home)
    • For at least: 5 minutes
  • Action: Turn off fan
    • Target: Office fan (fan.office)
YAML example for turning off the office fan when home is empty
AutomationAutomations in Home Assistant allow you to automatically respond to things that happen in and around your home. [Learn more]
alias: "Turn off the office fan when home is empty"
triggers:
  - trigger: zone.occupancy_cleared
    options:
      zone: zone.home
      for: "00:05:00"
actions:
  - action: fan.turn_off
    target:
      entity_id: fan.office

Automation: turn off the porch light after everyone leaves

When the home zone becomes empty after sunrise, this automation turns off the porch light.

  • Trigger: Zone occupancy cleared
    • Zone: Home (zone.home)
  • Condition: Sun is above horizon
  • Action: Turn off light
    • Target: Porch light (light.porch)
YAML example for turning off the porch light after everyone leaves
AutomationAutomations in Home Assistant allow you to automatically respond to things that happen in and around your home. [Learn more]
alias: "Turn off the porch light after everyone leaves"
triggers:
  - trigger: zone.occupancy_cleared
    options:
      zone: zone.home
conditions:
  - condition: sun
    before: sunset
    after: sunrise
actions:
  - action: light.turn_off
    target:
      entity_id: light.porch

Still stuck?

The Home Assistant community is quick to help: join Discord for real-time chat, post on the community forum with the trigger 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 triggers or suggest the right one when you describe what you want in plain language.

Related triggers

These triggers work well alongside this one: