Newbie Error: Message malformed: extra keys not allowed @ data['data_template']

I’m trying to specify different brightness based on time of day, but can’t even save the automation due to this error. Any help would be greatly appreciated.

alias: Motion Lights Study
description: ''
trigger:
  - type: motion
    platform: device
    device_id: e21def2de54d327fb03eeebd05cc8991
    entity_id: binary_sensor.study_pir
    domain: binary_sensor
condition: []
action:
  - type: turn_on
    device_id: 8170e2530a33500b4f697173b77f848f
    entity_id: light.s
    domain: light
    data_template:
      brightness_pct: >
        {% if now().hour > 20 %}50
        {% elif now().hour < 5 %}30
        {% elif now().hour < 8 %}50
        {% else %}100
        {% endif %}

change this:

to this:

data:

Thank you for the suggestion. I get exactly the same error using ‘data:’ instead of ‘data_template:’.

“ Message malformed: extra keys not allowed @ data[‘data’]”

Did you use the editor to create the automation or hand type it?

I don’t use the editor so TBH, I have no idea what the syntax is for an action using a “device”.

I don’t know if “data:” is a valid option there or not. That’s what it seems to be complaining about tho.