Allow use of presets (physical button) when receiving live data#5370
Allow use of presets (physical button) when receiving live data#5370IsaccoBenedetti wants to merge 7 commits intowled:mainfrom
Conversation
WalkthroughRemoved a duplicate playlist/presets handling block in the main loop: an early sequence now processes the playlist and presets, and the later duplicate invocation after hue handling was removed. No public APIs or declarations changed. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes 🚥 Pre-merge checks | ✅ 3 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Hi, thanks for your contribution to wled development 👍 I think this PR is a bit mis-labeled ... in fact it does not modify the button handling code. Buttons are read and button can be used as always while WLED is in "external control" mode. The PR does address a weakness that presets controlled by button are not effective until "real time mode" has ended. The PR actually changes the preset and playlist logic, by allowing preset changes and playlist activity during realtime mode. That's a behavioural change and I'm not sure we should go that way. Which the proposed change, the order in the main loop gets changed and presets are now handled prior to OTA, HUE and NightLight. To protect previous behaviour, there should be at new option in "sync interfaces" settings, something like "presets and playlist always active" (maybe find a better wording). I think the root cause of the problem that @IsaccoBenedetti wants to address is somewhere else: Lines 451 to 459 in f830ea4
|
|
PS the summary from @coderabbitai is rubbish, it completely missed the point 😄 |
This comment was marked as resolved.
This comment was marked as resolved.
@coderabbitai yes. And also add that consequences of the behavioural change still need investigation. |
|
I'll trigger the regeneration now. 🧠 Learnings used✅ Actions performedSummary regeneration triggered. |
@coderabbitai it's not clear to me what "LO=2" is actually meant for. please inspects utility functions like leds.cpp, set.cpp, cfg.cpp, XML.cpp, json.cpp to find out what this flag is doing. |
This comment was marked as duplicate.
This comment was marked as duplicate.
This comment was marked as duplicate.
This comment was marked as duplicate.
|
Tip For best results, initiate chat on the files or code changes. 🧩 Analysis chain
🏁 Script executed: Length of output: 10090 🏁 Script executed: Length of output: 1632
LO = Live Override (defined in `#define` REALTIME_OVERRIDE_NONE 0
`#define` REALTIME_OVERRIDE_ONCE 1
`#define` REALTIME_OVERRIDE_ALWAYS 2How it works:
Implementation details:
Special behavior: When So LO=2 in a button preset tells WLED: "ignore all incoming realtime data and apply this preset instead" - which is the escape mechanism from realtime mode that this PR enables by allowing 🧠 Learnings used |
| handlePlaylist(); | ||
| yield(); | ||
| } | ||
| handlePresets(); |
There was a problem hiding this comment.
Another option would be to create an else branch for if (!realtimeMode ...., and put handlepresets() into the else branch. But I would still prefer this to be guarded by a user-controled settings.
|
another option would be to add a checkmark "exit real time mode on button press" in the config and do just that, any button press will exit? |
This comment was marked as duplicate.
This comment was marked as duplicate.
I like your idea 👍 Edit: it's still a good chance to also address the "live mode has infinite timeout" problem - the behaviour is different from all other external control modes, which all use |
|
which one is "live mode"? I only ever used DDP and that one times out after a few seconds. |
Not sure ... its triggered by a json message with Some external tools (hyperion? falcon player?) appear to use this command, but then don't send |
|
@coderabbitai please research the internet on protocol specifications related to the "live mode" or "realtime control" supported by WLED. Which protocols are started by a json message Do these pprotocols mandate an "infinite timeout" until |
|
Tip For best results, initiate chat on the files or code changes. 🧩 Analysis chain
🌐 Web query: 💡 Result: WLED JSON API
|
This comment was marked as duplicate.
This comment was marked as duplicate.
|
@IsaccoBenedetti maybe the latest discussion / research is a bit off-topic. Can you explain your use case of the button solution?
|
|
Hi @softhack007, and thank you for your review! You're right, maybe I should explain my use case better. Basically, it's one of those classic "wife approval" factors: this wled instance drives a led strip in our living room, which I connected both to a HyperHDR instance (which is this fork of Hyperion: https://github.com/awawa-dev/HyperHDR) and to 2 physical buttons on the wall. To be honest, I feel that since api command LO=2 precise purpose is exactly to break out of realtime mode, any user that adds such a command to a preset will probably expect it to work this way, but I also agree that, since the order of the actions in the main loop is slightly changed now, it may introduce some unexpected consequences, though I haven't noticed any so far. Thus, adding a setting in sync interfaces is probably safer. I can look into it if you'd like, do you have any pointers on how you'd do it, since I'm not familiar with the codebase like you? Let me know what your thoughts are |
Hi, first time contributor here!
Recently I ran into a small issue when using physical buttons and HyperHDR. I'm not sure if this was done by design, but currently when WLED is receiving a live data stream physical button inputs are not processed. This makes it impossible to regain local control over the lights once a live source is active, without opening the webUI.
Initially I tried assigning a preset with the API command LO=2 (Live Override) to a physical button, but it didn't work as expected, because the functions that handle preset logic (handlePresets() and handlePlaylist()) are located within the conditional block that is skipped when realtimeMode is true.
This issue has been previously reported by the community on the WLED Discourse forums, but it seems it never got resolved: Live data override on the physical button.
This PR aims to solve the issue, simply by moving the handlePresets() and handlePlaylist() function calls out of the if (!realtimeMode || ...) block in the main loop.
This way button presses and their associated API commands are now processed on every loop cycle, regardless of the live data state. When a button triggers a preset containing LO=2, the realtimeOverride flag is correctly set, allowing WLED to exit the live stream and apply the desired preset.
I was a bit worried these functions were purposely been left inside the check for performance reasons, so I tested it specifically on an ESP8266 instead of an ESP32 with a HyperHDR stream, but I couldn't notice any lag or jitter at all. It seems solid.
What do you think?
Summary by CodeRabbit