Routine That Causes a Loop: Detecting and Breaking Automation Cycles

When automations trigger each other in a loop, the cycle can be hard to spot until it is firing thousands of times. Here is how to detect and stop runaway automation cycles.

Routine That Causes a Loop: Detecting and Breaking Automation Cycles
Difficulty Advanced
Estimated time 45 minutes
Last tested May 2026
Verified on HomeKit, SmartThings

You set up routine A: when the kitchen motion sensor triggers, turn on the kitchen light. You set up routine B: when the kitchen light turns on, run the kitchen scene. The kitchen scene sometimes triggers the motion sensor (because it includes a light that reflects strongly off a mirror). Now routine A fires routine B, which alters the kitchen, which triggers routine A again. A loop. Your smart home executes the same actions repeatedly until you notice and intervene.

How loops form

Loops require two automations whose actions feed each other’s triggers. The classic pattern:

  1. Automation A triggers on event X
  2. Automation A executes action Y
  3. Action Y causes event Z
  4. Automation B triggers on event Z
  5. Automation B executes action that causes event X
  6. Loop

Less obvious loops involve multiple steps or shared state through intermediate devices.

Detecting active loops

If a loop is happening right now, you usually notice because:

  • Lights are flickering on and off rapidly
  • The hub is more active than normal (LED activity)
  • Your voice assistant or app shows many recent commands
  • The hub’s response time slows down due to action backlog

The fastest way to stop a loop in progress is to disable one of the automations involved. The loop breaks immediately.

The most common loop pattern

The most common loop is the motion-to-light reflection loop:

  1. Motion sensor triggers light on
  2. Light on changes ambient light enough to make a moving shadow appear
  3. Motion sensor triggers again
  4. Light is already on, no visible change, but the trigger fires
  5. Repeated motion triggers cause repeated light commands

This is less of a loop and more of a re-trigger storm. The fix is to add a cooldown to the motion trigger: do not fire again within 60 seconds.

Find the loop in logs

If your hub has detailed event logs, look for the same events firing repeatedly in a short time. The pattern is unmistakable: events at sub-second intervals, all from the same devices.

Hubitat and Home Assistant make this easy. SmartThings IDE is workable. Alexa and Google Home do not expose enough log detail to see loops directly.

The state-change versus event-trigger distinction

Some triggers fire on state change (“when light turns from off to on”). Others fire on any update to the device’s state (“when light state is reported”). The latter can fire even when the actual state did not change.

If your automation triggers on “when device reports” rather than “when device changes”, every report from the device fires the trigger, even reports that say nothing changed. This is a common loop multiplier.

Use change-based triggers where possible.

Add break conditions

To break a potential loop, add a condition that prevents the second automation from firing when the first just fired.

Example: “Automation B: when light turns on, run scene, UNLESS automation A just fired in the last 5 seconds.”

The implementation depends on the engine. Hubitat and Home Assistant can do this directly with timestamps. SmartThings and consumer ecosystems need workarounds with virtual switches.

Use virtual switch flags

Pattern: create a virtual switch “automation-a-just-fired”. Automation A turns on this switch as its last action, then turns it off after a delay. Automation B checks the switch as a condition: only fire if the switch is off.

This prevents B from firing when A just fired, breaking the loop.

The smart home loop watchdog

Build a watchdog automation: if any specific device receives more than 10 commands in a minute, log an alert. This catches loops as they happen, before you notice them yourself.

The watchdog is itself at risk of being triggered by the loop. Make sure its trigger is conservative (the alert only fires once per minute, not for every command).

The downstream effect

Loops do not just affect the loop participants. They generate cloud traffic, hub processing load, and can throttle your account on manufacturer clouds.

If you discover a loop has been running for hours, check:

  • Are any devices now in a strange state that needs manual reset?
  • Has your hub’s CPU been hot enough to throttle?
  • Did the manufacturer cloud rate-limit your account?

Some manufacturers temporarily block accounts that send too many commands. The block may take hours to clear.

The dual-automation review

If you suspect a loop is possible, manually trace through the automations:

  1. List every automation that triggers on a specific device.
  2. For each automation, list the devices its actions touch.
  3. Compare the two lists. If any automation’s action touches a device that triggers another automation, you have a potential loop.

If you find a potential loop, design break conditions before deploying.

The harmless versus harmful loop

Some loops are benign because they converge. “Light on” triggers “set scene”, which includes “light on”. The second “light on” has no effect because the light is already on. The loop fires once and stops.

Other loops oscillate. “Light on” triggers “light off”. “Light off” triggers “light on”. The loop continues indefinitely.

Identify which kind of loop you have. Convergent loops are not urgent. Oscillating loops are.

The race-induced loop

Two automations that should not loop can loop under race conditions. Automation A turns on the light slowly. Automation B fires on “light turning on” and immediately runs a scene that turns off the light. Automation A is still running and sees the light off, so it tries to turn on again. The loop continues.

Eliminate races by using state-based triggers and explicit completion checks rather than fire-and-forget actions.

The recovery from a loop

After breaking a loop:

  1. Verify all involved devices are in their intended states. Manually correct any that are wrong.
  2. Check the hub for errors. Reboot if it is showing stress.
  3. Verify your manufacturer cloud is not in throttled state.
  4. Edit the loop-causing automations to break the cycle permanently.
  5. Test the fix by manually triggering the original event and watching for repeats.

The prevention checklist

Before deploying any new automation:

  • What devices does this automation control?
  • What automations trigger on those devices?
  • Can my actions create the triggers of those other automations?
  • If so, add a break condition.

This 1-minute mental check prevents most loops before they happen.

Works with
HomeKitSmartThings

Frequently asked questions

How fast do loops fire?

Limited by the slowest device in the cycle. A loop involving cloud-only devices fires every 1-3 seconds. A loop involving only local devices can fire dozens of times per second.

Does my hub crash from a loop?

Usually no, but performance degrades dramatically. The hub may become unresponsive to legitimate commands until the loop is stopped.

Can I have a watchdog automation that stops loops automatically?

Yes, on Hubitat and Home Assistant. The watchdog detects a high frequency of events from a device and disables the automations involved. Setup is technical but works well.

Why does my hub start losing commands during a loop?

The hub's action queue fills up. New commands wait for the queue to drain, which it cannot because the loop keeps adding more. The user-visible symptom is delayed or skipped commands.

Do all hubs handle loops the same way?

No. Some hubs have built-in loop detection (Home Assistant has rate-limit warnings). Most consumer hubs do not. Local hubs handle loops more cleanly because there is no cloud throttle to worry about.

What if I cannot find which automations are looping?

Disable automations one by one and observe. The loop stops when you disable one of the participants. The most recently disabled automation is part of the loop.