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:
- Automation A triggers on event X
- Automation A executes action Y
- Action Y causes event Z
- Automation B triggers on event Z
- Automation B executes action that causes event X
- 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:
- Motion sensor triggers light on
- Light on changes ambient light enough to make a moving shadow appear
- Motion sensor triggers again
- Light is already on, no visible change, but the trigger fires
- 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:
- List every automation that triggers on a specific device.
- For each automation, list the devices its actions touch.
- 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:
- Verify all involved devices are in their intended states. Manually correct any that are wrong.
- Check the hub for errors. Reboot if it is showing stress.
- Verify your manufacturer cloud is not in throttled state.
- Edit the loop-causing automations to break the cycle permanently.
- 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.