Automatin configuration question (newbie)

Hello all. I’m just getting started with Home Assistant, and I have a question. I am trying to configure my first automation. If I set it up in the configuration.yaml file, it works. But if I try to move it to the automations.yaml file it doesn’t. I receive the following error:

Invalid config for [automation]: expected a dictionary for dictionary value @ data[‘action’][0][‘data_template’]. Got None extra keys not allowed @ data[‘action’][0][‘name’]. Got None. (See /config/configuration.yaml, line 92). Please check the docs at https://home-assistant.io/components/automation/

I have the automation: !include automations.yaml in my configuration.yaml file. I also added a unique id in the automations.yaml file. Here is the contents of that file:

- id: AutoselectTheme
  alias: 'Set HA theme for day and night'
  trigger:
    - platform: homeassistant
      event: start
    - platform: state
      entity_id: sun.sun
      to: above_horizon
    - platform: state
      entity_id: sun.sun
      to: below_horizon
  action:
    - service_template: frontend.set_theme
      data_template:
      name: >
        {% if states.sun.sun.state == "above_horizon" %}
          vintage
        {% else %}
          slate
        {% endif %}

Can someone point me in the right direction? Thank you.

not sure if relevant, but I would not use uppercase letters for the id.
I think you need to indent the bits under data_template

  action:
    - service_template: frontend.set_theme
      data_template:
        name: >
          {% if states.sun.sun.state == "above_horizon" %}
            vintage
          {% else %}
            slate
          {% endif %}
1 Like

It indeed was the indentation on the name variable. Thank you!