Yaml parse error - why is it not working 8-0?

Hi there!

In one of my I got an error while doing check config:

while parsing a flow mapping
  in "/config/automations.yaml", line 1175, column 22
expected ',' or '}', but got '<scalar>'
  in "/config/automations.yaml", line 1175, column 77

Here’s the automation with offending line marked. If I skip the template, everything works fine.

action:
  - service: homeassistant.turn_on
    data_template:
      entity_id: script.light_{{ trigger.to_state.state }}_param
      variables:
        entity_id: light.tasma_led_ekran
        # This line gives me error:
        brightness: {{ state_attr('light.dimmer_salon_kinkiet', 'brightness')}}
# If changed to line below, everything is fine:
#        brightness: 50

What am I doing wrong?
Any help appreciated!

Put double quotes on the outside of the templates

action:
  - service: homeassistant.turn_on
    data_template:
      entity_id: "script.light_{{ trigger.to_state.state }}_param" 
      variables:
        entity_id: light.tasma_led_ekran
        brightness: "{{ state_attr('light.dimmer_salon_kinkiet' , 'brightness') }}" 
1 Like

Thank you very much, that’s exactly what the issue was! Thanks for solving that, it’s a simple error but I just couldn’t work it out by myself!

1 Like