Invalid config for [automation]: required key not provided @ data['action']

Any idea why HA throws this error for the following configuration:

input_boolean:

  switch_enable:
    name: Enable switch

input_datetime:

  enable_time:
    has_date: true
    has_time: true

automation:

  trigger:
    platform: state
    entity_id: input_boolean.switch_enable
    to: 'on'
  action:
    service: input_datetime.set_datetime
    entity_id: input_datetime.enable_time
    data:
      date: '2018-07-10'
      time: '05:00'

This config file is loaded as package from configuration.yaml:

homeassistant:

  packages:
    test: !include test.yaml

I’m sure it’s something basic, but I’m new to HA and still familiarise myself with YAML.
Thanks.

try putting the entity_id from your action under the data: section with the same indentation as the date and time

Same error. The entire error log is:
Invalid config for [automation]: required key not provided @ data[‘action’]. Got None
required key not provided @ data[‘trigger’]. Got None. (See ?, line ?). Please check the docs at https://home-assistant.io/components/automation/

I’ve never specified an automation, either before or after using packages, without
- alias: blah, blah, blah
I don’t know if alias is required, or the dash is required (to make it a list element.) I’d suggest either:

automation:

- trigger:
    platform: state
    entity_id: input_boolean.switch_enable
    to: 'on'
  action:
    service: input_datetime.set_datetime
    entity_id: input_datetime.enable_time
    data:
      date: '2018-07-10'
      time: '05:00'

or:

automation:

- alias: Set datetime
  trigger:
    platform: state
    entity_id: input_boolean.switch_enable
    to: 'on'
  action:
    service: input_datetime.set_datetime
    entity_id: input_datetime.enable_time
    data:
      date: '2018-07-10'
      time: '05:00'

yeah, i missed that. pretty sure they need an alias

Sorry, no luck. Both options give me the same error. But just out of curiosity, I pasted the code directly into configuration.yaml and it works. Is there anything specific required for automation defined in a package?

Ok, after more digging I found the problem… when I moved the code into a package, I left previous automation keyword in configuration.yaml. After removing it, everything started to work.

Thanks for help all.

Ah, ok. FWIW, here’s what I have in my configuration.yaml:

homeassistant:
  packages: !include_dir_named packages
automation: !include_dir_merge_list automations
script: !include_dir_merge_named scripts

This allows me to use both packages as well as “normal” automation and script files. Any file I put in <config>/packages will be interpreted as a package file, anything in <config>/automations can contain a list of automations, and anything in <config>/scripts can contain a set of named scripts.

3 Likes

!include_dir_merge_list was the solution, thanks pnbruckner.

1 Like