YAML Butler
← All guides

Notify when a door is left open in Home Assistant

Create a useful delayed door alert, choose the right notification action, and avoid repeated noise.

A door-open alert should arrive after an unusual opening, rather than every normal trip through the doorway. The essential pieces are a contact sensor, a duration, and a notification destination. Use a low-stakes test door or a brief test interval first. Once you trust the signal, tune the delay to how the household actually uses that door.

Confirm the raw contact state

Look up the door sensor in Developer Tools. A contact sensor generally reports "on" when open and "off" when closed, even if the dashboard uses friendly labels. Open and close the door while watching its raw state. Check for unavailable periods and low battery warnings. A flaky sensor can cause a pending duration to restart or miss an opening entirely, so settle hardware issues before relying on the alert.

Put the duration on the trigger

A state trigger with a five-minute for duration starts the automation only after the door has continuously remained open that long. Closing the door before the duration ends cancels that pending trigger. This is simpler than starting an action delay and remembering to check the door again afterward. Quote the on state and duration. Change the duration temporarily to a few seconds while testing, then restore the intended interval.

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: Front door open reminder
description: Send one notification after the front door stays open for five minutes.
triggers:
  - trigger: state
    entity_id: binary_sensor.front_door
    to: "on"
    for: "00:05:00"
conditions: []
actions:
  - action: notify.mobile_app_phone
    data:
      title: Door reminder
      message: The front door has been open for five minutes.
mode: single

Choose a real notification destination

The notify.mobile_app_phone action below is a placeholder for a Companion App device. Your installation will have its own action name. Find it in Developer Tools under Actions and send a harmless test message. Some notification integrations use notify.send_message with a target entity instead, so use the format your integration documents. A successful action call also does not guarantee the phone will display an alert immediately; operating-system settings still matter.

Decide whether one alert is enough

This rule sends one message per qualifying opening. It does not automatically repeat every five minutes. That is often the least annoying behavior. If you need reminders, use a bounded repeat with a fresh door-state check and a clear stopping condition. Consider a notification tag to update an existing message instead of filling the notification tray. Test what happens when the door closes during a reminder interval.

Account for restarts and quiet hours

The pending for duration does not survive Home Assistant restarting or automations reloading. For a more durable reminder, persist the opening deadline in a helper and evaluate it after startup. Quiet hours can be a condition, but then a door that qualified during quiet hours will not automatically produce a message when morning arrives. Add a separate morning check if that is the behavior you need.

Keep the message useful and proportionate

Name the door and the elapsed interval in the notification. Avoid sending precise household details to a destination you have not reviewed. This is a convenience reminder, so keep an appropriate independent arrangement for security or other critical needs. During testing, check both the automation trace and the phone. If the trace shows a successful action but no visible message, investigate notification permissions, battery restrictions, and the destination rather than rewriting the trigger.

Make a repeatable test checklist

Use three tests before increasing the delay: an opening shorter than the interval should remain silent, a longer opening should send one message, and a close followed by another long opening should send a new message. Repeat the last test after changing the sensor battery or notification destination. If you later add several doors, include the door name in each alert and confirm each sensor independently. A generic message that only says something is open becomes much less useful once multiple contact sensors share the same destination.

Further reference: official Home Assistant documentation.

Common questions

Will closing the door cancel the pending alert?

Yes, if it closes before the continuous for duration completes. A message already sent remains on the phone.

Why is my notify action missing?

The action depends on your installed notification integration and device name. Look up the actual action in Developer Tools.

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 ↗