DriversRecommendedOutdated drivers can make a good PC feel brokenScan driver issues before chasing fixes manually.Scan NowHalloween DealsAmazon USHalloween week deals: useful picks before month-endAmazon US: current deals, useful picks and tech finds.Check DealsSlow PC?RecommendedPC slow today? Run a repair scan before it gets worseResolve common Windows issues and optimize system performance.Scan Now×
FREEDOM251

Freedom251 › Blog › Automation

How to Add Availability Checks and Timeouts to Home Assistant Automations

By Freedom251 Team · · 12 min read

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Use an automation condition when you need a point-in-time availability gate, a wait_template when the current state may already satisfy the requirement, and wait_for_trigger when you need a new event to occur. Add a timeout to every wait that must not run indefinitely, then either set continue_on_timeout: false or branch on wait.completed so a timeout has an intentional outcome.

Choose between a check, a wait, and a timeout

Home Assistant automations and scripts use the same action building blocks, including conditions, waits, and branching actions. The right pattern depends on whether you are deciding immediately, pausing for a state, or listening for a new event. The official automation and script building-block documentation describes these actions and their variables.

As an Amazon Associate I earn from qualifying purchases.

What you need Use Important behavior
Decide once when a trigger starts a run Initial automation condition The condition is evaluated at that point. Later availability does not retry or restart the run.
Check again after earlier actions Condition action in the sequence A failed condition stops the remaining sequence.
Wait for a predicate that might already be true wait_template The wait completes immediately when the template is already true.
Wait for a new state change or other event wait_for_trigger An already-present state does not satisfy the wait; a new matching trigger must occur after the wait starts.
Prevent an unbounded wait timeout By default, the sequence continues after the timeout.
Stop automatically when the deadline expires continue_on_timeout: false The remaining actions are not run after a timeout.
Perform fallback work on timeout Test wait.completed Use an explicit success and timeout branch so notifications or cleanup run only when appropriate.

Home Assistant summarizes a condition as checking whether something is true right now. That point-in-time meaning is the key distinction between a condition and a wait; the official conditions documentation explains the evaluation model.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Gate the automation when the trigger starts

Put an availability check in the automation-level conditions list when the actions should run only if the device is acceptable at trigger time. This is the simplest and cheapest guard: the trigger starts a run, Home Assistant evaluates the conditions, and the action sequence proceeds only if they pass.

#1 Best Overall
Sale
TOZO A1 Wireless Earbuds Bluetooth 5.3 Light Weight in Ear Headphones | IPX5 Waterproof,2 Mics for AI Calls,Immersive Premium Sound Bass Headset with Charging Case,32 EQ via App Black
  • [Ultra-Lightweight Ear Buds Designed for Small Ears] Each earbud weighs only 3.7g and features a compact, ergonomic in-ear design made especially for small ears. Secure, low-profile, and comfortable for workouts, all-day wear or overnight sleeping.The ultra-slim profile sits flush in your ear with no hard edges poking or rubbing, so you can even sleep on your side without discomfort.
  • [Immersive Stereo Sound with TOZO OrigX Technology] TOZO OrigX tuning delivers clear vocals, balanced mids, and natural stereo sound for music, podcasts, and videos.
  • [Long Battery Life for Daily Use] Get up to 7 hours of playtime on a single charge, with up to 32 hours total using the charging case—ideal for workdays, commuting, and extended listening sessions.
  • [Bluetooth 5.3 & Stable Connection] Bluetooth 5.3 provides fast pairing, stable wireless performance, and reduced dropouts as you move around home or office.
  • [Deep Bass with Clear Vocals] High-performance drivers produce punchy bass while keeping vocals clean and detailed for everyday listening.

Check that an entity is not unavailable

The exact entity ID and state names depend on the integration. Many entities expose unavailable while their source cannot be reached, but some integrations also use unknown or another state. Confirm the value in Developer Tools or the entity details before writing the condition.

alias: Run only when the device is available
triggers:
  - trigger: state
    entity_id: binary_sensor.example_trigger
    to: 'on'
conditions:
  - condition: template
    value_template: "{{ not is_state('sensor.example_device', 'unavailable') }}"
actions:
  - action: light.turn_on
    target:
      entity_id: light.example

This example is a gate, not a retry mechanism. If sensor.example_device is unavailable when the binary sensor turns on, the run is rejected. If the sensor becomes available ten seconds later, Home Assistant does not revisit the condition and does not start the automation again.

Start work when availability changes

If becoming available should itself launch the work, create a trigger for that transition instead of expecting a condition to notice it. For example, a state trigger can watch for the entity to change from unavailable to a usable state. Keep any additional conditions that must be true for the resulting run. This separates two jobs: the trigger detects the event, while conditions filter runs that should not proceed.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Account for acceptable states

Some devices have more than one usable state. A template condition can express that policy explicitly, such as allowing a sensor to be anything except unavailable and unknown, or requiring a readiness flag from the integration. Do not assume that every integration reports connectivity identically; inspect the entity’s actual state and attributes and encode the states that are valid for your installation.

Check availability again inside the action sequence

An automation may perform several actions before it reaches the device that matters. Add a Condition building block at that later point when availability must be rechecked after those earlier actions. A failed action condition ends the remaining sequence, so no later service calls are made.

Use a condition when stopping is enough

actions:
  - action: notify.notify
    data:
      message: 'The trigger was received; checking the device before continuing.'
  - condition: template
    value_template: "{{ not is_state('sensor.example_device', 'unavailable') }}"
  - action: light.turn_on
    target:
      entity_id: light.example

Here the notification runs first. If the device is unavailable when the condition is reached, the light action is skipped and the sequence ends. This is useful for a silent safety gate, but it does not tell anyone why the sequence stopped unless you add separate handling.

Rank #2
Sale
Smart Watch for Men Women Compatible with iPhone Samsung Android Phone 1.69 inch Full Touch Screen IP68 Waterproof Bluetooh Fitness Tracker Heart Rate/Sleep Monitor (Black)
  • 【IP68 Waterproof Multifunctinal Smart Watch】Torjalph fitness activity tracker smart watch is IP68 waterproof technology ,you can wear it when swimming,handwashing,it's rain-proof which means that you perform multiple exercise modes outside without worrying about sweat or rain corroding your fitness smart watch,and this watch equipped with a 230 mAh large capacity battery magnetic charging ,and this sports activity tracker watch can be used 5-7 days If fully charged.
  • 【Larger 1.83'' Full Screen Watch & Multi-dial Selection】1.83 inch full HD color touch screen smart watch for men / women provides excellent 240*284 resolution image quality ,This Bluetooth smart watch offers a better touch experience and remarkable immersion and ,more than 200 watch faces for you to choose from App"Da Fit ", you can change the dial style according to your mood to wear keeping the world on your wrist
  • 【Accurate Activity Tracker Smart Watch 】sports watch activity tracker uses sweat and dust resistant breathable silicone strap, our Fitness Tracker Smart Watch for Android iOS Phones supports 12 sports modes,walking,running,bicycle,swimming,badminton,basketball,football,rope skipping. This bluetooth calls smart watch for men women is lightweight and stylish, bringing more convenient and relaxing sports experience while also providing more protection.
  • 【Your 24 Hour Personal Daily Health Monitor】Fitness watch for women men full touch screen IP67 waterproof bluetooth smartwatch for Android iOS Phones with heart rate blood pressure monitor multifunction Andriod smart watch with steps counter sleep monitor sports fitness watch, monitoring blood oxygen saturation allows you to understand your physical condition in real time to track fitness progress ,to know your health status in time.
  • 【More Functions Bluetooth Call Smart Watch】This fitness activity smart watch full screen for iPhone and Android phones includes a bunch of new features including:The bluetooth smart watch can hang up the phone, receive and display WhatsAPP /Text /Facebook /Twitter /Messenger reminder.Support sedentary reminder, alarm clock, stopwatch, timer,weather information,music control, remote camera control compatible with Android 5.0 and above or iOS 9.0 and above smartphones.

Use If or Choose for a deliberate fallback

When failure should send a notification, perform cleanup, or use an alternate device, use an if or choose action rather than relying on a failed standalone condition. The branches make the intended success and failure paths visible in traces and prevent fallback actions from running accidentally.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
actions:
  - if:
      - condition: template
        value_template: "{{ not is_state('sensor.example_device', 'unavailable') }}"
    then:
      - action: light.turn_on
        target:
          entity_id: light.example
    else:
      - action: notify.notify
        data:
          message: 'The device is unavailable; the light was not switched on.'

Use choose when there are multiple mutually exclusive states, such as a primary device, a backup device, and a final notification. Each choice should test a condition that reflects the actual entity states in your system.

Wait until an entity becomes available, with a deadline

Use wait_template when the condition you care about could already be true when the wait begins. Home Assistant evaluates the template immediately and reevaluates it as referenced entities change. A template that is already true therefore passes without an unnecessary delay.

Wait for the entity to leave the unavailable state

actions:
  - wait_template: "{{ not is_state('sensor.example_device', 'unavailable') }}"
    timeout: '00:00:30'
  - if:
      - condition: template
        value_template: "{{ wait.completed }}"
    then:
      - action: light.turn_on
        target:
          entity_id: light.example
    else:
      - action: notify.notify
        data:
          message: 'The device did not become available before the timeout.'

The 30-second value is an illustrative configuration, not a universal recommendation. Choose a deadline based on the integration’s normal recovery time and the consequences of delaying the automation. The template must match the integration’s real behavior: if a device reports unknown during startup, checking only for unavailable could allow the sequence to continue too early.

Understand what the timeout does

A timeout ends the wait; it does not automatically decide what the rest of the automation should do. The default for continue_on_timeout is true, so actions after the wait continue unless you change that behavior or branch explicitly. The script syntax documentation describes this default and the wait variables.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

To abort the remaining sequence automatically, set continue_on_timeout: false:

Rank #3
New Bee Guitar Cable 10ft Electric Instrument Bass AMP Cord | 6.35mm Jack, Durable Design, Stage and Home Studio Use, Low Noise Shielded Electric Cord for Bass, Keyboard, Amp, Mixer
  • [Low Noise High Fidelity] New bee guitar cord with 22AWG oxygen-free-copper center conductors provides enhanced signal transfer, the PVC insulation material and the high-density stranded copper double shield provide noise rejection for quiet operation
  • [Ideal for Choice] New bee 1/4 straight and right angle metal connectors, ensures a secure connection in any instrument, pedal, or amp jack. L shape great fro on stage guitar stands
  • [Wide Compatible] Suitable for mixer, power amplifier, microphone, effector, decoder, equalizer, electoronic organ, electric guitar, electric bass and other electronic equipments. Widely used in the installation of smart home, karaoke speaker, professional stage audio, etc
  • [Easy Disassemble] Making incidental repairs quick and easy! Very nice, flexible cable
  • [Dont Hesite to Order] 24 hours customer services and professional technology team are standing by
actions:
  - wait_template: "{{ not is_state('sensor.example_device', 'unavailable') }}"
    timeout: '00:00:30'
    continue_on_timeout: false
  - action: light.turn_on
    target:
      entity_id: light.example

With this form, the light action runs only if the template becomes true before the deadline. A timeout stops the sequence without executing that action. This is concise when no timeout notification, retry, or cleanup is required.

Use the wait result for success and timeout branches

When both outcomes need handling, leave continuation enabled and inspect wait.completed. It is true when the template or trigger completed the wait and false when the timeout expired. The wait context also provides wait.remaining, which is useful when several waits must share one overall time budget.

actions:
  - wait_template: "{{ not is_state('sensor.example_device', 'unavailable') }}"
    timeout: '00:00:30'
  - choose:
      - conditions:
          - condition: template
            value_template: "{{ wait.completed }}"
        sequence:
          - action: light.turn_on
            target:
              entity_id: light.example
    default:
      - action: notify.notify
        data:
          message: 'Availability wait timed out; no light command was sent.'

Keep timeout handling in the branch that owns it. If a later action assumes the device is available, place it only in the successful sequence. Put notifications, safe-state commands, or logging in the timeout sequence and make sure those actions do not themselves depend on the unavailable device.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Wait for a new event with wait_for_trigger

Use wait_for_trigger when the automation must observe a new trigger event after the wait starts. This is different from testing the entity’s current state. If the target state is already present, a trigger wait continues listening and does not finish merely because the entity is currently in that state.

Wait for a readiness transition

actions:
  - wait_for_trigger:
      - trigger: state
        entity_id: binary_sensor.example_device_ready
        to: 'on'
    timeout: '00:00:30'
    continue_on_timeout: false
  - action: light.turn_on
    target:
      entity_id: light.example

This pattern is appropriate when the transition to on is the event that matters, such as a device completing a calibration cycle. It is not appropriate when the sensor may already be on before the sequence reaches the wait; use wait_template for that case so an already-satisfied predicate passes immediately.

