This automation sends a push alert to our iPhones when all household members have left home but something was left on or open—for example, any light is still on or a door/window/garage is open.
How it works (overview):
- Tracks presence for all people via the Home Assistant Companion app (installed on each device with Location permission granted).
- When everyone is away, it checks a group of entities (lights, doors/windows, garage).
- If any of these are on/open, it sends a mobile notification to the iPhones so we can act quickly.
Why this is useful:
- It’s an easy safety and energy-saving catch-all—no more second-guessing whether a light is burning or a door is ajar after you’ve already left.
Prerequisites:
- Each person uses the Home Assistant Companion app on iOS, logged into the same HA instance.
- Location permissions enabled for presence tracking.
- Your lights and contact sensors (doors/windows/garage) are available in HA (ideally grouped for simple checks).
- Home Assistant must be reachable from the internet so iPhones can receive notifications and open deep-links reliably—e.g., via Home Assistant Cloud (Nabu Casa) or a secure reverse proxy with valid HTTPS. Ensure your HA host has a stable uplink.
The example below uses two people, but you can extend it to any number of household members by adding them to the presence group.
device_tracker.iphone1
device_tracker.iphone2Code-Sprache: CSS (css)
Mobile notification group:
notify.iphonesCode-Sprache: CSS (css)
You can optionally define an exclude_lights list to ignore specific lights in the “left on” check—useful for outdoor fixtures, always-on night lights, holiday decorations, or any lamp you don’t want to trigger alerts.
Configuration note:
Add the entity IDs you want to exclude to exclude_lights (e.g., light.porch, light.garden_spots, light.nightlight_bedroom). The automation will still check all other lights and any open doors/windows/garage.
/dashboard-leavehome/0 is a self build dashboard which shows all open things. You can link your own dashboard there
<code>alias: "[ALERT] Alle weg + etwas offen/AN → Hinweis (mit Ausschlussliste)"
triggers:
- trigger: template
value_template: |-
{% set d1 = is_state('device_tracker.iphone1', 'not_home')
and distance('device_tracker.iphone1','zone.home') > 0.1 %}
{% set d2 = is_state('device_tracker.iphone2', 'not_home')
and distance('device_tracker.iphone2','zone.home') > 0.1 %}
{{ d1 and d2 }}
for: "00:00:30"
conditions:
- condition: template
value_template: |-
{% set lights_on = states.light
| rejectattr('entity_id','in',exclude_lights)
| selectattr('state','eq','on')
| list | length %}
{% set contacts_open = states.binary_sensor
| selectattr('attributes.device_class','in',['door','window','opening'])
| rejectattr('entity_id','in',exclude_contacts)
| selectattr('state','eq','on')
| list | length %}
{{ lights_on > 0 or contacts_open > 0 }}
actions:
- variables:
open_items: >-
{%- set lights = states.light
| rejectattr('entity_id','in',exclude_lights)
| selectattr('state','eq','on')
| map(attribute='name') | list -%}
{%- set contacts = states.binary_sensor
| selectattr('attributes.device_class','in',['door','window','opening'])
| rejectattr('entity_id','in',exclude_contacts)
| selectattr('state','eq','on')
| map(attribute='name') | list -%}
{%- set items = (lights + contacts) -%} {%- if items | length == 0 -%}
nichts {%- else -%} {{ items | sort | join(', ') }} {%- endif -%}
- action: notify.iphones
data:
title: "🏠 Achtung: Niemand zu Hause"
message: "Offen/AN: {{ open_items }}."
data:
url: /dashboard-leavehome/0
push:
interruption-level: time-sensitive
apns_headers:
apns-collapse-id: away-open
actions:
- action: OPEN_DASH
title: 🔎 Jetzt prüfen
uri: /dashboard-leavehome/0
mode: single
variables:
exclude_lights:
- light.smart_garage
- light.example2
- light.outdoor
exclude_contacts: []</code>Code-Sprache: PHP (php)

