From 4fec7f90321d070b48ac1a5285a70de0cb9ed54d Mon Sep 17 00:00:00 2001 From: septicwolf818 Date: Tue, 11 Aug 2026 22:57:06 +0200 Subject: [PATCH] Fix zone parsing desync on OpenRGB 1.0rc3+ servers Servers with SDK protocol >= 5 serialize a matrix map block for every zone, not just MATRIX zones. ZoneData.unpack only consumed it when zone_type == MATRIX, leaving the parser 8 bytes behind on LINEAR/SINGLE zones and producing garbage values (e.g. "256 is not a valid ZoneType") during device discovery. Consume the matrix block whenever matrix_zone_size > 0, which is backward compatible since the size is 0 when no map exists. Also widen ZoneType to the current server values (LINEAR_LOOP, MATRIX_LOOP_X, MATRIX_LOOP_Y, SEGMENTED) and add a _missing_ fallback so future types don't crash. --- openrgb/utils.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/openrgb/utils.py b/openrgb/utils.py index 7403495..1683d1d 100644 --- a/openrgb/utils.py +++ b/openrgb/utils.py @@ -66,6 +66,17 @@ class ZoneType(IntEnum): SINGLE = 0 LINEAR = 1 MATRIX = 2 + LINEAR_LOOP = 3 + MATRIX_LOOP_X = 4 + MATRIX_LOOP_Y = 5 + SEGMENTED = 6 + + @classmethod + def _missing_(cls, value): + member = int.__new__(cls, value) + member._name_ = f"UNKNOWN_{value}" + member._value_ = value + return member class PacketType(IntEnum): @@ -468,7 +479,7 @@ def unpack(cls, data: Iterator[int], version: int, *args) -> ZoneData: leds_max = parse_var('I', data) num_leds = parse_var('I', data) matrix_zone_size = parse_var('H', data) - if zone_type == ZoneType.MATRIX: + if matrix_zone_size > 0: height = parse_var('I', data) width = parse_var('I', data) matrix: list[list[Optional[int]]] = [[] for x in range(height)]