Home Assistant Automation Not Working? Do THIS First!

All of my tips to help you troubleshoot home automations in Home Assistant.

Home Assistant Automation Not Working? Do THIS First!

Introduction

Is your Home Assistant automation not working? Well, I’ve been there, and I know how frustrating it can be. But after using Home Assistant to power my smart home for several years, I’ve learned what to do — and what not to do — to troubleshoot home automations.

I’m going to share all of my tips to help you get to the bottom of why something isn’t working. My hope is that this will save you time, and maybe even restore peace and order to your home.

And there’s even a bonus tip that I’m going to throw in, so make sure you don’t miss that.

🍿
Don't feel like reading? Watch it on YouTube.

Main Points

Troubleshooting Tools

There are three powerful features in Home Assistant that you can use to troubleshoot your home automations: Traces, History, and Logbook.

These three are the underrated superpowers of Home Assistant. When an automation goes rogue, you need to get to the bottom of it quickly, especially if you live with other people like I do, otherwise you are in for a world of pain and suffering.

I’ll run through what each tool does, and practical examples of how you might use them to troubleshoot an automation.

Traces

If you click the three dots next to an automation, you can select “Traces.” If you are already in the automation editor, you can click “Traces” in the upper right.

By default, the Traces page will show the five most recent times that the automation was triggered. You can click the dropdown menu showing the date and time, and choose the time period in question.

If you find that only the five most recent events is too limiting, you can change this, for example, from five to 10, by adding some simple code to the YAML for that automation.

trace:
  stored_traces: 10

Unfortunately, as of this recording there is no option to change the number of traces for all of your automations in one go.

Once the time period in question is selected, you can click “Trace Timeline.” This will show what occurred at each step of the automation after it was triggered up until the point where it stopped, either because a condition failed or it finished executing all actions.

The information here can help you understand why something did or did not run as expected. For example, maybe you had a condition that a person had to be in the Home zone, but the person’s device tracker entity did not update to “Home” when you expected it to.

Or, perhaps you have several conditions in your automation, and intended for the automation to proceed if any one of them was true, not realizing the automation stopped because one of the conditions did not pass.

As helpful as Traces can be, sometimes you need more information about the state of various entities in your home to figure out why something didn’t work. And if the automation was never triggered in the first place, it will not show up in the Traces history.

For those situations, you’ll want to turn to History and Logbook.

History

History tracks everything happening within Home Assistant. You can filter by date and time, plus areas, devices, entities, and labels. You can even download your History data as a CSV file.

By default, the Home Assistant recorder stores sensor data for 10 days, and older data is purged. If you select a History time frame that goes beyond 10 days, it will show you results from the long term statistics table, which is sampled and averaged once per hour to save storage.

When looking at a time period in History that goes beyond 10 days, the darker line represents the detailed data, and the lighter line represents the sampled data.

Let’s say you have an automation to turn on the lights in a room, but only when it is dark in that room based on a brightness sensor. You can look at the entity’s history to identify the different light level readings to determine the threshold that makes sense for you. It also enables you to see at a glance how the light level trends over the 24 hours in a day, and its behavior on sunny vs. cloudy days.

After creating such an automation, you may walk into a room and be surprised that the light didn’t come on, even though it seemed kind of dark to you. Reviewing the History, you can see the light level the moment you walked into the room, which will probably show the automation did not trigger the “Light: Turn On” action because the measured brightness was still above the threshold you set.

Sometimes though, you want to see what’s going on in your smart home around a certain time period, and you’re not sure which devices or entities to look at. For that, you can turn to the Logbook.

Logbook

The Logbook is a real-time display of all of the entity state changes in Home Assistant. If you have thousands of entities like I do, you can watch as the Logbook continuously displays updates, like motion detected from an animal outside on a security camera, wind changing direction on an outdoor weather station, and more.

Like History, you can also filter the Logbook by date and time, plus areas, devices, entities, and labels. If an automation runs, you’ll see it reported in the Logbook. If a device or entity changes state because of an automation, you’ll see it reported in the Logbook as well.

While I was preparing for this video, I heard the motorized shade close in the room next to me, which wasn’t expected. I immediately went to the Logbook and saw this was triggered by an automation related to the energy consumption of our smart TV, and was able to adjust it.

Note that “Logbook” is different from “System Log.” The System Log shows the 50 most recent errors and warnings about your Home Assistant setup, and is less likely to be helpful in troubleshooting automations. But, if you’re interested in it, the System Log is found under Settings > Systems > Logs.

