#How to change my automation

1 messages · Page 1 of 1 (latest)

potent ice
#

Hi there!
I'm trying to create an automation to delay a relay by 1 second and trigger boolean, which I didn't specify in the configuration file). But HA is giving me an error.

automation:
  - alias: Impulse Garage Gate Relay
    description: Turns on the Garage Gate Relay for 1 second, then turns it off.
    trigger:
      - platform: state
        entity_id: input_boolean.garage_gate_control
        to: on
    action:
      - service: switch.turn_on
        target:
          entity_id: switch.garage_gate_relay
      - delay: 00:00:01
      - service: switch.turn_off
        target:
          entity_id: switch.garage_gate_relay
      - service: input_boolean.turn_off
        target:
          entity_id: input_boolean.garage_gate_control```

The error: 
extra keys not allowed @ data['automation']. Got [{'alias': 'Test Automation', 'trigger': [{'platform': 'state', 'entity_id': 'input_boolean.garage_gate_control', 'to': 'on'}], 'action': [{'service': 'system_log.write', 'data': {'message': 'Automation triggered', 'level': 'info'}}]}] required key not provided @ data['actions']. Got None required key not provided @ data['triggers']. Got None.

What wrong?
Thanks in advance.
lapis finch
#

The main keys trigger and action both need to be plural. There also need to be quotes around "on" under the trigger.

#

I suggest using the UI to create automations until you get familiar with the syntax. You can switch back and forth between the UI and the code inside the editor.

potent ice
#

Thank you. I figured it out. Instead of automation (in the automations.yaml ) need to write ID!

molten pumice
#

you really shouldnt be writing automations directly to automation.yaml, you can write an entire automation in yaml from the ui and it's much easier to control, debug, etc 😅