Skip to content

Keep the requested mode after set_mode() - #96

Merged
jath03 merged 4 commits into
jath03:masterfrom
TRusselo:set-mode-tracks-requested-mode
Oct 8, 2026
Merged

jath03 merged 4 commits into
jath03:masterfrom
TRusselo:set-mode-tracks-requested-mode

Conversation

@TRusselo

@TRusselo TRusselo commented Oct 1, 2026

Copy link
Copy Markdown
Contributor

Device.set_mode() sends UPDATEMODE and then calls update(). OpenRGB 1.0 applies SDK writes on a per-controller thread but answers REQUEST_CONTROLLER_DATA right away, so that update() can return the previous mode. set_color() and set_colors() then dispatch on the stale active_mode, and when it has no colors (e.g. Off) they send nothing, without an error.

Home Assistant's OpenRGB integration hits this every time it turns a light on from Off: set_mode("Direct") followed by set_color(color, fast=True) leaves the device in Direct with its old color.

This keeps active_mode at the mode that was just sent. Against servers that apply writes in order the re-read already matches, so nothing changes there.

The server side is reported as https://gitlab.com/CalcProgrammer1/OpenRGB/-/work_items/5924.

Testing

Off → set_mode("Direct") → random set_color(..., fast=True), 20 rounds, each result checked from a second client (script in the OpenRGB issue), on a Razer Goliathus:

Server 0.3.7 This branch
OpenRGB master 0b02dc62 (protocol 6) 0–3/20, timing dependent 20/20
OpenRGB git 1e1fb09 (protocol 5) 20/20 20/20

flake8 and mypy output is unchanged.

🤖 Generated with Claude Code

https://claude.ai/code/session_01Bs25H1VRVY917EZg6GxZhr

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
@jath03
jath03 force-pushed the set-mode-tracks-requested-mode branch from 7d7e44c to ab0fe5e Compare October 8, 2026 04:50
@jath03
jath03 force-pushed the set-mode-tracks-requested-mode branch from ab0fe5e to 19996ab Compare October 8, 2026 04:53
Removed comments about OpenRGB 1.0+ behavior and server response.

@TRusselo TRusselo left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorry for the comments. fixed

@jath03
jath03 force-pushed the set-mode-tracks-requested-mode branch from e39f0f8 to 50f7b82 Compare October 8, 2026 04:59
@jath03

jath03 commented Oct 8, 2026

Copy link
Copy Markdown
Owner

This is an ugly problem. Your original fix would be invalid if the server rejected the UPDATEMODE request, so I added a short retry loop to catch the race. I still manually set it in the timeout case, as that may occur during rescans, but I added a warning.

The correct solution is to finally implement v6, but this should work for the moment.

@jath03
jath03 merged commit 4cfd69e into jath03:master Oct 8, 2026
4 checks passed
@TRusselo
TRusselo deleted the set-mode-tracks-requested-mode branch October 8, 2026 05:03
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.

2 participants