Problem with configuring Automations

Hello, I’ve just installed my first hass setup coming from Openhab and have some problems.

I’m trying to trigger an event (push a mqtt-switch) when another is triggered (changed from off to on).
But I have this error:

Invalid config for [automation]: required key not provided @ data[‘action’]. Got None. (See /home/damien/.homeassistant/configuration.yaml, line 148). Please check the docs at https://home-assistant.io/integrations/automation/

MY config is:

- id: garage_up
  alias: 'open garage'
  initial_state: 'off'
  condition:
    condition: state
    entity_id: switch.funkgarage 
    state: 'on'
  trigger:
    - platform: state
      entity_id: switch.garage_2
      to: 'on'

Thanks for your help

Like it says, you don’t have an action block.

Hi, welcome to the group.
I experimented with openhab about 2-3 years agon but my memory is hazy so I won’t offer comparisons, just elements of what is wrong here.

  1. yaml is hierarchical (a bit like html, but Yaml Ain’t a Markup Language) and it doesn’t care about the order of children under a parent. The Automation Editor highlights this by ordering everything alphabetically (makes it really hard to read)
  2. What you have done however, is one of the things that the HA interpretation of yaml, does object to. You’ve put the condition before the trigger.
  3. Trigger, Condition. Action see finity post below
  4. You have also specifically stated that the automation should be turned off. Why ?
  5. Then you have no action ? What do you want to happen ?
1 Like

I’m pretty sure that is not correct.

I just tested it and the order of the main keys doesn’t matter.

This works:

 - alias: Testing
    condition:
      - condition: state
        entity_id: input_boolean.bool_14
        state: 'on'
    action:
      - service: input_boolean.turn_on
        entity_id: input_boolean.bool_16
    trigger:
      - platform: state
        entity_id: input_boolean.bool_15
        to: 'on'

the biggest issue is as pointed out there is no action.

1 Like

Wow, although that’s consistent with yaml not caring about children order it makes human reading / logical sequencing a nightmare.

I suppose with the rise of the AE we will all need to get our heads round this.
I think there are ‘some’ conventions that should not be broken and personally would hate to see action, condition, trigger (cause and effect goes out the rectangular orifice in the wall)

1 Like

I think this would be what you need:

- id: garage_up
  alias: 'open garage'
  initial_state: 'on'
  trigger:
    - platform: state
      entity_id: switch.funkgarage
      to: 'on'
  action:
    - service: switch.turn_on
      entity_id: switch.garage_2

This will turn on “switch.funkgarage”, when “switch.garage_2” changes the state to “on”.

However I suggest taking a look at the documentation anyway.

You probably already knew this but I agree with that completely. I really dislike the AE’s for many reasons.

1 Like

Thanks, it works :slight_smile:
Actually, I tried to read the documentation, but it isn’t “straight forward” … for someone new to Hass its quite bad to have only parts of the config, it would be much better to have an example config for easy tasks like triggering one action with another .
But … in the end with your help I got it to work ,… at least config wise, it doesn’t trigger, but I look for the solution
Didn’t know that I need to activate the automation …
It works now

There are some examples here :slight_smile:

then give him tick in the “solution” box. :slightly_smiling_face: