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

iTechGuides is reader-supported. When you buy through links on our site, we may earn an affiliate commission. As an Amazon Associate I earn from qualifying purchases. Learn more

Use an automation condition when you need a one-time availability gate, a condition action when you need to check again later, wait_template when an already-satisfied state should pass immediately, and wait_for_trigger when only a new event should release the sequence. Put a timeout on every wait that must be bounded, then either stop with continue_on_timeout: false or branch on wait.completed.

The four building blocks and when to use each

Home Assistant automations and scripts use the same sequence building blocks. Availability logic is therefore a question of timing: do you want to decide once, check again at a later point, wait for a condition, or wait for a new event? The distinction matters because these blocks do not behave interchangeably.

Need Use Important behavior
Decide whether to run when a trigger starts Initial automation conditions The check is made once. A later state change does not recheck it or start a run.
Check availability after earlier actions A Condition building block in actions If it fails, the remaining sequence stops.
Wait for a predicate that may already be true wait_template An already-true template completes immediately; otherwise it is reevaluated as referenced state changes.
Wait for a new event from this point onward wait_for_trigger An existing target state does not satisfy the wait; a new matching trigger must occur.
Prevent an endless wait timeout By default, the sequence continues after the timeout. Set continue_on_timeout: false or branch explicitly.

Home Assistant describes a condition as checking whether something is true “right now.” See the official automation conditions documentation for the evaluation rules and examples.

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

Check availability before the automation runs

Put a condition in the automation’s top-level conditions when the actions should run only if an entity is acceptable at trigger time. This is a point-in-time gate, not a wait and not a retry mechanism. If the device is unavailable when the trigger fires, the run is rejected. If it becomes available a few seconds later, Home Assistant does not automatically rerun the same trigger.

#1 Best Overall
Sale
Compressed Air Duster,130000RPM Super Power Cordless Air Duster,Rechargeable Brushless Blower,3 Gear Adjustable Blower with LED Light,Dust Remover for Computer/House/Outdoor/Car
  • Powerful Turbo Fan:CAGIWIRU Electric Air Duster have reached speed up to 130000RPM,Can efficient remove dust and debris.With LED light and Three Adjustable Speed to meet with different cleaning tasks.
  • With Attached USB C Fasting Charging cable.Charing 3 hours,Enjoy up to 240 minutes of use on the lowest setting, For third speed can use for 25mins.with four charging options to meet with your needs.
  • Wide Application: attached 5 different nozzles,making it suitable for a variety of scenes, such as car,pet, pc, keyboards, and other electronic devices. It also serves for office and home clean duster.
  • Handy Design & Portable:Cordless air duster electric nozzle is Light weight and small size, design and comfortable to hold and space saving, convenient to carry around. You can put it in your room or inside the car without taking up space.
  • Economical &Reusable: Built durable materials with a long-lasting battery,our CAGIWIRU air duster it's a sustainable alternative to disposable air cans.

The exact state names depend on the integration. Many entities expose unavailable, but verify the states shown by your installation before writing the template. Replace every example entity ID below with an entity from your system.

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 template allows every state except unavailable. If your integration has another failure state that should also block the action, include that state in the condition logic rather than assuming all integrations use the same vocabulary. Conversely, if an unknown state should be treated as unsafe, write a positive allow-list for the states you consider usable.

When a later availability change should start the work

A startup condition never waits for recovery. If “the sensor becomes available” is itself the event that should initiate the work, create a trigger for that state change and use conditions only for additional gates. This separates the event that starts the automation from the checks that decide whether the resulting actions are safe.

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

Check again inside the action sequence

An initial condition can become stale while earlier actions are running. For example, a sequence may turn on a relay, wait for another device, and only then attempt an operation that requires the original sensor to remain available. Add a Condition building block at that later point to make a fresh decision.

alias: Recheck before the final action
triggers:
  - trigger: state
    entity_id: binary_sensor.example_trigger
    to: "on"
