Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jan 24, 2026

When turnOnAtBoot is disabled but a boot preset contains "on":true, the relay remains off at startup despite LEDs being driven with data.

Root Cause

Boot presets are applied asynchronously after beginStrip() initializes the relay to OFF. By the time handlePresets() updates bri and handleIO() runs, brightness transitions may still report strip.getBrightness() == 0, preventing relay activation.

Changes

  • wled00/presets.cpp: After applying a boot preset (CALL_MODE_INIT), explicitly activate relay if bri > 0 and offMode == true:
if (tmpMode == CALL_MODE_INIT && rlyPin >= 0 && bri > 0 && offMode) {
  pinMode(rlyPin, rlyOpenDrain ? OUTPUT_OPEN_DRAIN : OUTPUT);
  digitalWrite(rlyPin, rlyMde);
  delay(50); // relay stabilization
  offMode = false;
}

This ensures relay switches on immediately when boot preset turns on LEDs, rather than waiting for handleIO() to detect non-zero brightness through the transition.

Original prompt

This section details on the original issue you should resolve

<issue_title>Relay not switching on at power-up with boot-preset</issue_title>
<issue_description>### What happened?

At bootup, the relay pin is not switched on (or not set as an output) if "power on at boot" is not set even if the boot-up preset uses "on":true
After switching off the LEDs and switching them back on, it works as intended.
This is confusing as the UI shows everything working and the LEDs being on, even data is sent to the LEDs but they are not powered as the relay stays off.

To Reproduce Bug

disable "power on at boot" in settings.
set relay pin for example to GPIO25, power on the MCU -> relay does not switch on.

Expected Behavior

when the UI shows the LEDs are on and data is sent, the relay should also be on.

Install Method

Self-Compiled

What version of WLED?

0.16

Which microcontroller/board are you seeing the problem on?

Other

Relevant log/trace output

C3 and ESP32 classic tested.

Anything else?

maybe a comment should be added to the settings that "Turn LEDs on after power up/reset" will be overridden if the boot-preset has "on" set to true.

Code of Conduct

  • I agree to follow this project's Code of Conduct</issue_description>

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 3 commits January 24, 2026 14:14
Co-authored-by: DedeHai <6280424+DedeHai@users.noreply.github.com>
Co-authored-by: DedeHai <6280424+DedeHai@users.noreply.github.com>
Co-authored-by: DedeHai <6280424+DedeHai@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix relay not switching on at power-up with boot-preset Fix relay not switching on at boot with boot preset Jan 24, 2026
Copilot AI requested a review from DedeHai January 24, 2026 14:21
@softhack007
Copy link
Member

softhack007 commented Jan 24, 2026

@DedeHai is it necessary to duplicate the code from handleio()?

void handleIO()

Maybe it would be better to add a parameter to handleIO, like "immediate = false". When immediate = true, the relay code would simply skip all checks and and control the relay?

@DedeHai
Copy link
Collaborator

DedeHai commented Jan 24, 2026

@softhack007 I was hoping copilot would do it properly, you are absolutely right that this is not the correct way to do it.

@DedeHai
Copy link
Collaborator

DedeHai commented Jan 24, 2026

proper fix in #5315

@DedeHai DedeHai closed this Jan 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Relay not switching on at power-up with boot-preset

3 participants