Was it a Ghost?

Inevitably something will go wrong — an automation will not perform as expected. A light may appear to randomly turn on, for example. No, it wasn’t a ghost. There is always a reason for this.

It may be something as innocuous as a device changed to an “Unavailable” state in Home Assistant, and then once it came back online, the device turned on. This can happen. Reviewing Traces, History, and Logbook can help you troubleshoot what’s going on because they allow you to see what happened and when across everything in Home Assistant.

If you need to understand at what point an automation failed to proceed, Traces will show you. If a device tracker did not update its zone when you expected, History will show you. If an automation triggered something to turn on or off, Logbook will show you.

I like to keep History and Logbook easily accessible from the lefthand navigation menu for easy access in case I need to troubleshoot something quickly.

Troubleshooting Examples

Alright, let’s take a look at several examples of how you might use Traces, History, and Logbook to troubleshoot actual Home Assistant automations.

Why didn’t the door automatically unlock when I returned home?

Some smart locks include an auto-unlock feature, which means once you return home, the door will automatically unlock for you. My experience with this was spotty, and I preferred to centralize all of my automations in Home Assistant and not rely on a manufacturer app.

The automation would be triggered when either my wife or I entered our Home zone. If the door was locked, it would wait for either of our phones to connect to our home’s WiFi network. Then, it would unlock the door and send me an app notification so that I was aware.

But, sometimes I’d arrive home and the door would not auto-unlock. Then, after manually unlocking, going inside, and locking, the door would suddenly auto-unlock.

To troubleshoot, I turned to Traces. From there, I could see that the automation was not triggered until after I walked through my door. Looking at History and Logbook, I could see that my location status was not updated to the Home zone when I expected, which was delaying the automation from kicking-in.

I was then able to adjust the geofence boundary of my Home zone to tailor the automation to the intended experience.

Why did Home Assistant notify me the washing machine was done when it was still going?

One of the first home automations that I ever created was a notification sent to our phones and an announcement broadcast over our smart speakers when the washing machine and dryer completed their cycles.

By adding a smart plug to our washing machine, I was able to track the energy used by the appliance before, during, and after a laundry cycle. I then used this data from the History page to set the numeric state threshold in an automation, meaning if the current consumption dropped below that threshold, it indicated the washing machine was done, or so I thought.

When I first set this up, my wife and I were getting notified that the washing machine was done, only to walk down to the basement and see that it was still running.

To troubleshoot, I turned to the History page, and looked more closely at the electrical consumption of the washing machine over several cycles. This allowed me to pinpoint the edge cases not covered by my automation — like when the current consumption went down to zero for a brief moment, and spiked back up again.

I was then able to account for this in my automation by stating that the current consumption must be below 5 watts for 30 seconds, which would confirm that the washing machine was in fact done.

Why didn’t the light turn off when no one was in the room?

If you have home automations, chances are at least one of them controls smart lighting. If so, then you may have experienced a light turning on or off — or not turning off — when you expected.

For example, I was using a mmWave presence sensor to turn off the lights in a room when no occupancy was detected. But I noticed the lights remained on well after everyone had left that room.

To troubleshoot, I turned to Logbook, and noticed a separate automation ran turning on the ceiling fan because it was too warm in that room and the room was occupied. But once the people left, the mmWave radar continued to show that the room was occupied — not because of a person, but because of the moving ceiling fan.

I was then able to adjust the position of the mmWave sensor to avoid this false detection.

Bonus: Cameras can really help

Traces, History, and Logbook are great, but I do have one bonus tip for troubleshooting home automations: cameras.

I am using Ubiquiti UniFi cameras around my property, with video recordings saved locally on my own network video recorder (NVR). On occasion, reviewing camera footage has been invaluable in helping me get to the bottom of what was going on.

Cameras can provide visual confirmation of where people, animals, and vehicles are and when at the precise moment that some automation went awry. Combining Traces, History, and Logbook with local camera recordings, I can get to the bottom of just about anything.

Final Thoughts

Those are my tips for troubleshooting automations in Home Assistant, but I want to hear from you: What are your troubleshooting tips?

Watch on YouTube

What I use to run my Home Assistant server:

Beelink S12 Pro Mini PC: https://amzn.to/49WrA9U

Raspberry Pi 4 Starter MAX Kit: https://amzn.to/4cE0qFw