From 24e6ecac23fb6e337fa65383f619af5f994c524e Mon Sep 17 00:00:00 2001 From: DodoSeal Date: Thu, 1 Jan 2026 14:20:01 -0700 Subject: [PATCH 1/3] Update wizlights Usermod - Add LED Offset Configuration - Offset Wiz Lights from the first pixels to become individually controllable - MUST add MAX_WIZ_LIGHTS to WLED output when offset = output length --- usermods/wizlights/wizlights.cpp | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/usermods/wizlights/wizlights.cpp b/usermods/wizlights/wizlights.cpp index 3ac756b12a..35ad90fe4e 100644 --- a/usermods/wizlights/wizlights.cpp +++ b/usermods/wizlights/wizlights.cpp @@ -15,6 +15,7 @@ class WizLightsUsermod : public Usermod { unsigned long lastTime = 0; long updateInterval; long sendDelay; + int ledOffset; long forceUpdateMinutes; bool forceUpdate; @@ -90,7 +91,7 @@ class WizLightsUsermod : public Usermod { bool update = false; for (uint8_t i = 0; i < MAX_WIZ_LIGHTS; i++) { if (!lightsValid[i]) { continue; } - uint32_t newColor = strip.getPixelColor(i); + uint32_t newColor = strip.getPixelColor(i + ledOffset); if (forceUpdate || (newColor != colorsSent[i]) || (ellapsedTime > forceUpdateMinutes*60000)){ wizSendColor(lightsIP[i], newColor); colorsSent[i] = newColor; @@ -107,6 +108,7 @@ class WizLightsUsermod : public Usermod { void addToConfig(JsonObject& root) { JsonObject top = root.createNestedObject("wizLightsUsermod"); + top["LED Offset"] = ledOffset; top["Interval (ms)"] = updateInterval; top["Send Delay (ms)"] = sendDelay; top["Use Enhanced White *"] = useEnhancedWhite; @@ -127,13 +129,14 @@ class WizLightsUsermod : public Usermod { JsonObject top = root["wizLightsUsermod"]; bool configComplete = !top.isNull(); - configComplete &= getJsonValue(top["Interval (ms)"], updateInterval, 1000); // How frequently to update the wiz lights + configComplete &= getJsonValue(top["LED Offset"], ledOffset, 0); // Offset the "address" of the Wiz Lights for individual control + configComplete &= getJsonValue(top["Interval (ms)"], updateInterval, 1000); // How frequently to update the Wiz lights configComplete &= getJsonValue(top["Send Delay (ms)"], sendDelay, 0); // Optional delay after sending each UDP message - configComplete &= getJsonValue(top["Use Enhanced White *"], useEnhancedWhite, false); // When color is white use wiz white LEDs instead of mixing RGB + configComplete &= getJsonValue(top["Use Enhanced White *"], useEnhancedWhite, false); // When color is white use Wiz white LEDs instead of mixing RGB configComplete &= getJsonValue(top["* Warm White Value (0-255)"], warmWhite, 0); // Warm White LED value for Enhanced White - configComplete &= getJsonValue(top["* Cold White Value (0-255)"], coldWhite, 50); // Cold White LED value for Enhanced White - configComplete &= getJsonValue(top["Always Force Update"], forceUpdate, false); // Update wiz light every loop, even if color value has not changed - configComplete &= getJsonValue(top["Force Update Every x Minutes"], forceUpdateMinutes, 5); // Update wiz light if color value has not changed, every x minutes + configComplete &= getJsonValue(top["* Cold White Value (0-255)"], coldWhite, 50); // Cold White LED value for Enhanced White + configComplete &= getJsonValue(top["Always Force Update"], forceUpdate, false); // Update Wiz light every loop, even if color value has not changed + configComplete &= getJsonValue(top["Force Update Every x Minutes"], forceUpdateMinutes, 5); // Update Wiz light if color value has not changed, every x minutes // Read list of IPs String tempIp; From 7466e68b5e1d8fc481ee15c9c02d465c87bbec10 Mon Sep 17 00:00:00 2001 From: DodoSeal Date: Thu, 1 Jan 2026 14:42:17 -0700 Subject: [PATCH 2/3] Add CodeRabbit Suggestions - Change **ledOffset** to **uint16_t** type - Add validation for **ledOffset** to prevent addressing more LEDs than configured --- usermods/wizlights/wizlights.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/usermods/wizlights/wizlights.cpp b/usermods/wizlights/wizlights.cpp index 35ad90fe4e..2d9ee679d6 100644 --- a/usermods/wizlights/wizlights.cpp +++ b/usermods/wizlights/wizlights.cpp @@ -15,8 +15,8 @@ class WizLightsUsermod : public Usermod { unsigned long lastTime = 0; long updateInterval; long sendDelay; - int ledOffset; - + uint16_t ledOffset; + long forceUpdateMinutes; bool forceUpdate; @@ -130,6 +130,13 @@ class WizLightsUsermod : public Usermod { bool configComplete = !top.isNull(); configComplete &= getJsonValue(top["LED Offset"], ledOffset, 0); // Offset the "address" of the Wiz Lights for individual control + + if (ledOffset + MAX_WIZ_LIGHTS > strip.getLengthTotal()) + { + ledOffset = 0; + configComplete = false; + } + configComplete &= getJsonValue(top["Interval (ms)"], updateInterval, 1000); // How frequently to update the Wiz lights configComplete &= getJsonValue(top["Send Delay (ms)"], sendDelay, 0); // Optional delay after sending each UDP message configComplete &= getJsonValue(top["Use Enhanced White *"], useEnhancedWhite, false); // When color is white use Wiz white LEDs instead of mixing RGB From 3b11e8bf57b14947a8eeb8ac4ec98bd9fea18cc3 Mon Sep 17 00:00:00 2001 From: DodoSeal Date: Thu, 1 Jan 2026 14:55:20 -0700 Subject: [PATCH 3/3] Add CodeRabbit Suggestions - Add more validation for strip length and ledOffset --- usermods/wizlights/wizlights.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/usermods/wizlights/wizlights.cpp b/usermods/wizlights/wizlights.cpp index 2d9ee679d6..b178e8a3c9 100644 --- a/usermods/wizlights/wizlights.cpp +++ b/usermods/wizlights/wizlights.cpp @@ -91,7 +91,11 @@ class WizLightsUsermod : public Usermod { bool update = false; for (uint8_t i = 0; i < MAX_WIZ_LIGHTS; i++) { if (!lightsValid[i]) { continue; } - uint32_t newColor = strip.getPixelColor(i + ledOffset); + + uint16_t pixelIndex = i + ledOffset; + if (pixelIndex >= strip.getLengthTotal()) continue; + uint32_t newColor = strip.getPixelColor(pixelIndex); + if (forceUpdate || (newColor != colorsSent[i]) || (ellapsedTime > forceUpdateMinutes*60000)){ wizSendColor(lightsIP[i], newColor); colorsSent[i] = newColor;