Constant Errors - Invalid config for [automation]: [type] is an invalid option for [automation]. Check: automation->action->0->type

I am getting this error as soon as I update automations.yaml

Invalid config for [automation]: [type] is an invalid option for [automation]. Check: automation->action->0->type.

I found something related here but not sure what the issue is. The automation is pretty basic:

- id: test_6
  alias: test_6
  description: ''
  trigger:
  - platform: time
    at: '21:00'
  condition: []
  action:
  - type: turn_on
    entity_id: switch.6414430640f520f8340f
    domain: switch

Any help would be much appreciated.

Check the indentation of your code.


alias: test_6
trigger:
  - platform: time
    at: '21:00:00'
condition: []
action:
  - type: turn_on
    …
    …

I have no direct experience with device actions, but you may need a device_id: key there. If I make a sample action for a switch, I get this:

- device_id: 05576e755093955358463ed8a8b0268c
  domain: water_heater
  entity_id: water_heater.buzz_coffee
  type: turn_on

But device triggers/actions aren’t intended to be written manually, so something like this would be better if that’s what you’re doing:

  - service: switch.turn_on
    entity_id: switch.6414430640f520f8340f

What do you think is wrong with the indentation? I am checking it with the File Editor - and it doesn’t give me warning for indentation. Plus, I am keeping the indentation as per the other automations, which are running fine.

I read that the device_id is generated when you create an automation through the automation from the UI. I am trying to get away from the UI as some of my automations which are working won’t work when I go and create a new one from UI. Apparently, it is this way due to how YAML interacts with Python.

Devices are assigned device_ids when they’re created by the integration, not when an automation is created. I think getting away from the UI is valuable, but there’s no relationship between YAML and Python and how devices are addressed.

May be I am wrong about device_ids just read it here.

Not sure where that comes from. The error message is quite explicit: [type] is an invalid option for [automation]

A proper automation action would be

    - service: switch.turn_on
      target:
        entity_id: switch.6414430640f520f8340f

When this kind of indentation is working, everything is fine; I always use the automation editor for testing my code before I release it and so I suggested another way of indentation.

But:
If wether the „blueprint“ examples for device actions (see Rob‘s one), nor a service action (as Chris suggested) are working flawlessly, then I would suspect an error somewhere in another automation. Is the automation above the only one you tested recently?

Woke up in the morning - and did this and it worked wanted to punch myself in the face :slight_smile:

I was using the YAML in GUI generated templates to create my own, and it calls on the type and that clearly didnt work, but the service call surely works.

Thanks Chris!