Inspect trigger details and timeout state

For a wait with a timeout, wait.completed indicates whether the wait finished normally and wait.remaining reports the remaining time. A wait_for_trigger also exposes wait.trigger; it is none when the timeout occurs. These values let you distinguish a matching event from an expired deadline and include useful context in notifications or logs.

Rank #4
BSIMB 15.6" Digital Family Calendar & Chore Chart, No Subscription Fees
  • Digital Family Calendar: BSIMB digital calendar wall touch screen puts an end to your chaotic life. Designed for busy families, the digital calendar keeps you organised and in step with your family. Assign different colours and tasks to each family member to make family scheduling easier and more intuitive.
  • Easy Setup and Auto-Sync: Plug in, connect to WLAN and auto-syn your electric calendar in minutes. Digital wall calendar compatible with Google calendar, iCloud calendar, Outlook calendar, Cozi calendar and Yahoo calendar. Add events directly on the device or through the ecalendar app. Electronic calendar stays current whether you're at work or traveling—no manual updates needed.
  • All-In-One Home Assistant: Smart calendar builds habits and encourage independence with personalised chores. Display daily meal plan to reduce the daily ‘What's for dinner?’ stress. To-do lists keep track of everything you want. Turning chores into valuable achievements with stars and rewards, making life easier and more enjoyable.
  • Manage Anytime Anywhere: BSIMB electronic calendar for family stay connected with the powerful ecalendar app. Access and manage your digital wall calendar anytime, anywhere with free features like stars & rewards, photo screensaver, chore charts, meals plans, to-do lists etc. Electronic planner paid features like Magic Import tailor advanced tools for users with special needs.
  • Stay in Touch with Loved Ones: Share photos or videos from your phone to electronic wall calendar with app, instantly update your life moment, and keep in touch with your family, especially those who are far away; you can also surprise your smart calendar digital wall by sending him a wish card; it's also great for keeping tech-illiterate elders in touch with the youngsters.
actions:
  - wait_for_trigger:
      - trigger: state
        entity_id: binary_sensor.example_device_ready
        to: 'on'
    timeout: '00:00:30'
  - if:
      - condition: template
        value_template: "{{ wait.completed and wait.trigger is not none }}"
    then:
      - action: light.turn_on
        target:
          entity_id: light.example
    else:
      - action: notify.notify
        data:
          message: 'No new ready event arrived within 30 seconds.'

The exact trigger fields must match the event you need. A state trigger can include a specific entity and target state; other trigger types can be used when the integration exposes an event rather than a state transition.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Combine several waits under one overall deadline

Sequential waits can accidentally create a much longer delay than intended. For example, two independent 30-second waits can consume up to a minute. Use wait.remaining from the first wait as the timeout for the next one when the entire operation must fit within a single budget.

actions:
  - wait_template: "{{ not is_state('sensor.example_device', 'unavailable') }}"
    timeout: '00:00:30'
  - if:
      - condition: template
        value_template: "{{ not wait.completed }}"
    then:
      - action: notify.notify
        data:
          message: 'The device did not become available in the overall time budget.'
    else:
      - wait_for_trigger:
          - trigger: state
            entity_id: binary_sensor.example_device_ready
            to: 'on'
        timeout: "{{ wait.remaining }}"
      - if:
          - condition: template
            value_template: "{{ wait.completed }}"
        then:
          - action: light.turn_on
            target:
              entity_id: light.example
        else:
          - action: notify.notify
            data:
              message: 'The device became available but did not report ready in time.'

When designing shared budgets, decide whether the second operation should be skipped if there is no time left and guard that case explicitly. A short remaining duration is still a valid timeout; it should not be treated as proof that the second event occurred.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Know what restarts and automation modes do to waits

A Home Assistant restart stops a pending wait

A running script or automation that is waiting does not survive every interruption. A Home Assistant restart stops scripts and automations that are currently waiting, so do not promise that a pending wait_template, wait_for_trigger, or delay will resume after startup. If the operation must recover, design a separate startup trigger or state-based automation that reconstructs the desired work from the current entity states.

Restart mode cancels the previous run

In automation mode: restart, a new trigger cancels the previous run. That cancellation includes an active wait or delay. If a second trigger arrives while the first run is waiting, inspect the automation mode and decide whether replacing the old run is really what you want. The automation troubleshooting documentation covers traces and run behavior.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Do not solve a cancellation problem by making the timeout longer. First decide whether each trigger should have its own wait, whether a new trigger should replace an old one, and whether a persistent state change can safely retrigger the work after an interruption.

