Use template sensor
- sensor:
- name: "Adaptive brightness"
unique_id: adaptive_brightness_id_1
state: >-
{% set input_value = (states('sensor.lux_sensor_illuminance_lux')|int) %}
{% set min_input_value = 400 %}
{% set max_input_value = 10 %}
{% set output_min = 0 %}
{% set output_max = 60 %}
{% set mapped_value = (input_value - min_input_value) / (max_input_value - min_input_value) * (output_max - output_min) %}
{% if mapped_value < 10 %}
{{ 0 }}
{% else %}
{{ mapped_value|int }}
{% endif %}
unit_of_measurement: '%'
This uses a lux sensor.
In this example it maps the lux sensor value from 400lx to 10lx > 0 to 60%.
Adapt the mapped values to your liking.
example: a lux sensor value of 300lx will set the value to 15% and a value of 20lx will output 58%
The output number is exposed as a state value that can be used for the brighness_pct for lights. Set a long transition time as to compensate for the lux sensor update time. The lights will dim/brighten automagically.