Configuration includes question

I’m trying to get my configuration organized, and I’m having some issues using the advanced include directives. I’ve searched around but haven’t found an answer.

My directory structure for the relevant parts of this question is like this:

configuration.yaml config/ config/automation/lights.yaml config/automation/notifications.yaml

lights.yaml and notifications.yaml both contain lists, e.g.

  trigger:
    - platform: state
      entity_id: binary_sensor.office_motion_sensor_8
      from: 'off'
      to: 'on'
  condition:
    - condition: state
      entity_id: light.office_pendant_light_level_10
      state: 'off'
  action:
    service: scene.turn_on
    entity_id: scene.office_bright

- alias: Turn off office lights when there is no motion for 15 minutes
  trigger:
    - platform: state
      entity_id: binary_sensor.office_motion_sensor_8
      from: 'on'
      to: 'off'
      for:
        minutes: 15
  action:
    service: light.turn_off
    entity_id: group.office_lights

...

Anyway, when I switched to this file structure, from what I can tell (via the docs and looking at example configurations) I should be doing the following in configuration.yaml:

automation: !include_dir_merge_list config/automation

However, this blows up and leaves messages in the log like

16-06-06 19:54:25 homeassistant.core: BusHandler:Exception doing job
Traceback (most recent call last):
File “/srv/hass/hass_venv/lib/python3.4/site-packages/homeassistant/helpers/template.py”, line 61, in render
}).render(kwargs).strip()
File “/srv/hass/hass_venv/lib/python3.4/site-packages/jinja2/environment.py”, line 989, in render
return self.environment.handle_exception(exc_info, True)
File “/srv/hass/hass_venv/lib/python3.4/site-packages/jinja2/environment.py”, line 754, in handle_exception
reraise(exc_type, exc_value, tb)
File “/srv/hass/hass_venv/lib/python3.4/site-packages/jinja2/_compat.py”, line 37, in reraise
raise value.with_traceback(tb)
File “”, line 1, in top-level template code
File “/srv/hass/hass_venv/lib/python3.4/site-packages/jinja2/sandbox.py”, line 329, in getattr
value = getattr(obj, attribute)
jinja2.exceptions.UndefinedError: ‘trigger’ is undefined

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File “/srv/hass/hass_venv/lib/python3.4/site-packages/homeassistant/core.py”, line 809, in job_handler
func(arg)
File “/srv/hass/hass_venv/lib/python3.4/site-packages/homeassistant/core.py”, line 663, in _execute_service
service(call)
File “/srv/hass/hass_venv/lib/python3.4/site-packages/homeassistant/core.py”, line 522, in call
self.func(call)
File “/srv/hass/hass_venv/lib/python3.4/site-packages/homeassistant/components/notify/init.py”, line 88, in notify_message
message = template.render(hass, message)
File “/srv/hass/hass_venv/lib/python3.4/site-packages/homeassistant/helpers/template.py”, line 63, in render
raise TemplateError(err)
homeassistant.exceptions.TemplateError: UndefinedError: ‘trigger’ is undefined

Any ideas what I’m doing wrong?

Wrap your snippets in triple backquotes for proper formatting. That will help determine the problem.

Fixed formatting. Thanks for the tip. I was using the “code” button and it was just doing single ticks.

And of course after banging my head against this for a couple hours, I find the problem right after I post…in one of my included files, I apparently had a syntax error. I had this:

- alias: Turn off lights when everyone leaves the house
  trigger:
    platform: state
    entity_id: group.all_devices
    state: 'not_home'
  condition:
  - condition: state
    entity_id: switch.presence
    state: 'on'
  - condition: state
    entity_id: switch.guests
    state: 'off'
  action:
    service: light.turn_off
    entity_id: group.all_lights

instead of this:

- alias: Turn off lights when everyone leaves the house
  trigger:
    - platform: state
      entity_id: group.all_devices
      state: 'not_home'
  condition:
  - condition: state
    entity_id: switch.presence
    state: 'on'
  - condition: state
    entity_id: switch.guests
    state: 'off'
  action:
    service: light.turn_off
    entity_id: group.all_lights

(note the lack of a list indicator under trigger)

For some reason, this wasn’t throwing an error when everything was in one file (it also wasn’t working, but it wasn’t throwing an error) , but once I split them up and included it this way it barfed…