Troubleshoot an availability wait that behaves unexpectedly

The wait is stuck even though the entity is already ready

  • Check whether the action is wait_for_trigger. It waits for a new matching event and ignores a state that was already present when the wait began.
  • If the current state should count, replace it with a wait_template that tests the predicate directly.
  • Verify that the template references the correct entity ID and the exact state spelling used by the integration.

Actions run after the deadline

  • Look for an omitted continue_on_timeout. Its default is true, so later actions normally continue after a timeout.
  • Set continue_on_timeout: false when the sequence should stop.
  • Alternatively, branch on wait.completed and place success-only actions inside the successful branch.

A wait disappears when another trigger arrives

  • Inspect the automation’s configured mode. In Restart mode, the newer run cancels the earlier run, including its wait.
  • Open the automation trace for both runs to see which trigger started each run and where the earlier sequence ended.
  • If overlapping runs are not intended, redesign the trigger or mode policy rather than relying on a longer timeout.

The wait vanishes after Home Assistant restarts

  • Treat a restart as an interruption; the pending wait is not guaranteed to resume.
  • Add a startup or state-based recovery path if the desired outcome can be inferred from the current entity states.
  • Make recovery idempotent so running it twice does not create duplicate notifications or unsafe service calls.

The condition passes or fails unexpectedly

  • Use Developer Tools to inspect the entity’s current state and attributes.
  • Test the condition at the point where it is used; an initial condition and a later condition can legitimately produce different results.
  • Review the automation trace to identify the exact branch that ran. Home Assistant’s troubleshooting guide documents trace-based diagnosis.

Test each path before relying on it

Test more than the normal success case. Temporarily make the device unavailable, start the automation, and confirm that the initial condition blocks the run or that the later condition stops the sequence. Then make the entity available before a template wait begins; it should continue immediately. Repeat with the entity unavailable, allow the timeout to expire, and verify the intended notification, cleanup, or stop behavior.

For wait_for_trigger, begin with the target state already present and confirm that the wait still listens for a new event. Then cause the transition after the wait starts and verify that the successful branch runs. Finally, trigger a second automation run while the first is waiting and check the trace if the automation uses Restart mode.

Keep test values separate from production values. A 30-second timeout is convenient for demonstrations, but a door lock, heating system, alarm, or irrigation controller may need a different deadline and a safer timeout action. Record the reason for the chosen duration in a comment so a later change does not silently weaken the safety behavior.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Practical design checklist

  • Use an initial condition for a decision that belongs at trigger time.
  • Use a condition action for a later point-in-time gate.
  • Use if or choose when a failed check needs an explicit fallback, notification, or cleanup path.
  • Use wait_template when an already-true predicate should pass immediately.
  • Use wait_for_trigger when only a new event after the wait starts should release the sequence.
  • Give every potentially indefinite wait a realistic timeout.
  • Remember that timeout continuation defaults to true; choose explicitly between stopping and branching.
  • Keep success-only service calls inside the success branch.
  • Check wait.completed, wait.remaining, and, for trigger waits, wait.trigger when you need to explain the outcome.
  • Account for Home Assistant restarts and the configured automation mode; an active wait can be cancelled.
  • Use traces and the actual entity states from your integration rather than assuming every device reports availability the same way.

A reliable pattern for most automations

For many device-control automations, the most predictable structure is: filter obviously invalid runs with an initial condition, perform early actions, recheck availability immediately before the device command, wait with a bounded template only when recovery is acceptable, and branch explicitly on success versus timeout. This prevents an unavailable entity from receiving a service call, prevents a sequence from waiting forever, and leaves a trace that explains why the action did or did not run.

The critical choice is semantic rather than syntactic. A condition answers, “Is this acceptable right now?” A template wait answers, “Keep checking until this predicate becomes true, but stop by this deadline.” A trigger wait answers, “Did the required new event happen after this point?” Once that distinction is clear, availability checks and timeout handling become composable parts of the same automation.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

AutomationavailabilityHome Assistantsmart hometimeoutsYAML

Leave a Reply

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

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Recommended PC Tool
Recommended PC Tool
Outdated Drivers Are Slowing You DownFree scan - exact matches
Windows Errors? Fix Them Before They SpreadFree repair scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.