Skip to content

Commit 4cfd69e

Browse files
TRusseloclaudejath03
authored
Keep the requested mode after set_mode() (#96)
* Keep the requested mode after set_mode() OpenRGB 1.0 applies SDK writes on a per-controller thread but answers REQUEST_CONTROLLER_DATA right away, so the update() in set_mode() can return the previous mode. set_color() and set_colors() then dispatch on that stale mode, and when it has no colors (e.g. Off) they send nothing. Home Assistant hits this every time it turns a light on from Off. See https://gitlab.com/CalcProgrammer1/OpenRGB/-/work_items/5924 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Bs25H1VRVY917EZg6GxZhr * Poll for mode change confirmation in set_mode() * Clean up comments in orgb.py Removed comments about OpenRGB 1.0+ behavior and server response. * Warn when the mode change doesn't land in set_mode() --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: Jack Hughes <jackthughes@yahoo.com>
1 parent 8651c0d commit 4cfd69e

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

‎openrgb/orgb.py‎

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from __future__ import annotations
22
import struct
33
import platform
4+
import time
45
import warnings
56
from openrgb import utils
67
from typing import Union, Any, Optional
@@ -333,7 +334,16 @@ def set_mode(self, mode: Union[str, int, utils.ModeData], save: bool = False, fo
333334
len(data)
334335
)
335336
self.comms.send_data(data)
336-
self.update()
337+
for _ in range(5):
338+
self.update()
339+
if self.active_mode == mode.id:
340+
break
341+
time.sleep(0.05)
342+
else:
343+
warnings.warn(
344+
f"Device {self.name} did not confirm mode change to "
345+
f"{mode.name!r}, setting it anyways")
346+
self.active_mode = mode.id
337347

338348
def set_custom_mode(self):
339349
'''

0 commit comments

Comments
 (0)