File tree Expand file tree Collapse file tree 1 file changed +19
-4
lines changed Expand file tree Collapse file tree 1 file changed +19
-4
lines changed Original file line number Diff line number Diff line change @@ -295,12 +295,27 @@ class Segment(BaseModel):
295295 """
296296
297297 name : str | None = field (default = None , metadata = field_options (alias = "n" ))
298- """The name of the segment.
299-
300- Names are not present by default. If this is none, use
301- "Segment{segment_id}" to match the WLED UI .
298+ """User-defined segment name (alias: "n").
299+
300+ Not present by default. If None or empty, callers may fall back to a UI-like
301+ default, e.g., "Segment {segment_id}".
302302 """
303303
304+ @property
305+ def effective_name (self ) -> str :
306+ if self .name :
307+ return self .name
308+ if self .segment_id is not None :
309+ return f"Segment { self .segment_id } "
310+ return "Segment"
311+
312+ @classmethod
313+ def __post_deserialize__ (cls , obj : "Segment" ) -> "Segment" :
314+ # Normalize empty string to None for consistency
315+ if obj .name == "" :
316+ obj .name = None
317+ return obj
318+
304319
305320@dataclass (kw_only = True )
306321class Leds :
You can’t perform that action at this time.
0 commit comments