Debugging automations syntax

I’ve been using the dir_merge_list for quite some time now.
In the past few days I’ve did a major refactor and now I see the following errors in the HA log:

2021-11-19 15:53:45 ERROR (MainThread) [homeassistant.config] Invalid config for [automation]: invalid template (TemplateSyntaxError: unexpected '}', expected ')') for dictionary value @ data['condition'][0]['conditions'][1]['value_template']. Got None. (See /config/configuration.yaml, line 81). 
2021-11-19 15:53:45 ERROR (MainThread) [homeassistant.config] Invalid config for [automation]: invalid template (TemplateSyntaxError: expected token ',', got 'string') for dictionary value @ data['condition'][0]['conditions'][1]['value_template']. Got None. (See /config/configuration.yaml, line 81). 
2021-11-19 15:53:45 ERROR (MainThread) [homeassistant.config] Invalid config for [automation]: invalid template (TemplateSyntaxError: unexpected '}', expected ')') for dictionary value @ data['condition'][0]['conditions'][1]['value_template']. Got None. (See /config/configuration.yaml, line 81). 

The thing is they all point to the same line of code in the configuration.yaml file which is:

automation: !include_dir_merge_list automation

How do I make the error output meaningful information about the actual automation that caused the error?

You can’t.

You have to search your automations files for a missing ) or , in the second template condition in the first AND or OR condition in one of your automations.

As you have automations in separate files you can move the files out of the directory and put them back one by one doing a config check after putting each one back, until you find the automation(s) that cause the error(s). Looks like there might be three of them.

Thanks for your answer, I was hoping of an easier way.
The config check passes just fine for some reason:

I typically find that I get more useful information using the SSH add on and running ha core check
It takes a LOT longer to run than clicking the button in the web interface, and provides a lot more information on what failed to validate.

Yeah but it will generate a persistent notification and create the error in your log.

Either use the CLI as Andrew suggested or clear your system log before each config check then look at it after the check completes.

2 Likes