Automations Problem

Hi All

Hope there is someone out there to help me with this problem :

1º - My automations dissapear from the UI and i don’t understand why. (but it´s not a big deal since we can create them directly in the yaml)

2º - If i create a fresh automation in UI and save it i get an error in some lines and other times the error below automation :

This is the automation

  • id: ‘1606927027961’
    alias: Sunset
    description: ‘’
    trigger:
    • platform: sun
      event: sunset
      condition: []
      action:
    • service: switch.turn_on
      data: {}
      entity_id: switch.sonoff_10002e4fc4
      mode: single

and this is the error HA gives me

extra keys not allowed @ data[‘automation’]

and for what i can see in this error i have extra characters in the configuration.yaml, but when i check everything is okay, i even got compared with other configuration file and it´s the same amount of spaces and characters, the configuraton.yaml is this :

homeassistant:
customize: !include customize.yaml
automation: !include automations.yaml

Can someone help me whit this because i cant see anymore errors on this.

Thanks all.

You have posted an unformatted automation. That makes it challenging for others to examine it for syntax errors such as incorrect indentation.

Select the unformatted code and click the </> icon.

1 Like

Please read the community guidelines here, especially point 11, and format your code properly as Taras pointed out.

1 Like

Sorry about that, there you have it :

Automation:

- id: '1606927027961'
  alias: Sunset
  description: ''
  trigger:
  - platform: sun
    event: sunset
  condition: []
  action:
  - service: switch.turn_on
    data: {}
    entity_id: switch.sonoff_10002e4fc4
  mode: single

Conguration.yaml

#homeassistant
homeassistant:
  customize: !include customize.yaml
  automation: !include automations.yaml

The indentation for the the include of the automations is wrong.

Should be:

homeassistant:
  customize: !include customize.yaml
automation: !include automations.yaml

And the automation you posted is inside autonations.yaml and there’s no automation: at the top of the automations.yaml file?

2 Likes

I think you now see how important it is to post formatted YAML. The indentation error was instantly recognizable.

After you make the correction, save the file and restart Home Assistant.

If you add an automation and it no longer disappears, the problem is solved. In that case, please mark Burningstone’s post with the Solution tag. It will automatically place a check-mark next to the topic’s title which signals to other users that this topic has an accepted solution. This helps other users find answers to similar questions.

1 Like

100% agree with @Burningstone here, this is likely the issue.
Also, be aware that creating an automation in YAML requires reloading automations in Configuration - Server Controls, while creating them in the UI doesn’t.
Sounds like you’ve maybe created one here and one there, overwriting each other because you didn’t reload, which could cause your first problem :slight_smile:

1 Like

Guys you are all the best.

It solved the problem.

Already marked as solved, thanks you for your help.