Automation config error

I just added some automations to my automations.yaml file. When validating the configuration I am getting the following error:

Invalid config for [automation]: [after] is an invalid option for [automation]. Check: automation->trigger->0->after. (See /config/configuration.yaml, line 145). Please check the docs at https://home-assistant.io/components/automation/ Invalid config for [automation]: [after] is an invalid option for [automation]. Check: automation->trigger->0->after. (See /config/configuration.yaml, line 145). Please check the docs at https://home-assistant.io/components/automation/

Strange thing is that I have not made any changes to my config file.

The last part of the config file looks like this:

group: !include groups.yaml
automation: !include automations.yaml
script: !include scripts.yaml

Any suggestions to whats wrong?

Is line 145 the automation line if so the the error is in the automation file HA has a hard time dealing with !include just check your spacing in said file

Thanks!
Yes, the line 145 is the automation file.
So the error is in that file? I have previously got errors specifically in automation.yaml. Have not seen this before.
Is there any tool to validate the automation file that you know of?

Ask Google lol or post it here and use the formatting at top of page other user mite should see what wrong

Ok, got it… :slight_smile:

this is the what I have:

- alias: Turn on outdoor lights at sunset 
  trigger:
    platform: sun
    event: sunset
  action:
    service: light.turn_on
    entity_id: 
    - light.utebelysning_framsida
    - light.hue_ambiance_lamp_1
    - light.hue_ambiance_lamp_2

- alias: Turn off outdoor lights at sunrise 
  trigger:
    platform: sun
    event: sunrise
  action:
    service: light.turn_off
    entity_id: 
    - light.utebelysning_framsida
    - light.hue_ambiance_lamp_1
    - light.hue_ambiance_lamp_2
    - light.onoff_plug_1

- alias: Turn on window lights at sunset
  trigger: 
    platform: sun
    event: sunset
  condition:
  - condition: state
    entity_id: input_boolean.not_at_home
    state: 'on'
  action: 
    service: light.turn_on
    entity_id:
    - light.onoff_plug_1_2
    - light.onoff_plug_1

- alias: Turn of some window lights at 23
  trigger:
    platform: time
    at: '23:00:00'
  condition:
  - condition: state
    entity_id: input_boolean.not_at_home
    state: 'on'
  action:
    service: light.turn_off
    entity_id:
      - light.onoff_plug_1_2

- alias: Turn on indoor lights random when not at not at home
  trigger:
    platform: time
    after: '17:00:00'
  condition:
  - condition: state
    entity_id: input_boolean.not_at_home
    state: 'on'
  action:
    delay: '{{ (range(0, 2)|random|int) }}:{{ (range(1, 59)|random|int) }}:00'
    service: light.turn_on
    entity_id:
      - light.hue_ambiance_lamp_2_2
      - light.hue_ambiance_lamp_1_2

- alias: Turn off indoor lights random when not at not at home
  trigger:
    platform: time
    after: '22:00:00'
  condition:
  - condition: state
    entity_id: input_boolean.not_at_home
    state: 'on'
  action:
    delay: '{{ (range(0, 2)|random|int) }}:{{ (range(1, 59)|random|int) }}:00'
    service: light.turn_off
    entity_id:
      - light.hue_ambiance_lamp_2_2
      - light.hue_ambiance_lamp_1_2

Off top of head think u missing the ID

A tick you can do is what I did when starting down this track is

Put a # at the front of line 145
Then copy all the automation into the configuration file under automation:
Then do a config check that will tell you the line number then cut it back to the automation file take out the # in 145 do a config check again

I splitted the automation file and found out that the error is in this bit:

- alias: Turn on indoor lights random when not at not at home
  trigger:
    platform: time
    after: '17:00:00'
  condition:
  - condition: state
    entity_id: input_boolean.not_at_home
    state: 'on'
  action:
    delay: '{{ (range(0, 2)|random|int) }}:{{ (range(1, 59)|random|int) }}:00'
    service: light.turn_on
    entity_id:
      - light.hue_ambiance_lamp_2_2
      - light.hue_ambiance_lamp_1_2

Not sure where though…?

Ok we getting somewhere now if you copy the delay part into template does it show the right format doing this on my phone

Left hand side of main screen about 4th 5th icon in

Got a feeling the formatting of the delay is not putting in the leading 0 in

Hay join this dicord https://discord.gg/FHqNAd6

Ask it there it where I live most of the time

thanks!

I think there is some problem with delay in relation to service:
Could be something like this

  action:
    - delay: '{{ (range(0, 2)|random|int) }}:{{ (range(1, 59)|random|int) }}:00'
    - service: light.turn_on
      entity_id: 
        - light.hue_ambiance_lamp_2_2
        - light.hue_ambiance_lamp_1_2

However still not getting it through…

paste into in here
image

You should see the out put

image

Found a PC I can Work ON

I see its doing this
image

so looking into how to format to 01:45:00 think that the problem

Think I have it
try this

‘{{ "%02d" % (range(0, 2)|random|int) }}:{{ "%02d" % (range(1, 59)|random|int) }}:00’

as it out puts

back to my real job packing powder

The problem is here…

- alias: Turn on indoor lights random when not at not at home
  trigger:
    platform: time
    after: '17:00:00'

Change after to at

It clearly tells you this in the error message, so I don’t know why you’ve both been working on the template for the last 4 hours.

2 Likes

Thanks! That soved the problem.