Yaml formatting in configuration.yaml

I have been trying to tidy configuration.yaml up, there seem to be a number of settings (see script syntax at https://www.home-assistant.io/docs/scripts/) which use the list prefix ‘-’ even if there is no list (e.g. delay) If I put in a delay as

  action:
    - delay: 00:03
    - service: homekit.start

this is accepted, however neither of these are lists, what looks like correct yaml:

  action:
    delay: 00:03
    service: homekit.start

creates an error:
Invalid config for [automation]: [delay] is an invalid option for [automation]. Check: automation->action->0->delay. (See /config/configuration.yaml, line 120).
this is even more confusing as the delay statement is on line 8, there is no delay on line 120…

Why does delay need the list prefix, or is ‘-’ used for other things besides lists in yaml?

It needs the prefix if you have more than one action defined.

Have a read of this:

http://thomasloven.com/blog/2018/08/YAML-For-Nonprogrammers/

The prefix ‘-’ is used to separate elements in a list, it doesn’t mean that what comes after ‘-’ is a list.

Here in your example “action:” is a list and the elements are “delay: …” and “service:…”.

so it wasn’t clear (to me) that delay is itself an action, the yaml syntax doesn’t help here, it is a function of the script page and on re-reading it, I now understand that the subheadings shown are all different actions (it isn’t explicit in the documentation) and so need to be combined in a list.