conditions: []
actions:
  - action: script.prepare_device
  - condition: template
    value_template: "{{ not is_state('sensor.example_device', 'unavailable') }}"
  - action: light.turn_on
    target:
      entity_id: light.example

If the condition fails, Home Assistant stops the remaining sequence. That behavior is useful when “do nothing further” is the correct result. It is not suitable when a failed check needs an explanation, cleanup, or alternate action.

Rank #2
EVEO® Screen Cleaner Spray Kit (Streak-Free) TV Screen Cleaner for Smart TV, Lcd, LEd, Oled | Computer Screen Cleaner Spray and Wipe Microfiber Cloth - TV, Monitor, Laptop, iPad, Car - 6.7oz 1 Pack
  • Screen Cleaner is Your Screen’s New Bestfriend! - EVEO is proud to present a screen cleaner that’s perfectly suited for your TV. Meet your new screen cleaner, computer screen cleaner, laptop cleaner, iPad cleaner, Macbook,tv cleaner or any other electronic device. Our screen cleaner spray and wipe along with the included plush microfiber cloth, easily removes dust, fingerprints & other smudges on the screen’s surface. Clean effectively for a streak-free screen
  • Gentle on your Screens - Our screen cleaner spray and wipes is compatible to be used even for the most sensitive LCD, LED, CRT, and OLED screens in proper use. Be at ease knowing that this product is compatible with all the major brands: LG, SONY, Samsung, Sharp, iPad, iPhone, Android screens, Kindle, PC monitors - we’ve got you covered! Can be used as LCD screen cleaner, tv cleaner, smart tv screen cleaner, and more
  • Premium Super Soft Plush Microfiber Cloth - Included in this efficient screen cleaning kit. This screen cleaner spray and wipe has our signature plush microfiber cloth specially designed to comply with screens and monitors and leave them streak-free. Has been shown to effectively absorbs stubborn stains, zero streaks, and no fiber shedding. Always use this together with our screen cleaner for the best results
  • Easy-to-Use Screen Cleaner Kit + microfiber cleaning cloth - The EVEO Screen Cleaning Kit will easily be your new favorite tool when it comes to taking care of the things you love most, quick and easy solution for a streak-free screen. Simply screw on the sprayer gun on the screen cleaner bottle. Spray the cleaning liquid onto the microfiber cloth, then wipe the screen until desired cleanliness & shine is achieved.
  • Quality Screen Care Kit Worth Purchasing - Enjoy a convenient Screen Cleaner anytime, anywhere you need it. Your satisfaction is our top priority. We stand behind the quality of our products and that’s why, you shouldn’t be worrying at all. We manufacture the Best Screen Cleaner. and can be used for laptop cleaning kit, laptop screen cleaner, tv screen cleaner for smart tv. MacBook screen cleaner, monitor cleaner or screen cleaner spray for electronic devices with microfiber cleaning cloth

Use an explicit branch for fallback work

Use an If-then or Choose building block when the unavailable path needs its own actions. Put the availability test in the branch condition, keep the normal actions in then, and put notification or recovery actions in else. An explicit branch prevents a fallback from being accidentally executed after a successful wait or check.

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 action was skipped."

Use a plain Condition action when the sequence should simply stop. Use If-then or Choose when the failed path is part of the design.

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

Wait for availability with a bounded template wait

Choose wait_template when the condition itself is the thing you want to test and the current state should count. The template is evaluated as the wait starts. If it is already true, the automation continues immediately. If it is false, Home Assistant reevaluates it when entities referenced by the template change; time-based template functions have additional reevaluation behavior documented in the automation and script actions documentation.

This example waits up to 30 seconds for an entity to leave unavailable, then uses wait.completed to choose the outcome:

alias: Wait briefly for a device to recover
triggers:
  - trigger: state
    entity_id: binary_sensor.example_trigger
    to: "on"
conditions: []
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: "Device did not become available before the timeout."

