How to Debug Home Assistant Automations
In this article
Debugging Home Assistant automations is the process of figuring out why a rule you wrote doesn't trigger, or triggers at the wrong time, or fails partway through its actions. This guide walks you through a systematic approach: checking the logbook, using trace, adding temporary debug notifications, and testing conditions manually. You'll need access to your Home Assistant web interface and, ideally, the ability to edit automations in YAML or the visual editor.
What You'll Need
- A running Home Assistant instance (any installation type: HAOS, Docker, Supervised, or Core).
- Access to the Home Assistant web interface (usually
http://).:8123 - Basic understanding of your automation's logic: what trigger, condition, and action you expect.
- Optional: SSH or file access if you need to edit
automations.yamldirectly.
Step-by-Step
- Reproduce the issue. Try to make the automation fail or succeed in a controlled way. For example, if it should trigger at sunset, wait for sunset or temporarily change the trigger to a short time delay (e.g., every minute) to test quickly.
- Check the Logbook. Go to Settings → Logbook. Filter by your automation's name or entity. The logbook shows when the automation was triggered, whether it ran, and if it was skipped. Look for entries like "Triggered by state of..." or "Automation has been triggered." If you see nothing, the trigger never fired.
- Examine the Trace. When an automation runs, Home Assistant stores a trace. Go to Settings → Automations & Scenes, find your automation, click the three-dot menu, and select Traces. You'll see a list of runs. Click a run to see a step-by-step diagram: which trigger matched, whether conditions passed, and each action's result. This is the single most useful debugging tool.
- Add temporary debug notifications. Insert
notify.notifyactions at key points: right after the trigger, after each condition, and at the start of each action. For example, a notification saying "Trigger fired" or "Condition passed" helps you see where the flow stops. Remember to remove them after fixing. - Test conditions manually. If a condition is failing, go to Developer Tools → Template and paste the condition's template with real values. For example, if you have
condition: numeric_statefor temperature, check the current temperature and see if it meets the threshold. - Check entity states. Use Developer Tools → States to confirm that the entities your automation references exist and have the expected attributes. A common mistake is using an entity ID that changed or a state that's a string instead of a number.
- Validate YAML. If you're editing YAML manually, go to Developer Tools → YAML and validate your configuration. Syntax errors will prevent the automation from loading at all.
- Restart or reload. After editing YAML, click Reload Automations in Developer Tools → YAML (or restart Home Assistant) to apply changes. If the automation doesn't appear in the list, there's a syntax error.
- Check the logs. Go to Settings → System → Logs and look for errors related to your automation or its actions. Warnings about unknown entities or service calls often point to the issue.
- Simplify and isolate. Temporarily remove conditions and extra actions. If the automation works with just a trigger and a simple action, add parts back one by one until it breaks. This pinpoints the culprit.
Common Mistakes
- Using the wrong entity ID. Entity IDs can change if you rename a device. Always verify the current ID in Developer Tools.
- Mixing up state and attribute. For example,
stateof a sensor is often a string like "21.5", but numeric comparisons needstate | float. - Forgetting that triggers are OR-ed. If you have multiple triggers, any one of them will fire the automation. If you want all to be required, you need conditions.
- Assuming the automation runs immediately. There's a small delay between trigger and execution, and if the system is busy, it can be longer. Also, the trigger may be blocked by the automation's
mode(e.g.,singlewon't restart while running). - Ignoring timezone. Sun-based triggers use your configured timezone. If you set a fixed time, it's in your local time, but if you use
input_datetime, ensure it's set correctly. - Using
andin templates incorrectly. In YAML,andmust be lowercase and placed inside the template, not as a YAML key.
Tips
- Use the visual editor's Trace feature as your first stop—it shows exactly what happened in a run.
- Name your automation actions descriptively so traces are easier to read.
- Set up a
debuginput boolean that you can toggle to enable/disable extra notifications without editing YAML every time. - Test with a short delay trigger (e.g.,
time_patternwithseconds: "/30") to get quick runs, then revert. - Keep a backup of your automations before major edits, especially if you're editing YAML directly.
- If you're using templates, test them in Developer Tools → Template with real data before putting them in an automation.
Troubleshooting
If the steps above don't solve your issue:
- Automation not showing in the list: YAML syntax error. Validate your YAML and check the logs for the exact line number.
- Trigger fires but no actions happen: Check the trace to see if a condition failed. If no condition, check if the action's service call is failing (e.g., service not found, entity unavailable).
- Actions run but nothing changes: Verify the target entity is correct and that the service actually affects it. For example,
light.turn_onwithbrightnessmay not work if the light doesn't support brightness. - Automation triggers but runs multiple times: Check the
modesetting. If it'ssingle, it won't restart. If you want it to run only once, add a condition that checks a state or usefor:in the trigger to debounce. - Sun trigger not firing: Ensure your location is set correctly in Settings → System → General. Also, check if the sun entity is available.
- Everything seems correct but still fails: Restart Home Assistant. Sometimes the automation engine gets stuck, and a restart clears it.
Frequently Asked Questions
Why is my automation not triggering at all?
Check the Logbook to see if the trigger fired. If not, verify the trigger conditions (e.g., correct entity, state change, time). Also, ensure the automation is enabled (not paused) and the trigger isn't blocked by a condition that is always false.
How do I see what went wrong in a specific run?
Go to Settings → Automations & Scenes, select your automation, click the three-dot menu, and choose Traces. You'll see a list of runs; click one to see a detailed breakdown of each step.
What does "mode: single" mean and how does it affect debugging?
Mode determines what happens if the automation is triggered while already running. single means it won't start a new run until the current one finishes. If you expect multiple runs but only see one, check the mode.
Why does my automation work in the visual editor but not in YAML?
Likely a YAML syntax issue, such as incorrect indentation or a missing colon. Use the YAML validation tool in Developer Tools to catch errors.
Can I debug an automation without waiting for the real trigger?
Yes. Temporarily change the trigger to a time_pattern that fires every minute, or use the Run button in the automation editor to manually trigger it (if you have that option).
How do I add a debug notification to my automation?
Add an action like service: notify.notify with data: containing message: "Debug: trigger fired". Place it at the beginning of the action sequence. You'll get a notification on your phone or web interface.