Error in Garadget docs?

The configuration.yaml suggested in the documentation doesn’t parse as valid yaml. In particular, this sensor section:

sensor:
  - platform: template
    sensors:
      garage_door_status:
        friendly_name: 'State of the door'
        value_template: '{{ states('cover.garage_door') }}'

Both doesn’t work in HA, and fails in various YAML checkers, with: (): did not find expected key while parsing a block mapping at line 13 column 9

The use of nested single parenthesis looks suspect, but I’m not sure exactly what the issue is here.

Where is this example given in the docs?

Look closely at what the single quotes enclose.

This:

'{{ states('

And this:

') }}'

Solution, put double quotes around the whole thing and single quotes inside.

value_template: "{{ states('cover.garage_door') }}"

The other option is to use a multi-line template as they are not quoted:

value_template: >
  {{ states('cover.garage_door') }}

Yeah, I didn’t think that could be right.

Thanks for the link. Fix submitted: Corrected template examples by tomlut · Pull Request #10114 · home-assistant/home-assistant.io · GitHub

FYI you can submit corrections if you ever notice a problem with the docs: