Help with light automation - beginner

I’m new to Home Assistant. I’m trying to make a light turn on when motion is detected, with the brightness based on the time of day.

This is what I have so far. The error I’m getting is “Message malformed: expected float for dictionary value @ data[‘brightness_pct’]”. Any help would be greatly appreciated!

alias: Closet Light On
description: ""
trigger:
  - type: motion
    platform: device
    device_id: 6eb7f10db85b7ac2957935
    entity_id: binary_sensor.4_in_1_sensor_motion_detection
    domain: binary_sensor
condition:
  - condition: device
    type: is_off
    device_id: 18bfacd7487c218ce
    entity_id: light.z_wave_plus_700_series_dimmer_switch
    domain: light
action:
  - type: turn_on
    device_id: 18bfacd7487c218ce527
    entity_id: light.z_wave_plus_700_series_dimmer_switch
    domain: light
    brightness_pct: >
        {% if now().hour > 20 %} 20
        {% elif now().hour < 8 %} 20
        {% else  %} 100 {% endif %}

mode: single

Device actions don’t support templates. Use the light turn on service instead. You might want to stop using device triggers and conditions too. https://community.home-assistant.io/t/what-happens-if-i-have-to-replace-a-device/454183/2