Cwww Light reboots when set to midrange, due to watchdog timeout

I may have discovered a bug in the cwww component.

I have 5 cwww lights running ESPHome which reboot themselves approx. every 5-6 minutes when set to midrange color-temperature and brightness values (e.g. 25% bright, 4000K).
Suspecting power problems, I added large caps to the 24v and 5V bus, no improvement. Ocilloscope traces confirm that the 5V bus is rock-solid.

A spare ESP8266 (a lolin d1_mini) - that was connected to nothing but a USB cable for the serial log - was also affected, which told me the problem had to be in software or an inherent characteristic of the 8266. Unable to pursue the latter, I went for the former.
Logs show:

rst cause:4, boot mode:(3,6)
wdt reset

The devices are stable at either end of the color/brightness ranges - they only self-reset when the colors were about equal.
So, I looked around and found that the call shown below may ā€˜feedā€™ the watchdog timer sufficiently to prevent the random rebooting.

esphome:
  on_loop:
    then:
      - lambda: |-
          ESP.wdtFeed(); return;

After adding the call to WDT, the devices have remained reboot-free for 18 hours. Previously they could not last beyond a sunset/sunrise, when the circadian code in HA sets them to the troublesome midranges of color & brightness.

Here is the relevant portion of the deviceā€™s config:

light:
  - platform: cwww
    name: ${node_name}
    id: the_light
    cold_white: output_cool_leds
    warm_white: output_warm_leds
    cold_white_color_temperature: 6024 K
    warm_white_color_temperature: 2700 K
    default_transition_length: 1s
    constant_brightness: true

output:
  - platform: esp8266_pwm
    id: output_warm_leds
    pin: GPIO5
    inverted: false
  - platform: esp8266_pwm
    id: output_cool_leds
    pin: GPIO4
    inverted: false

So, while this workaround seems to suffice for me, I wonder if I should submit this as a bug in the cwww component of ESPHome?

Yes I think it belongs on github.

There is another thread here a month to 6 weeks ago where wdt was causing issues. See if I wan find it. edit here Simultaneously turning on or off physical switch trigger hardware watchdog but on reflection probably unrelated.

1 Like

When I added ā€œinstrumentationā€ such as sntp_time, loop time, heap fragmentation, etc, and removed the wdtfeed call, the problem remained absent.
That smells like a pseudo-race happening at a much lower level than the cwww module.
I looked into the cwww and Light code, and the math in the ESPHome code seems sane and unlikely to cause loop starvation. My guess is this issue is an emergent property of the underlying Arduino lib that handles software PWM (or, in this case, 2 of them simultaneously).
But thanks for the input. I appreciate the concurrence and will post as an issue on GitHub, if only so the maintainer on the ESPHome side can be aware of it.
But I suspect the prob does not reside in their code.

As of 2024.10.x, this problem has returned.

Previous to this version, the WDT feed described above has suppressed the problem, but after 2024.10 that workaround no longer helps.