The 30-second value is an illustrative configuration, not a universal recommendation. Choose a deadline that fits the device’s normal recovery time and the consequence of delaying the rest of the automation. A short deadline limits blocking but may reject a device that normally needs longer; a long deadline gives recovery more time but keeps the run active longer.

Rank #3
Sale
BladeHawks RGB Gaming Mouse Pad Extra Large Extended 31.5x12 Inch-Black | LED mouse pad with 14 lighting modes, covers keyboard & mouse, anti-slip rubber base, waterproof surface, USB powered
  • 【Large size】:Measuring 800 x 300 mm/ 31. 5×12 inches, which is wider and taller than others. Large mouse pad can perfectly fit your keyboard and mouse of any size, and there is also ample space for peripherals such as phones, tablets, etc.
  • 【LED backlight mouse pad】:Blade Hawks RGB mouse pad provides 7 static modes and 7 dynamic modes will give you the options you are looking for. Power-off memory function remembers the last lighting mode you selected. The super glow fiber Chroma will give you a colorful gaming setup that you want.
  • 【Anti-slip rubber base】:Made from Natural rubber, this gaming mousepad will firmly grip your desktop, allowing you to enjoy the ultimate precision in the games you are most passionate about. It also comes with a texture that enhances this ability even further.
  • 【Smooth and waterproof surface】: Micro-textured cloth surface, for extremely precise mouse control and a smooth movement. When liquid splashes on the gaming mouse pad, it forms water droplets and slides down. Will not delay your work or gameplay.
  • 【Plug and play】: This mouse and keyboard pad is powered by USB, plug and play, no driver required. One button control light modes. Press one time to change the lighting mode, press twice to change the brightness, press and hold about 3 seconds turn ON/OFF.

Stop automatically when the deadline expires

Waits continue after timeout unless you change the default. Set continue_on_timeout: false when no later action should run after a failed wait:

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.
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 is reached only when the template succeeds before the deadline. If you need a notification, logging action, or cleanup on timeout, keep the default continuation and branch on wait.completed instead. The default and wait-result behavior are covered in Home Assistant’s script syntax documentation.

Wait for a new state-change event

Use wait_for_trigger when the automation must observe a new trigger event after the wait begins. This is different from testing the current state. If the target state is already present when the wait starts, the existing state alone does not complete the wait.

alias: Wait for a fresh ready event
triggers:
  - trigger: state
    entity_id: binary_sensor.example_trigger
    to: "on"
conditions: []
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 “ready” must be a fresh transition—for example, when an upstream process signals completion and an old on state should not be reused. If the device is already ready and that should be enough, use a wait_template such as {{ is_state('binary_sensor.example_device_ready', 'on') }} instead.

Inspect the result of a trigger wait

After a wait with a timeout, Home Assistant exposes information through the wait variable. wait.completed indicates whether the template or trigger finished the wait. wait.remaining reports the unused portion of the timeout. For wait_for_trigger, wait.trigger contains the trigger that completed the wait and is none on timeout.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #4
Sale
Vaydeer Wrist Rest for Keyboard and Mouse, Computer Ergonomic Wrist Support Pad, Soft Memory Foam Arm Cushion for Desk, Palm Hand Office Laptop Typing
  • 【Softer and More Comfortable】Vaydeer wrist rest has unique diamond pattern, which is the combination of softness and aesthetics. The materials of wrist rest are improved into higher quality memory foam and covered with silky smooth lycra. The computer wrist rest makes you as comfortable and cushiony as like rest your wrists on clouds.
  • 【Ergonomic Wrist Saver】The wrist rests for keyboard and mouse comes with a 17.32×3.15×0.83 inch keyboard wrist pad and a 5.94×3.15×0.83 inch mouse wrist support. Based on ergonomic design, the unique concave shape is the perfect fit for your wrist joints. The wrist rest pad fits most computer keyboards and laptops, improve hand and wrist posture, release your wrist and arm stress.
  • 【Non-Slip Rubber Bottom】Featuring an anti-skid silicone base on the bottom, this wrist keyboard support stays firmly in place on your desk, preventing the padding from sliding around, ensuring stable and consistent wrist support during extended computer sessions.
  • 【Better Experience & Pain Relief】Our keyboard arm rest is beneficial to alleviate the soreness caused by direct contact and friction between your arm and a hard desk surface, reducing the risk of wrist fatigue or carpal tunnel. The soft texture of memory foam can evenly distribute the pressure around your wrists and provide good support with just enough give.
  • 【Helpful in Multiple Scenarios】Whether you're working, studying, writing, typing, gaming, this keyboard and mouse rest combo is an essential accessory to add comfort and support to your hands and wrists. It’s also a great gift for men, women, family, friend, coworker, gamer, teacher, etc.
