Issue with rotary encoder dimming a light group

I have setup easyesp with a rotary encoder. The encoder is configured with a value from 1-100 with every ‘click’ making 4 steps. I have also tried setting it up with a value from 0-16 with 1 step per ‘click’ and translating that to a brightness value from 0-255, but that only improves it just a little, but is still pretty unusable.

I then use the state value of the rotary encoder entity to control a lights brightness_pct from 0-100.

If I view the entity of the encoder in hass, the value goes up and down very smoothly when rotating the encoder. So that works just fine.

As long as I use a single light, that all woks just fine and pretty smooth.

However when controlling the brightness of a hass light group OR a Philips Hue room/group of lights, this results in very unreliable dimming. The Hass light.turn_on > brightness_pct (or the brightness) command seems to have trouble catching up with the rotary encoder entity state value.

This is my configuration:

sensor:

    - platform: mqtt
      state_topic: "/ESP_Easy/rotary1_dimmer/state"
      name: "Livingroom 2 dimmer 1"

Automation:

    - id: livingroom_2_dimmer_1
      alias: "Livingroom 2 dimmer 1"
      trigger:
        platform: mqtt
        topic: /ESP_Easy/rotary1_dimmer/state
      action:
        service: light.turn_on
        entity_id: light.livingroom_group
        data_template:
          brightness_pct: '{{states.sensor.livingroom_2_dimmer_1.state}}'

Is there anybody who could point me to the solution for this issue?

You have to keep in mind that the automation triggers for each change of that sensor, so if you for instance turn your knob from 0-100 in one second that translates to 100 automations beeing triggered in one second and that means 100 service calls to set the lights to that particular percentage. I would not be surprised if that would cause some interference.

Ok, but how does that explain that it does work flawlessly if using just 1 light in stead of a light group? I also tried creating the group in hue, so that hue translates the single light entity to the respective living room lights, but that doesn’t help either :frowning:

How did you go with this?

Any solutions? I was thinking of using this for my kitchen lounge lights

Why don’t you create a script that changes the brightness.

Run a script via automation with each change in state, but add a condition that the script is not already running.

In the script add a 250ms delay after sending the brightness command.

This way you won’t send more than one command every 250ms.