How do I setup Automations so that HA can tell me which automation is at fault?

When I check for Configuration errors, I get a green “Configuration valid!”. But the logs notification shows this:

 Logger: homeassistant.config
Source: config.py:455
First occurred: 07:24:33 (3 occurrences)
Last logged: 07:24:34
Invalid config for [automation]: Unable to determine action @ data['action'][0]. Got None. (See /config/configuration.yaml, line 30)

Line 30 of my configuration.yaml is not changed at all and only contains

automation: !include automations.yaml

So how do I find out what action @ data['action'][0] in automations.yaml is faulty?

You could try commenting out sections of the yaml and slowly making the sections smaller until you find the area of the issue.

There are moves to improve error reporting.

2 Likes

You need to check the last change that you made for errors.

So basically, the default way of setting up the yaml files doesn’t allow for correct error logging…

I guess I have to comment out all automations and hope I find it sooner rather than later… and find a way of using Git to store my yaml files so I can easily revert changes.

I suggest the 50% method.

Comment out 50% and see if the error goes away.
Now you know what half of automations the issue is in.

Now comment out 50% of the 50%
Keep going and you will rather quickly found the automation.

Just have two tabs open, one with config check and one with the editor.

Thanks!

I found it this way, what really bugs me is that HA totaly removes that automation from the Automations-list in the GUI, so It knows it’s faulty, but instead of showing it as faulty it just removes it.

Which means I can’t use the GUI to edit it.

All it was was 2 extra spaces… I hate YAML…

When the extra spaces were added, were you using the Automation Editor or a text editor?

  • The Automation Editor should have reported the YAML syntax error (bad indentation) when you clicked the Save button. If it didn’t then I would report it as a bug.

  • If you used a text editor, get one that includes an automatic YAML checker (I use Visual Studio Code) and always run Check Configuration to spot errors before executing Reload Automations.

I use the Built in File-Editor for when I edit text files, usually I just use the GUI.

Check Configuration in this regard didn’t help since it couldn’t tell me where the error was, but HA knew and HID that automation from the GUI… they should have just let it be visible but bright red instead.

I checked my Automations.yaml in Atom before and everything seemed fine

If by “Built-in File Editor” you mean the Automation Editor then report its failure to detect a YAML syntax error.

If by “Built-in File Editor” you mean the File Editor Add-on then it has some limited YAML validation and reports detected problems with a colored icon (but will let you save the file with errors).

FWIW, the Check Configuration function was revised recently to make it faster. However I noticed it seems less thorough than in the past. The ha core check command is more thorough and takes much longer to complete. However, it must be executed in the command-line so it’s less convenient.

Anyway, the upcoming improvement for identifying automation errors should help.

If you would have followed this advice you might have been able to find it easier.

It’s ALWAYS the last change you made for this type of error. The only issue is that if you make a bunch of changes before doing a config check it will be harder to narrow down. So the lesson there is to not do that.

It’s almost getting humorous (in a not funny way) how often this is happening lately. I’ve seen a bunch of “I’m getting errors and my HA is completely broken and I didn’t change a thing!” posts recently. And when the issue is solved it is inevitably “Oh, I actually did make that change but didn’t think that was it”.

1 Like

If you mean this editor:

Then I added two spaces where it’s yellow and you can see the red icon at the top right indicates there is an error.

Yeah that would have been nice. Mine doesn’t do that. At least not for this error. It might have something to do it being a data_template or whatever.

I DID check for errors between changes. But since I already had other log errors I was trying to fix I didn’t get any indication that this happened.

I still think YAML sucks.
Parentheses I can count but a random number of spaces instead of normal tab indentations. No thanks.

it’s not random.

I believe you can use pretty much any number of spaces you want as long as you are consistent throughout the config.

Most people use two spaces as convention.

Right but you did have some indication that it happened or you wouldn’t have been able to post the above error.

Did you use the built-in config checker or some other one?

If you use the built-in checker even if it shows “valid” it will still indicate there is an error in the sidebar and post the error description to the last line of the homeassistant.log file in your config directory.

But the point of my statement above is that it’s always that the error is in what you changed last so you should first look there for the error and if you don’t see it right away then just undo those changes and redo them one by one.

yaml isn’t that special in it’s requirements. I’m sure there are plenty of structured programming languages around.