Skip to content

Commit 3ff3c2c

Browse files
authored
Ensure preset segments are lists (#1420)
1 parent 04d7dba commit 3ff3c2c

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/wled/models.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -612,6 +612,15 @@ class Preset(BaseModel):
612612
)
613613
"""Segments are individual parts of the LED strip."""
614614

615+
@classmethod
616+
def __pre_deserialize__(cls, d: dict[Any, Any]) -> dict[Any, Any]:
617+
"""Pre deserialize hook for Preset object."""
618+
# If the segment is a single value, we will convert it to a list.
619+
if "seg" in d and not isinstance(d["seg"], list):
620+
d["seg"] = [d["seg"]]
621+
622+
return d
623+
615624
@classmethod
616625
def __post_deserialize__(cls, obj: Preset) -> Preset:
617626
"""Post deserialize hook for Preset object."""

0 commit comments

Comments
 (0)