actions:
  - wait_for_trigger:
      - trigger: state
        entity_id: binary_sensor.example_device_ready
        to: "on"
    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: "No new ready event arrived before the deadline."

Use wait.trigger when several trigger alternatives are listed and the follow-up action depends on which one fired. Test wait.completed before reading trigger details so the timeout path cannot be mistaken for a successful event.

Design timeout behavior deliberately

Fail closed

Fail closed when continuing without a confirmed available or ready device could cause an unsafe, misleading, or irreversible action. Set continue_on_timeout: false and place dependent actions after the wait. The sequence ends when the deadline is reached.

Fail with a controlled fallback

Keep continuation enabled when timeout should produce a separate outcome: notify someone, record a diagnostic message, turn off a preparatory device, or select a degraded path. Branch on wait.completed; do not put fallback actions unconditionally after a wait, because they would also run after success.

Share one overall deadline across several waits

When a workflow has multiple sequential waits, use the remaining time from the first wait rather than giving every step a fresh full timeout. The wait.remaining value is intended for this pattern. Check whether the first wait completed, then use the remaining value for the next bounded wait and branch again on its result. This keeps the total automation run within the promised window instead of allowing several independent deadlines to accumulate.

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

Design the branches so that a timeout at any stage has one unambiguous outcome. If the first wait times out, do not proceed to a second wait merely because continuation was left at its default.

Best Value
Sale
Under Desk Cable Management Tray No Drill, Metal Mesh Cable Management Under Desk with Clamp Mount, 2 Hole Cable Tray with Wire Management and Cord Organizer for Home Office Standing Desk
  • 【No Drill Mounted】Cable management tray can be assembled in as little as 3 minutes or less-simply. Side clips easily clampe the edge of desk, pass through the holes on the sides, and secure excess cables with baskets. Desk cable management supports inward or outward installation to meet your needs in different scenarios, and provides you with great convenience when collecting and organizing wires.
  • 【Rubber Pad Protects Desk】Wire organizer under desk built-in soft rubber pads on the clamp protect your desk from scratches, so you will not damage your furniture or office.
  • 【Sturdy and Beautiful】Cord management under desk is made of high-quality carbon steel and holds about 15 lbs. The wire basket has 2 holes on each side of the tray to enable your cables to pass freely. Cable baskets are suitable for desk thickness use from 0.4" to 2.4".
  • 【Space Saving & Keep Organized】Desk cable management tray holds all your power cords, outlet strips, USB hubs and computer transformers hidden from your feet, and the data cables will not enter the vacuum cleaner to keep your desk clean and tidy. Desk wire organizer is also suitable for use in the kitchen and outdoors.
  • 【Reduce Safety Risks】Cable tray under desk keeps all plugs away from your kids, no more worry about tripping. Using 2 holes wire tray saves extra space, helps you easily cabling and wire protection. The mesh design is not easy to accumulate dust, but avoids safety accidents caused by messy wires.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Understand interruptions, automation mode, and restarts

A wait is an active automation run, not a durable job stored for later completion. A Home Assistant restart stops scripts and automations that are waiting; a pending wait should not be described as resuming automatically after the restart.

