Home Assistant

Build and test a door-left-open reminder using two virtual switches before buying any sensors.

Home Assistant logo

Ingredients

Follow a part’s name for an introduction and compatibility notes.

  • 1
    Computer and local network

    Existing computer capable of running Home Assistant OS in a virtual machine, or an existing Home Assistant host.

  • 1 installation
    Home Assistant

    Free software; a browser on the same private network.

Home Assistant connects devices and turns their states into dashboards and automations. You can learn its central ideas without a smart bulb, subscription, or Raspberry Pi. In this exercise, two virtual switches stand in for a door contact and an alert.

Choose an installation

Use the official installation guide for your hardware. Home Assistant OS in a virtual machine is one way to reuse a computer; it must remain running for automations to work. Downloading a free application does not provide an always-on computer for free. Keep the first installation on your private network, create your own account, and save the recovery information.

Create a pretend door and alert

  1. Open Settings → Devices & services → Helpers. Create a Toggle helper named Demo door, then another named Demo alert.
  2. Open each helper’s settings and confirm its entity ID. This example uses input_boolean.demo_door and input_boolean.demo_alert. Rename the entity IDs or adjust the YAML below to match.
  3. Add both helpers to a dashboard. Treat Demo door’s on state as “open,” and Demo alert’s on state as “reminder active.” Start with both off.
  4. Under Settings → Automations & scenes, create an empty automation. Open its YAML editor and replace the automation with the example below. Save it and make sure it is enabled.
alias: Demo door left open
triggers:
  - trigger: state
    entity_id: input_boolean.demo_door
    to: "on"
    for: "00:00:20"
conditions: []
actions:
  - action: input_boolean.turn_on
    target:
      entity_id: input_boolean.demo_alert
mode: single

The trigger waits for a continuous 20 seconds of open state. There is no real door sensor yet: the dashboard switch supplies the input. Create a second automation to clear the alert when the pretend door closes:

alias: Demo door closed
triggers:
  - trigger: state
    entity_id: input_boolean.demo_door
    to: "off"
conditions: []
actions:
  - action: input_boolean.turn_off
    target:
      entity_id: input_boolean.demo_alert
mode: single

Prove the behavior

  • Turn Demo door on for 10 seconds, then off. Demo alert should remain off.
  • Turn the door on and leave it on for at least 20 seconds. The alert should turn on.
  • Turn the door off. The alert should clear.
  • Open the automation’s traces to see which trigger and action ran. “Run actions” tests the action directly; it does not test the 20-second trigger.

A state trigger’s for wait does not survive an automation reload or Home Assistant restart. This is a learning exercise, not a durable timer. A real reminder must decide how to handle a door already open at startup, an unavailable sensor, and a lost notification. See the state-trigger documentation before choosing a persistent design.

Replace one pretend part at a time

Once the logic works, replace Demo door with a real contact sensor entity. Check whether its states are actually on/off; displayed words such as “Open” are friendly labels. Then replace Demo alert with a notification action and test the receiving device. Keep the dashboard input available as a way to reproduce failures without repeatedly opening a physical door.

If nothing happens, check the exact entity IDs, enabled state, automation trace, and how long the input stayed on. If notifications are late, separate automation execution time from phone delivery time. Next, learn how to inspect and transform messages or how to plan for disconnected devices.