Skip to content

Commit

Permalink
Ensure preset segments are lists (#1420)
Browse files Browse the repository at this point in the history
  • Loading branch information
frenck authored Aug 7, 2024
1 parent 04d7dba commit 3ff3c2c
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/wled/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -612,6 +612,15 @@ class Preset(BaseModel):
)
"""Segments are individual parts of the LED strip."""

@classmethod
def __pre_deserialize__(cls, d: dict[Any, Any]) -> dict[Any, Any]:
"""Pre deserialize hook for Preset object."""
# If the segment is a single value, we will convert it to a list.
if "seg" in d and not isinstance(d["seg"], list):
d["seg"] = [d["seg"]]

return d

@classmethod
def __post_deserialize__(cls, obj: Preset) -> Preset:
"""Post deserialize hook for Preset object."""
Expand Down

0 comments on commit 3ff3c2c

Please sign in to comment.