Help on how to debugging Automations from log

Afternoon All

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.

automation

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.

151 is where “automation:” now starts.

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.

Oh sorry. I missed that part. My bad.

Post your config from a few lines before to a couple of automations after that line so we can try to spot something.

That’s the problem 151 is where “automation:” starts so it could be any of the 600+ lines below it.

automation:
  - alias: "Startup"
    id: '00000000000001'
    trigger:
      platform: homeassistant
      event: start
    condition: []
    action:
      service: python_script.daycountdown
  - alias: "Night Run"
    id: '00000000000002'
    trigger:
      platform: time
      at: '00:01:00'
    condition: []
    action:
      service: python_script.daycountdown
  - alias: "LockTime"
    id: '00000000000003'
    trigger:
      platform: state
      from: 'on'
      to: 'off'
      entity_id: binary_sensor.door_window_sensor_158d0002252ca6
    action:
      - service: input_datetime.set_datetime
        data_template:
          entity_id: input_datetime.locktime
          time: '{{ (as_timestamp(now()) | timestamp_custom("%H:%M", true)) }}'

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?

Just as a check, you did delete your other “automation: !include…” line in your config correct?

Yeah I’ve hastagged it out so it won’t process.

Maybe try getting rid if the two empty “condition: []” sections?

You don’t have to have them in there and there may be something weird with the spacing or something.

Firstly thanks for helping

I’ve found the culprit:

- alias: "misc_Cold @ Night"
  id: '9990000000001'
  trigger:
    platform: time
    at: '05:00:00'
  condition:
  - condition: numeric_state
    below: '4'
  action:
    - service: notify.kriss
      data:
        message: "It's below 4 degrees outside you may have to defrost your car." 

When changing it over I must have deleted the

entity_id: 'sensor.temperature'

I’m glad you got it sorted out.

How far down in the list was it?

It’s strange that it wasn’t more specific on the line number. I’ve usually have it pretty close when I get any errors.

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.