Splitting automation directory out of config.yaml

I’m attempting to split the automation section out of my configuration.yaml and cannot get includes to work with a directory, only a single file. I have tried the following variants

automation: !include_dir_merge_list automations
automation: !include_dir_merge_list automations/
automation: !include_dir_merge_named automations
automation: !include_dir_merge_named automations/
automation: !include_dir_named automations
automation: !include_dir_named automations/

After each attempt I check the config and do a full reboot. !include_dir_merge_named automations passes config check but the automations will not fire. Identical automations will fire when placed in a single yaml file, such as automation: !include automations.yaml

All files pass an external yaml check on yamllint

What am I missing? Feels like it should be obvious.

I have read the documentation, searched this forum, and browsed various Github configs. I feel like I have exhausted all options before reaching out to you guys. Wish I had a more sophisticated problem.

config.yaml and the automation used are below


# Configure a default setup of Home Assistant (frontend, api, etc)
default_config:

# Uncomment this if you are using SSL/TLS, running in Docker container, etc.
# http:
#   base_url: example.duckdns.org:8123

#climate:
#  - platform: generic_thermostat
#    name: Study
#    heater: switch.study_heater
#    target_sensor: sensor.study_temperature

# Text to speech
tts:
  - platform: google_translate

##############################################
#         Testing Area
# !include automations.yaml DOES work and nothing else does
automation: !include automations.yaml

# "!include_dir_merge_list automations" does not work
# Error code below:

# Invalid config for [automation]: not a valid value for dictionary value @ data['action'][0]['entity_id']. 
#Got None. (See /config/configuration.yaml, line 20). 
#Please check the docs at https://home-assistant.io/components/automation/
#automation: !include_dir_merge_list automations

#!include dir_merge_named does not  work
# automation: !include_dir_merge_named automations


##############################################
group: !include groups.yaml

input_boolean: !include input_boolean.yaml
script: !include scripts.yaml
zwave:
  usb_path: /dev/ttyACM0
  
lutron_caseta:
  host: 192.168.1.18
  keyfile: /ssl/lutron/caseta.key
  certfile: /ssl/lutron/caseta.crt
  ca_certs: /ssl/lutron/caseta-bridge.crt
  
cloud:
  alexa:
    filter:
#      include_entities:
      include_domains:
        - switch
        - group
        - scene
        - input_boolean
        - fan
        - light


And here is the test automation that will fire when it is in a single file but will not work in a directory

- alias: 'light test'
  trigger:
    - platform: time
      at: '22:02'

  action:
    - service: light.turn_off
      entity_id:
        - light.nook_chandelier

Running Hassio 0.98.2

That error message is saying something is wrong with the action block of an automation, specifically the entity_id (or lack thereof). The automation you posted looks ok, so it might not actually be the issue.

Here’s how I have my automations set up. This is the reference in configuration.yaml:

automation: !include_dir_merge_list automations/

My automations directory has 12 yaml files with multiple automations in each.

Is your automations directory in the same directory as configuration.yaml? How many files are in your automations directory, and do all the files have .yaml at the end of the name?

First off, thank you for your assistance. I also have a newborn at home so I’m not as sharp as I’m accustomed to

I tried dissecting the error message but I’m confused as to why the exact same automation works when linked to a single yaml file ( !include automations.yaml ) and not work in a directory.

My automations directory is in the same directory as my configuration.yaml and I currently have 3 files in the automations directory
config/automations/exterior_lights.yaml
config/automations/good_night.yaml
config/automations/test.yaml

For what it’s worth the good_night.yaml is a work in progress but, to my knowledge, should not impact the other automations from initiating.

Below is config/automations/test.yaml which does not work

- alias: 'light test'
  trigger:
    - platform: time
      at: '21:46'

  action:
    - service: light.turn_off
      entity_id:
        - light.nook_chandelier

Below is config/automations.yaml which does work when included directly.

- alias: 'light test'
  trigger:
    - platform: time
      at: '22:02'

  action:
    - service: light.turn_off
      entity_id:
        - light.nook_chandelier

Use this in your configuration.yaml:

automation: !include_dir_merge_list automations/

and try replacing the action block in the test automation with this and see if it works with the other automation files in the automations directory:

    - service: light.turn_off
      entity_id: light.nook_chandelier

If that doesn’t work, can you upload the contents of all three automation yaml files on something like https://paste.ubuntu.com/? Preferably separately.

I received the following error during check configuration (before a reboot)

Invalid config for [automation]: not a valid value for dictionary value @ data[‘action’][0][‘entity_id’]. Got None. (See /config/configuration.yaml, line 29). Please check the docs at https://home-assistant.io/components/automation/
Invalid config for [automation]: [service] is an invalid option for [automation]. Check: automation->service. (See /config/configuration.yaml, line 29). Please check the docs at https://home-assistant.io/components/automation/

config.yaml

# Configure a default setup of Home Assistant (frontend, api, etc)
default_config:

# Uncomment this if you are using SSL/TLS, running in Docker container, etc.
# http:
#   base_url: example.duckdns.org:8123

#climate:
#  - platform: generic_thermostat
#    name: Study
#    heater: switch.study_heater
#    target_sensor: sensor.study_temperature

