Turn off lights when nobody is home
Use household presence carefully so the last person leaving turns off the lights you choose.
Turning off forgotten lights is a good first presence automation, provided it really waits for the last person to leave. A single phone going away does not prove the house is empty. Think about partners, children, visitors, and phones with dead batteries before choosing your presence signal. Start with a few nonessential lights and observe the result before expanding the target.
Choose a household presence signal
The home zone exposes a count of tracked people present. A numeric state trigger below one can represent an empty home, but only if the relevant residents have person entities and working location sources. Inspect zone.home in Developer Tools and compare it with reality. Another option is an explicit group of residents or a template helper combining your chosen presence sources. Use the same definition consistently across your away automations.
Allow for tracking delays
Location updates can arrive late, and a phone can briefly appear away while its connection changes. The example waits until the empty count has held for five minutes. This reduces accidental shutoffs, although it also means lights stay on briefly after departure. Pick a delay that fits your household. If privacy settings stop background location, fix the presence source rather than stacking increasingly complicated conditions around unreliable data.
A starting-point automation
Every entity ID below is an example. Replace it with your actual entity ID and review all settings before use.
alias: Lights off when home is empty
description: Turn off selected lights after five minutes with no tracked people home.
triggers:
- trigger: numeric_state
entity_id: zone.home
below: 1
for: "00:05:00"
conditions:
- condition: state
entity_id: input_boolean.guest_mode
state: "off"
actions:
- action: light.turn_off
target:
entity_id:
- light.living_room
- light.kitchen
mode: singleTarget a reviewed list
Use explicit light entity IDs when first testing. A whole-house target can include a porch light somebody relies on, a guest room, or a light supporting another routine. Leave out safety and access lighting until you have considered its purpose. An area target can simplify maintenance later, but remember that moving a light into that area changes what the automation controls. Review the scope whenever you add devices.
Make guests and exceptions visible
Create a guest_mode input_boolean if guests can remain while every tracked resident is away. Turn it on through a clear dashboard switch and include a condition requiring it to be off. A similar approach works for house sitters or a cleaner. Prefer an understandable helper over a hidden assumption about a particular phone. Give the helper a reminder or review routine so an old exception does not silently disable useful behavior forever.
Understand the trigger edge
A numeric state trigger fires when its threshold is crossed, not continuously while the value remains below it. If Home Assistant starts with the home already empty, this basic rule may not run. For recovery, add a Home Assistant start trigger and recheck the current household count in conditions. Think through the intended behavior before adding that trigger; a restart during maintenance should not surprise somebody who is still inside.
Test without leaving anyone in the dark
Temporarily target a spare lamp and watch traces during a real departure and return. Confirm that one person leaving while another stays does nothing. Test guest mode separately, then verify the quiet interval. The for duration is lost on restart or reload. If a departure must be remembered across restarts, use a persisted timestamp. Keep the initial rule modest and expand it only after several reliable days.
Separate absence from device failure
An unavailable tracker is not positive evidence that somebody left. Inspect how your chosen household signal treats missing updates and avoid converting every unknown state into away. You can add another source of presence evidence, but make its purpose clear: a router connection may confirm a phone is nearby without proving the person is home. If a light unexpectedly switches off, record the household count and relevant tracker states at that moment. That evidence is more useful than changing the timeout at random.
Further reference: official Home Assistant documentation.
Common questions
Why did the rule miss a departure?
Check person tracking, the zone.home count, and whether the count actually crossed below one. Inspect traces and tracking history.
How do I keep lights on for guests?
Add a guest-mode helper and require it to be off before the automation changes lights.
Put your own idea into YAML.
Describe your devices, timing, and exceptions. YAML Butler will give you a starting point to review.
Generate your automation ↗