ESP32 LEDC Light turn on behaviour

Hey all,

I am kind of confused why my 3 Monochromatic PWM Lights all connected to a ESP32 nodemcu dev board behave the following way.

My device configuration looks like this (I’ve removed some unrelated things):

esphome:
  name: "esp32-test"
  friendly_name: ESP32 Test

[...]

esp32:
  #board: esp32dev
  #board: nodemcu-32s2
  board: esp32doit-devkit-v1
  framework:
    type: arduino
    #type: esp-idf

[...]

# Custom Lights
light:
  # Single Light 0
  - platform: monochromatic
    output: pwm_output_0
    id: light_0
    name: "Monochromatic Light R"
    effects:
      [...]
    default_transition_length: 3s
    restore_mode: ALWAYS_OFF
  # Single Light 1
  - platform: monochromatic
    output: pwm_output_1
    id: light_1
    name: "Monochromatic Light M"
    effects:
      [...]
    default_transition_length: 3s
    restore_mode: ALWAYS_OFF
  # Single Light 2
  - platform: monochromatic
    output: pwm_output_2
    id: light_2
    name: "Monochromatic Light L"
    effects:
      [...]
    default_transition_length: 3s
    restore_mode: ALWAYS_OFF

# Custom PWM Outputs
output:
  - platform: ledc
    pin: GPIO4
    frequency: 1000 Hz
    id: pwm_output_0
  - platform: ledc
    pin: GPIO16
    frequency: 1000 Hz
    id: pwm_output_1
  - platform: ledc
    pin: GPIO17
    frequency: 1000 Hz
    id: pwm_output_2

Now what I would expect to happen…

when I turn on one of the Light entities (that is currently off) in Home Assistant without defining a brightness: The Light should turn on at the last used brightness or maybe at 100%.

when I turn on one of the Light entities (that is currently off) in Home Assistant, defining a target Brightness of 100%: The Light should turn on at 100% or at least transition from 0% or the last used brightness to 100%.

when I create a group helper in Home Assistant to control all lights at once, and turn on this light entity at for example 100 %: The individual Lights should then turn on / transition to 100 % brightness.

But It seems I misunderstand something or misconfigured it…

when I turn on one of the Light entities (that is currently off) in Home Assistant without defining a brightness: The Light turns on at the same or very slightly below the brightness of the other lights, if they are on. When no other Lights on the device are on, the light turns on at 1% brightness.

when I turn on one of the Light entities (that is currently off) in Home Assistant, defining a target Brightness of 100%: The Light (or Home Assistant?) ignores the
brightness and turns on as if none was given (see above). When I send the same turn_on service again while the light is now on, the light transitions to the given brightness without issue.

when I create a group helper in Home Assistant to control all lights at once: When turning on all the lights via the group entity without defining a brightness, the lights (and subsequently the group light) behaves like described above and turns on at 1%. When one of the lights is already on, the group is already on, and I don’t define a target brightness the previously off light turns on at the brightness of the other lights (as expected). However, when I do the same while defining a new target brightness the group light jumps to the new target brightness, then back to the real / previous brightness of the lights. When all lights in the group are on, and I change the brightness of the group, It shows the same jumping behavior but the lights actually transition to the desired brightness and the group brightness finally jumps to the new real brightness.

I tried to use light partition with all single lights as segments instead of the Home Assistant Group entity, but that had its own problems:

light:
  # Light Group
  - platform: partition
    name: "Monochromatic Lights"
    id: light_group
    segments:
      - single_light_id: light_0
      - single_light_id: light_1
      - single_light_id: light_2
    effects:
      - pulse:
    default_transition_length: 3s
    restore_mode: RESTORE_AND_OFF
    on_turn_on:
      then:
        - light.turn_off: 
            id: light_0
            transition_length: 0s 
        - light.turn_off: 
            id: light_1
            transition_length: 0s 
        - light.turn_off: 
            id: light_2
            transition_length: 0s

I still wanted to control the single lights using their entities, so I added on_turn_on actions to turn_off the single lights when turning on the group and vice versa.
That caused the lights to flicker when all are off and are turned on via the group / partition. Additionally, when turning the lights off via the group (also turned on via the group) the lights would transition to 1%, halt a moment and then flick off. The single lights turn off smoothly. That is mainly why I moved to a Home Assistant Group Helper, as then the lights turn off smoothly in a group.

To summarize, I am confused by the behavior the monochromatic LEDC lights show when I turn them on or change the brightness in a HA Group. As far as I understand the documentation, the “restore_mode” only refers to the behavior when the device loses power and what state the light should then assume. But I may be wrong on that.

Also, the ESPHome Device Logs just show the same as the observed behaviour, It’s not like they show the defined target brightness and then the light does something else. They show exactly what happens, as described above. But maybe I’m not using the correct loglevel to see what really happens?

Also the ESPHome Device Logs show a regular brightness “change” to the same brightness as currently set with a transition time of 45s, and I really can’t tell where that comes from. It doesn’t come from the HA Group Helper as It still happens when I delete that group. It doesn’t change the real light brightness, but still confusing.

I may not be using the right esp32 board definition or the right framework, as I couldn’t find the “NodeMCU ESP32 devkit v1” as a valid board, so I assumed the “espdoit-devkit-v1” should be good?

I’d be very grateful If anyone could point me in the right direction or correct my assumptions or just share their experience as I am a bit lost here. Thank you very much for reading this wall of text and for any responses.

Writing it all down made me think about it and I think the ESP Device uses the last defined target brightness of any previous action of any light for any next action if no brightness is given or the light is turned on.

What I mean by that / how I came to that conclusion:

  1. Light 0 + 1 + 2 turned on at / transitioned to brightness 20 %
  2. Light 2 brightness change to 10 %
  3. (optional) Light 2 turn off from 10 % brightness
  4. Light 0 turn off from 20 % brightness
  5. Light 0 turn on, brightness at turn_on is 10 %

Why else would light 0 turn back on at the last brightness of light 2?
This internal target brightness seems to only be affected by brightness changes, and when the last light is turned off it changes to 1%.

First things first… Before adding extra configuration settings, effects, and all the other stuff, just do a bare bones config and make sure youve got everything wired correctly and the lights work as they should. I never understand why anyone sets a bunch of extra configs without first checking the actual light first. Does a bare minimum config work?