# Text to speech
tts:
  - platform: google_translate

##############################################
#         Testing Area
# !include automations.yaml DOES work and nothing else does
#automation: !include automations.yaml

# "!include_dir_merge_list automations" does not work
# Error code below:

# Invalid config for [automation]: not a valid value for dictionary value @ data['action'][0]['entity_id']. 
#Got None. (See /config/configuration.yaml, line 20). 
#Please check the docs at https://home-assistant.io/components/automation/
automation: !include_dir_merge_list automations/

#!include dir_merge_named does not  work
#automation: !include_dir_merge_named automations


##############################################
group: !include groups.yaml

input_boolean: !include input_boolean.yaml
script: !include scripts.yaml
zwave:
  usb_path: /dev/ttyACM0
  
lutron_caseta:
  host: 192.168.1.18
  keyfile: /ssl/lutron/caseta.key
  certfile: /ssl/lutron/caseta.crt
  ca_certs: /ssl/lutron/caseta-bridge.crt
  
cloud:
  alexa:
    filter:
#      include_entities:
      include_domains:
        - switch
        - group
        - scene
        - input_boolean
        - fan
        - light     

config/automations/test.yaml (with your changes)

- alias: 'light test'
  trigger:
    - platform: time
      at: '13:35'
      
# Test via Tedidore
  service: light.turn_off
  entity_id:
    - light.nook_chandelier
#  action:
#    - service: light.turn_off
#      entity_id:
#        - light.nook_chandelier

I also tried this to ensure the whitespace was correct (same error message with config check)

- alias: 'light test'
  trigger:
    - platform: time
      at: '13:35'
      
# Test via Tedidore
    - service: light.turn_off
      entity_id:
        - light.nook_chandelier
#  action:
#    - service: light.turn_off
#      entity_id:
#        - light.nook_chandelier

Links to the individual automation yaml files below
config/automations/test.yaml
config/automations/exterior_lights.yaml
config/automations/good_night.yaml

You still need the action: line in that one automation I suggested to change which is why there’s a new error. I looked through the other automations and honestly can’t see anything wrong, but once I’m back at my computer I’ll take a closer look. You could try using this format for the action block in all the automations:

  action:
    - service: light.turn_off
      entity_id: light.nook_chandelier

Note the difference between what I have above and what you have in all the automations:

  action:
    - service: light.turn_off
      entity_id:
        - light.nook_chandelier

It shouldn’t matter which you use because both are correct but I wonder if it’s causing an issue for some reason. Let me take a closer look first before you change to the other format (unless you’re bored and want to try it anyway).

Also, to clarify, does splitting the automations work without the test automation in the directory?

It looks like exterior_lights and good_night have the same content. Can you fix that? Also, you have some spaces in line 5 of the light test automation. Could possibly be an issue (shouldn’t be, but I’m really reaching here at this point).

How bout this for a kicker. I removed those phantom spaces that I missed in line 5 and the automation works! This was the only change I made. However, I’m still getting the config error when using automation: !include_dir_merge_list automations/

Invalid config for [automation]: not a valid value for dictionary value @ data['action'][0]['entity_id']. Got None. (See /config/configuration.yaml, line 29). Please check the docs at https://home-assistant.io/components/automation/

Here is the config. It should be the same as above.


# Configure a default setup of Home Assistant (frontend, api, etc)
default_config:

# Uncomment this if you are using SSL/TLS, running in Docker container, etc.
# http:
#   base_url: example.duckdns.org:8123

#climate:
#  - platform: generic_thermostat
#    name: Study
#    heater: switch.study_heater
#    target_sensor: sensor.study_temperature

# Text to speech
tts:
  - platform: google_translate

##############################################
#         Testing Area
# !include automations.yaml DOES work and nothing else does
#automation: !include automations.yaml

# "!include_dir_merge_list automations" does not work
# Error code below:

# Invalid config for [automation]: not a valid value for dictionary value @ data['action'][0]['entity_id']. 
#Got None. (See /config/configuration.yaml, line 20). 
#Please check the docs at https://home-assistant.io/components/automation/
automation: !include_dir_merge_list automations/

#!include dir_merge_named does not  work
#automation: !include_dir_merge_named automations


##############################################
group: !include groups.yaml

input_boolean: !include input_boolean.yaml
script: !include scripts.yaml
zwave:
  usb_path: /dev/ttyACM0
  
lutron_caseta:
  host: 192.168.1.18
  keyfile: /ssl/lutron/caseta.key
  certfile: /ssl/lutron/caseta.crt
  ca_certs: /ssl/lutron/caseta-bridge.crt
  
cloud:
  alexa:
    filter:
#      include_entities:
      include_domains:
        - switch
        - group
        - scene
        - input_boolean
        - fan
        - light
        

Below are the 3 automations in the /config/automantions/ directory

config/automations/test.yaml
config/automations/exterior_lights.yaml
config/automations/good_night.yaml

In the last automation above (good_night), all of the entity_ids under the first action need to have a dash in front of each of them.

Yep, I second what finity said. Once you change that you shouldn’t have any issues anymore.