Issue with automation and brightness based on time

I’m having an issue with my automation for the light on the hallway i want to use.

My automation looks like this:

- alias: Verlichtig hal eerste verdieping aan bij beweging
  trigger:
    platform: state
    entity_id: binary_sensor.pir_unused_sensor
    to: 'on'
  action:
    service: homeassistant.turn_on
    data:
      entity_id: light.eettafel
      brightness: >-
      {% if now().hour < 22 %}
        255
      {% else %}
        10
      {% endif %}

However when reloading the automations i get the following error:

while scanning for the next token found character '%' that cannot start any token  in "/config/automations.yaml", line 25, column 8

I tried also some other stuff like data_template but it keeps going wrong on the {% … %} inside my automation.

Anyone that have an suggestion that could help me out? Brightness is the only issue i’m facing now, turning it on and off works like a charm.

Never mind, i got it working, seems an indentation issue, the {% if … %} needs to be indented also.