[SOLVED]Automation in package not working

Hey guys,

I’m trying to convert most of my config from separate sensors/automations/switches folders to a more appropriate ‘packages’ system. So I am only using parts of my ‘proven to work’ configurations. Setting up my sensors, input booleans, customizations, etc in the package folder is working fine. But every time I also try to include some automations in the package file Home Assistant goes bonkers! When I run the automations seperate in their normal ‘automations folder’, everything works as expected.

Error:

2017-08-17 23:26:15 ERROR (MainThread) [homeassistant.config] 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/

My package file named ‘button_slaapkamer.yaml’ looks like this:
And again, when I exclude the automations from the file everything works as expected!

#------------------------------------------------------------------------------
# Fibaro The Button slaapkamer
# @NickSchaepkens
# Original Repo : https://github.com/NickSchaepkens
#------------------------------------------------------------------------------

##############################
#####    Instructies     #####
##############################

# Bij het aanmaken van een nieuwe entity in dit bestand:
# - vervangen button_X door button_Y
# - friendly names aanpassen

# Customize
#------------------------------------------------------------------------------

homeassistant:
  customize:
    binary_sensor.button_slaapkamer_1:
      icon: mdi:circle
      friendly_name: Button slaapkamer 1x

    binary_sensor.button_slaapkamer_2:
      icon: mdi:circle
      friendly_name: Button slaapkamer 2x

    binary_sensor.button_slaapkamer_3:
      icon: mdi:circle
      friendly_name: Button slaapkamer 3x


# Input booleans
#------------------------------------------------------------------------------

input_boolean:
  button_slaapkamer_1:
    initial: off

  button_slaapkamer_2:
    initial: off

  button_slaapkamer_3:
    initial: off


# Binary sensors
#------------------------------------------------------------------------------

binary_sensor:
  - platform: template
    sensors:
      button_slaapkamer_1:
        entity_id:
          - input_boolean.button_slaapkamer_1
        value_template: "{{ states.input_boolean.button_slaapkamer_1.state == 'on' }}"

      button_slaapkamer_2:
        entity_id:
          - input_boolean.button_slaapkamer_2
        value_template: "{{ states.input_boolean.button_slaapkamer_2.state == 'on' }}"

      button_slaapkamer_3:
        entity_id:
          - input_boolean.button_slaapkamer_3
        value_template: "{{ states.input_boolean.button_slaapkamer_3.state == 'on' }}"


# Automations
#------------------------------------------------------------------------------

automation:
  - alias: button_slaapkamer_1
    trigger:
      - platform: event
        event_type: zwave.node_event
        event_data:
          entity_id: zwave.button_slaapkamer
          basic_level: 1
    action:
      - service: homeassistant.turn_on
        entity_id: input_boolean.button_slaapkamer_1
      - delay: '00:00:01'
      - service: homeassistant.turn_off
        entity_id: input_boolean.button_slaapkamer_1
  
  - alias: button_slaapkamer_2
    trigger:
      - platform: event
        event_type: zwave.node_event
        event_data:
          entity_id: zwave.button_slaapkamer
          basic_level: 2
    action:
      - service: homeassistant.turn_on
        entity_id: input_boolean.button_slaapkamer_2
      - delay: '00:00:01'
      - service: homeassistant.turn_off
        entity_id: input_boolean.button_slaapkamer_2
  
  - alias: button_slaapkamer_3
    trigger:
      - platform: event
        event_type: zwave.node_event
        event_data:
          entity_id: zwave.button_slaapkamer
          basic_level: 3
    action:
      - service: homeassistant.turn_on
        entity_id: input_boolean.button_slaapkamer_3
      - delay: '00:00:01'
      - service: homeassistant.turn_off
        entity_id: input_boolean.button_slaapkamer_3

What am I doing wrong here?! :frowning:

1 Like

So, after some more fiddling around and trying everything I could possibly imagine it somehow started working. So after some more research it turned out that if I didn’t have a single automation in my automation.yaml (the one that the automation editor uses), hass throws the error displayed above. So I just copy pasted and made a kind of dummy automation in the automation.yaml, and now everything works! For some reason hass doesn’t like the fact that you have some automations in a package while the original automation file is empty…

So the solution: just make sure you got at least 1 automation (it doesn’t need to do anything really) in the automation.yaml file when using automations in a package, or else hass won’t like it!

6 Likes

Thank you so much, I was about to pull my hair out over this one. :grinning:

An example dummy automation that shouldn’t put any aditionnal load on the server:

- id: '1525220727848'
  alias: Dummy - delete me as there is new automation added to main automation file
  trigger:
  - platform: template
    value_template: 'false'
  condition: []
  action:
  - delay: '1'

This one is even simpler:

- action: []
  id: DUMMY
  alias: DUMMY Can Be Deleted After First Automation Has Been Added
  hide_entity: no # default no, hide from UI
  condition: []
  trigger: []
3 Likes

Wow thanks for that tip! Guess this is a bug? Did someone already file an issue?

I experienced the same problem today (automation in package, but empty automations.yaml).
The dummy script solved it for me, but this should mayby be filed as an issue?

Very big thanks to you!!! I’ve been solving this problem for a two hours without good result. And only your solution with dummy automation in “automations.yaml” helps to resolve the problem.

It seems to me, it’s a bug.

I don’t recognize the problem.

If I read this correctly, the problem is the combination of a line in the base configuration:

automation: !include automations.yaml

Combined with an empty automations.yaml file?

In my configuration, the include-line in my base configuration is missing, and the automations.yaml file does not exist. Automations declared in packages work fine.

Yeah I have just come across this ‘bug’, i’ve commented out the includes statement in my configuration.yaml and all is well.

I also just came across this ‘feature’ after cleaning up my automations file…

I have just come across this ‘feature’ and neither of the suggestions are working for me;

I have added a dummy automation in automations.yaml - and have an automation in a package file - this works, but as soon as I put automations in a second package file I start getting the error.

When removing the automations.yaml file completely and removing references to it in the configuration.yaml file, also automations in one package file are ok, as soon as a second package has an automation I start getting the error.

Is this correct? can only 1 package file have automations in it? do I have to go back to lots of individual files?