ESPHome: Output set max level runtime

I would like to create a dynamic brightness control for the LED’s and display in my ESPHome project.

I’ve got an PCA9685 led driver with outputs mapped to lights.

# UI board Led Driver
  - id: pca9685_hub1
    frequency: 500
    address: 0x5F 

  - platform: pca9685
    pca9685_id: pca9685_hub1
    channel: 0
    id: pwm00
    max_power: 0.25

Adjusting the max_power works perfect in adjusting the maximum brightness, while keeping all the nice features of blinking and effects in place.

Now i would like to be able to adjust the brightness of the leds. For now i will use a numer slider, but in the future an light sensor will control this.

Now the below code does not work, but it reflects the idea i’m looking for:

  - platform: template
    name: "Brightness"
    id: brightness
    optimistic: true
    min_value: 0
    max_value: 1
    step: 0.01
        - logger.log: "brightness changed"
        - output.set_max_power:
            id: pwm00

How would i be able to do this ?