Home Assistant: Use Delay Instead of Timers for Simple Automations

The Problem: Overcomplicating a Simple Automation

You want to turn something on, leave it running for a few hours, then turn it off. Easy, right?

Many Home Assistant users reach for timers or complex time triggers to achieve this. But when all you need is “do A, wait, then do B”, there’s a simpler way: the delay action.

The Wrong Way

Here’s a real example. I wanted my Shelly Pro 1PM to run the hot water system between 9:00 AM and 2:00 PM — a 5-hour window for solar-heated hot water diversion.

My first attempt combined a time trigger, a timer, and a switch-off action all in one automation:

alias: Hot water daytime run
triggers:
  - trigger: time
    at: "08:45:00"
actions:
  - action: switch.turn_on
    target:
      entity_id: switch.shellypro1pm_80f3dac87e8c
  - action: timer.start
    target:
      entity_id: timer.hot_water_daytime
    data:
      duration: "05:00:00"
  - action: switch.turn_off
    target:
      entity_id: switch.shellypro1pm_80f3dac87e8c
mode: single

Why this fails:

  • Home Assistant runs all actions sequentially with no implicit delay between them.
  • The switch turns ON, the timer starts counting down, and the switch turns OFF — all within milliseconds at 08:45:00.
  • The timer just runs in the background doing nothing. You’d need a second automation to catch the timer.finished event and only then turn off the switch.

That’s two automations plus a timer helper entity. Overkill.

The Right Way: Just Use delay

Home Assistant has a built-in delay action that pauses the automation for a specified duration. The fix is three lines:

alias: Hot water daytime run
description: Turn on hot water at 8:45 AM, run for 5h15m, then turn off.
triggers:
  - trigger: time
    at: "08:45:00"
actions:
  - action: switch.turn_on
    target:
      entity_id: switch.shellypro1pm_80f3dac87e8c
  - delay: "05:15:00"
  - action: switch.turn_off
    target:
      entity_id: switch.shellypro1pm_80f3dac87e8c
mode: single

That’s it. One automation. No timer helper. No second automation. The delay: "05:15:00" pauses execution for 5 hours and 15 minutes, then continues to the switch-off action.

When to Use delay vs. Timers

Use delay Use a Timer Helper
One-shot: do it once, wait, finish Multiple automations need to know the timer state
Simple on-wait-off sequences You want the countdown visible on a dashboard
No need to track remaining time Timer needs to persist across HA restarts (delay survives but is less visible)
All three conditions above: just use delay Cross-automation coordination (start in one, finish triggers another)

Real Example: Shelly Hot Water Solar Diversion

The automation above runs daily on a Shelly Pro 1PM (flashed with ESPHome) controlling a 3.6kW hot water element. The 5h15m window covers peak solar production hours, ensuring excess solar energy heats water instead of being exported to the grid for peanuts.

Paired with another automation that checks solar export levels, this setup diverts power that would otherwise go to waste.

delay Syntax Options

All valid formats:

# Hours:minutes:seconds
delay: "05:15:00"

# Seconds only
delay: 18900

# Template-based (dynamic delay)
delay:
  minutes: "{{ states('input_number.hot_water_duration') | int }}"

# Fixed minutes/seconds objects
delay:
  hours: 5
  minutes: 15
  seconds: 0

Key Takeaways

  • If your automation is “turn on, wait X time, turn off” — use delay.
  • If you need other automations or dashboards to know the timer is running — use a timer helper with separate ON/OFF automations.
  • delay survives Home Assistant restarts — it resumes where it left off.
  • Don’t create extra helper entities when the built-in delay action does the job.

Posted

in

by

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *