Dim lights according to the sun

That seems back-to-front. You need less artificial light during the day and more at night.

The way I do it is with a template sensor. This calculates the required brightness depending on the outside lux level.

I use this sensor to set the brightness whenever I turn a light on, and continuously in some places.

This template is specific to my lights and my light sensor so won’t work for you. But here’s the idea:

template:
  - sensor:
      - name: 'Calculated Light Brightness'
        unique_id: ec93bfc9-9b35-4281-a1da-7907469766e7
        unit_of_measurement: "Int"
        state: >
          {{ ( [0, (-0.1785 * states('sensor.outside_light_level')|float(0) + 298.35 )|int(0), 255]|sort )[1] }}
        availability: "{{ states('sensor.outside_light_level')|is_number }}"
  action:
  - service: light.turn_on
    entity_id: light.kitchen_downlights
    data:
      brightness: "{{ states('sensor.calculated_light_brightness')|int(0) }}"
      transition: 5
      kelvin: 4000

If you don’t have a lux sensor you could make one.