Automation error key not provided

I get this error on my automation.
I copied the code from a github repository so i don’t know why on my HA it doesn’t work,

Invalid config for [automation]: required key not provided @ data[‘action’]. Got None required key not provided @ data[‘trigger’]. Got None. (See ?, line ?)

automation:
  - alias: Trash Pickup Day Changed
    initial_state: true
    trigger:
      - platform: state
        entity_id: input_select.trash_pickup_day
    action:
      - service: mqtt.publish
        data_template:
          topic: "/home/trashpickupday"
          retain: true
          payload: '{{ states.input_select.trash_pickup_day.state }}'

Did you create the input_select?

Yes they all exist

How many “automation:” entries do you have in your config?

Other than that it looks like it should all be ok.

I splitted my yaml files by packages like examples found online from another user.

each yaml is inside a folder called packages in the root dir config.

So for each yaml file i’ve a new define for

sensor:
automation:
group:
… Etc…

Why only automation: doesn’t work?

Probably because your !include statement for your automations yaml files is not correct.

I don’t use packages but I know when using includes you can’t have the “automations:” line at the top of your yamls … that comes from the include line in config… it should just start with your first automation.

  - alias: Trash Pickup Day Changed
    initial_state: true
    trigger:
      - platform: state
        entity_id: input_select.trash_pickup_day
    action:
      - service: mqtt.publish
        data_template:

I dont think that is correct.

As long as your packages are defined properly you can have (and actually need) the automation: section in your package yaml file.

To the OP - post your configuration yaml and also post the first few lines of your automations yaml.

Is OP using actual packages or just splitting it and calling it a package?
Like I said and the docs show in the examples…remove the first line that says “automation:”

If he was splitting it up and calling it a package, the error would point to the line that contained

automation: !include automations.yaml

His error has

There could be a number of reasons why this is happening. He really needs to post his config.