Value template with state attribute error

Can any body tell me what’s wrong with this code? Probably with a focus on the contents of the value_template.

sensor:
  - platform: template
    sensors:
      last_run_zone_1:
        friendly_name: "Last Run"
        value_template: '{{ (as_timestamp(state_attr('automation.activate_zone_1_timer','last_triggered'))) |   timestamp_custom("%A, %d %h %H:%M") }}'

Returns error

Error: INFO:homeassistant.util.package:Attempting install of colorlog==4.0.2
Testing configuration at /config
ERROR:homeassistant.util.yaml:while parsing a block mapping
  in "/config/configuration.yaml", line 338, column 9
expected <block end>, but found '<scalar>'
  in "/config/configuration.yaml", line 339, column 55
Failed config
  General Errors: 
- Error loading /config/configuration.yaml: while parsing a block mapping
  in "/config/configuration.yaml", line 338, column 9
expected <block end>, but found '<scalar>'
  in "/config/configuration.yaml", line 339, column 55
Successful config (partial)

But if I run the same value template in template checker then I get the following, which is as expected.

Tuesday, 26 Feb 18:30

Thanks for any help.

Check the quotes.
If you have double ones in the template you must wrap them in single ones.
' .... "...." "...." ....'

1 Like

Brilliant! Many thanks that resolved it.