TLDR: Got any tips on debugging automations as cannot see that it’s always shown in the log.
I’ve recently decided to “rewrite” all my automations in the format alias->id->trigger->condition->action (as per the HA documentation) as I had a mix match, some done in the front end, some manipulated from forum posts and some the above way that I started doing when I got my head round them.
At first I was doing them one by one and reloading the automations, and looking at the main page to see if automations errored (image below). If they did i would go back and tweak them. Unfortunately once I got through them all I rebooted and it seemed reloading them on at a time didn’t truly show if they worked.
I’ve gone through and fixed a fair few since then but it seems that it’s still not perfect.
I had my automations in a automation.yaml and the only real error I could find was this:
ERROR (MainThread) [homeassistant.config] Invalid config for [automation]: required key not provided @ data['condition'][0]['entity_id']. Got None. (See /config/configuration.yaml, line 27). Please check the docs at https://home-assistant.io/components/automation/
Line 27 was just where my “automation: !include automations.yaml” was. I then tried moving them to my configuration (in the hopes I would get a line but it only moved the error to:
ERROR (MainThread) [homeassistant.config] Invalid config for [automation]: required key not provided @ data['condition'][0]['entity_id']. Got None. (See /config/configuration.yaml, line 151). Please check the docs at https://home-assistant.io/components/automation/
This is where I had moved them to the bottom of the configuration yaml.
I would assume from them that somewhere there is an undefined condition and entity_id but for the life of me I can’t find it. Is there any way for me to get HA to tell me which line (I have about 650 lines of automations)?
since you’ve moved all you automations back into your configuration.yaml then try posting your configuration snippet around line 151 and let us see if we can spot the issue.
I think the lesson might be to just do a couple of automations at a time and run the config checker and reload automations before moving on.
I think the lesson might be to just do a couple of automations at a time and run the config checker and reload automations before moving on.
Sorry maybe I worded myself badly but this is exactly what I did. No errors turned up until I rebooted. I used two instances of notepad ++ and cut and pasted one in at a time and reloaded automations each time. Error didn’t show up until I rebooted.
The above are the first few lines after 151, but they all work and if I delete everything past that I don’t get the error. I guess my option is one at a time and do a reboot each time to see which is actually wrong.
I don’t suppose there is a debug setting I have missed that gives more information as to where I should look?
It was about half way through my automations. That’s what was throwing me off the line it references in both instances was the line all automations started (I thought/hoped moving them to the configuration.yaml would change that).
I’m confused as I have definitely had exact lines pop up in the past (especially recently when I was testing the individually). Anyways sorted now, thanks for your commitment there, very nice of you man.