Automation mode also affects an active wait. In restart mode, a new trigger cancels the previous run, including its current wait or delay, and starts a new run. If a wait seems to vanish when another trigger arrives, inspect the automation’s mode and the trace for the cancelled run. The official automation troubleshooting documentation explains traces and common interruption symptoms.

These interruptions are separate from a timeout. A timeout means the run reached its configured deadline. A cancellation or restart means the wait ended because the run itself was stopped, so do not treat those situations as equivalent success or timeout signals in operational messages.

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

A complete availability-aware pattern

The following pattern combines a startup gate, a bounded recovery wait, and an explicit success or timeout branch. The initial condition avoids starting work when the device is known to be unavailable. The wait handles a device that becomes unavailable after the trigger. The branch ensures that the timeout path sends a notification instead of silently continuing.

alias: Operate only after the device is ready
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: script.prepare_device
  - 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: "The device was not available within 30 seconds."

Use this structure only when the initial gate and later wait represent two different decisions. If the device is allowed to be unavailable at trigger time and should simply recover within the deadline, remove the top-level condition and keep the wait. If no recovery is acceptable, replace the wait with a condition action that stops immediately.

Troubleshoot the most common failures

Symptom Likely cause Correction
The wait appears stuck even though the entity is already in the target state. The sequence uses wait_for_trigger, which requires a new event. Use wait_template when the current state should satisfy the wait.
Actions run after the deadline. continue_on_timeout was omitted, so its default of true applied. Set it to false, or branch on wait.completed before dependent actions.
A later availability change never starts the automation. The availability test was only an initial condition. Add a trigger for the relevant state change if recovery should initiate a run.
The sequence stops before the final action. A Condition building block inside the action sequence evaluated false. Confirm the entity ID and actual state, or replace the stop-only condition with If-then/Choose logic.
The wait disappears when another trigger arrives. The automation is in restart mode and the new run cancelled the old one. Inspect the automation mode and trace; design the workflow with cancellation in mind.
The wait is gone after Home Assistant restarts. Waiting scripts and automations are stopped by a restart. Decide how a fresh trigger or startup routine should reconstruct the work; do not assume the old wait resumes.

Entity IDs and state values vary by integration. Verify them in your instance, then use the automation trace to see which condition, wait, and branch actually ran. Traces are particularly useful for distinguishing a false condition, a timeout, and a cancelled run.

Testing checklist before relying on the automation

  • Run the automation while the checked entity is available and confirm that the normal action executes.
  • Force or observe the entity’s unavailable state and verify that the startup condition blocks the run when appropriate.
  • Test an already-available entity with wait_template; it should pass without waiting for a new transition.
  • Test an already-on target with wait_for_trigger; confirm that it waits for a new matching event instead of accepting the existing state.
  • Let each wait reach its deadline and verify whether the intended behavior is stop, notification, cleanup, or fallback.
  • Trigger the automation again during an active wait and inspect the trace if the mode may cancel the first run.
  • Check the entity’s real state names and the exact entity IDs used in every template.
  • Restart Home Assistant during a test only if you have a safe recovery plan, and verify how a new trigger should rebuild the workflow.

For implementation details and additional syntax, consult Home Assistant’s building blocks and actions documentation, its conditions guide, and the troubleshooting guide.

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.

Choose the pattern by the decision you need

  • “Should this run start now?” Use an initial condition.
  • “Is it still safe after these earlier steps?” Use a Condition action.
  • “Wait until this predicate is true, even if it is true already.” Use wait_template.
  • “Wait for a fresh signal from this point onward.” Use wait_for_trigger.
  • “Never wait forever.” Add a timeout.
  • “What should happen when time runs out?” Choose between continue_on_timeout: false and an explicit wait.completed branch.

Keeping those decisions separate makes an automation predictable: conditions gate runs, waits pause them, timeouts bound the pause, and branches define what failure means.

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.