Control dimmer with servo as light

Hello everyone,

I am trying to attach a servo to my light dimmer, so I can control the non-smart lights with Home Assistant.

At the moment I can control the servo with a number component, but I can’t show this in HomeKit and I would like to. Is there any way to turn this number into a template light?

The number goes from -100 to 100, with 0 in the middle. To turn off the light, it needs to go to -100, and to turn it on, it should go to the brightness requested by the user. One problem is that the brightness goes from 0 to 255, but this goes -100 to 100

I greatly appreciate your help, thank you!

Why not replace the dimmer with a Zigbee or Z-Wave dimmer?

Some arithmetic:

{% set servo_min = -100 %}
{% set servo_max = 100 %}
{% set light_brightness_min = 0 %}
{% set light_brightness_max = 255 %}
{% set input_value = states('input_number.bedroom_fan_speed') | float %}
{% set output_value = ((input_value - servo_min) / (servo_max - servo_min)) * (light_brightness_max - light_brightness_min) %}
{{output_value}}


You can see when i set it manually to 0 (as a test for the servo value) then it sets the output_value to 127.5 so 50% brightness.

You can then use that for the brightness value in a light template like this:

light:
  - platform: template
    lights:
      your_light_id:
        friendly_name: "Your Light Friendly Name"
        level_template: |-
          {% set servo_min = -100 %}
          {% set servo_max = 100 %}
          {% set light_brightness_min = 0 %}
          {% set light_brightness_max = 255 %}
          {% set input_value = states('input_number.bedroom_fan_speed') | float %}
          {% set output_value = ((input_value - servo_min) / (servo_max - servo_min)) * (light_brightness_max - light_brightness_min) %}
          {{output_value}}

There are all sorts or smart dimmers available as well as other hardware options to easily dim lights and they fit nicely inside the switch box or in the wall. How do you or anyone else plan to use the wall switch/dimmer after you duck tape a servo onto the front of it? Beside the fact that you will loose that convenient dimmer switch but, your going to have a noisy eye sore there thwt you cant physically use.You might want to rethink this project because you’re most likely going to regret it later on.