Help me understand new Automations interface

I’m trying to convert a simple “Webhook → JSON: Do action with entity” automation from an old HA v0.92 installation to the current HA version, but running into some issues understanding the changes in interface and terminology. It can be confusing trying to look up information and follow examples because there have been so many changes and the older information online is not up to date with the latest version.

For reference here is the old automation as entered in the v0.92 Automations UI:

Name: DoService
Trigger: Webhook
Action:

{
  "data_template": {
    "entity_id": "{{ trigger.json.entity_id }}"
  },
  "service_template": "{{ trigger.json.service }}"
}

As you can see, the desired service call (now a.k.a. action) and target entity_id are passed to the webhook in JSON and executed by the automation.

This generated the following in automations.yaml:

- id: '1512060478224'
  alias: DoService
  trigger:
  - platform: webhook
    webhook_id: DoService
  condition: []
  action:
  - data_template:
      entity_id: '{{ trigger.json.entity_id }}'
    service_template: '{{ trigger.json.service }}'

First question: There does not seem to be any way to enter an action like this in the Action field when creating an automation in the new UI. Correct?

Second question: The Trigger field in the Create Automation UI has a right-click menu item “Edit in YAML”, but it appears to allow editing of the trigger only, not the full automation with Actions, and the Actions field does not have a similar “Edit in YAML” option. As far as I can tell, the new Automations UI no longer has the ability to create an automation like the one I am copying from the old Automations UI. I will have to edit the automations.yaml file directly?

With the changes in terminology, I think the correct format in the automations.yaml file will be:

- id: '1733699755634'
  alias: DoService
  description: ''
  triggers:
  - trigger: webhook
    allowed_methods:
    - POST
    - PUT
    local_only: true
    webhook_id: -L6xg5ymBGz7M61wrBQJAd_Ph
    alias: DoService
  conditions: []
  actions:
  - action: '{{ trigger.json.service }}'
    data: entity_id: '{{ trigger.json.entity_id }}'
  mode: single

since “service” is now “action” and “data_template” is now “data”.
Does this seem correct? Does the entity_id have to be the internal numeric id?

Not sure what you mean by ‘interface’ as this is the .yaml file (not the interface).

Regardless, It looks OK, but entity_id needs to be indented on the next line:

- action: '{{ trigger.json.service }}'
    data:
      entity_id: '{{ trigger.json.entity_id }}'

Of course, you could just try it and see if it works :slight_smile:

1 Like

This is the current HA documentation on Automations YAML: from: Automation YAML - Home Assistant

" Automations are created in Home Assistant via the UI, but are stored in a YAML format. If you want to edit the YAML of an automation, select the automation, select the menu button in the top right then on ‘Edit in YAML’.

The UI will write your automations to automations.yaml. This file is managed by the UI and should not be edited manually."

Confusing!
As I pointed out above, the referenced ‘Edit in YAML’ appears to be only able to edit the Trigger.
And then they go on to say don’t edit the automations.yaml file.

You’re clicking the wrong edit in yaml and the wrong 3 dots (i.e. top right of the page). Look in the upper corner of the entire automation, click those 3 dots.

1 Like

Thanks! That upper-right 3-dot menu is non-functional in 3 out of 4 browsers I tried, but with that guidance I kept trying and it worked in the 4th browser I tried.

Works for me in Firefox (windows), chrome (on windows & ios), safari (ios), and the ios companion app

I was initially working on an old Win7 system, where the menu failed to work in any of the browsers. Switched to Win10 to get it to work.

In any case, thanks for the hints, as I now have it working. The correct format (in yaml) is:

alias: DoService
description: ""
triggers:
  - trigger: webhook
    allowed_methods:
      - POST
      - PUT
    local_only: true
    webhook_id: DoService
    alias: DoService
conditions: []
actions:
  - action: "{{ trigger.json.service }}"
    data:
      entity_id: "{{ trigger.json.entity_id }}"
mode: single

One more HA bug discovered in testing: I checked initially with a simple “turn on the light” automation called from the browser to make sure that Webhook-triggered Automations were working at all, but for some reason it just returned a 405 error even though I did have “GET” checked off as an allowed method for the simple automation.