-
-
Notifications
You must be signed in to change notification settings - Fork 34
Add segment name #1810
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Add segment name #1810
Conversation
WalkthroughAdds an optional Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 💡 Knowledge Base configuration:
You can enable these sources in your CodeRabbit configuration. 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
✨ Finishing Touches
🧪 Generate unit tests
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR/Issue comments)Type Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (2)
src/wled/models.py (2)
298-302: Tighten docstring and remove trailing whitespaceClarify fallback wording, reference
Nonecorrectly, and avoid trailing spaces to keep linters happy.- """The name of the segment. - - Names are not present by default. If this is none, use - "Segment{segment_id}" to match the WLED UI. - """ + """User-defined segment name (alias: "n"). + + Not present by default. If None or empty, callers may fall back to a UI-like + default, e.g., "Segment {segment_id}". + """
297-303: Optional: expose a computed fallback to reduce duplication downstreamConsider providing a convenience property (and optional normalization) so consumers don’t have to replicate fallback logic.
Example (outside the changed hunk):
# Inside class Segment @property def effective_name(self) -> str: if self.name: return self.name if self.segment_id is not None: return f"Segment {self.segment_id}" return "Segment" @classmethod def __post_deserialize__(cls, obj: "Segment") -> "Segment": # Normalize empty string to None for consistency if obj.name == "": obj.name = None return obj
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
💡 Knowledge Base configuration:
- MCP integration is disabled by default for public repositories
- Jira integration is disabled by default for public repositories
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (1)
src/wled/models.py(1 hunks)
🔇 Additional comments (1)
src/wled/models.py (1)
297-303: Addition ofname(alias "n") looks correctMatches WLED’s segment JSON field and will omit on serialization when
None, which is desirable. Nice, minimal change.
|
@coderabbitai I pushed a fix, please review it. |
|
I checked that this change is correct at the real device. At the beginning, I didn't have any segments name Then I set a name for two segments: And later I deleted the name of the segment: |
|
There hasn't been any activity on this pull request recently. This pull request has been automatically marked as stale because of that and will be closed if no further activity occurs within 7 days. Thank you for your contributions. |
|
This is waiting for review from the project maintainer. |
Proposed Changes
Hi. WLED allows you to set your own segment names, but unfortunately this name is not available in HA and HA generates names based on ID, which is a bit confusing. To solve this, I add name deserialization. As a next step, we can update HA to use this field.
The segment name is available at n field in API.
https://github.com/wled/WLED/blob/705f2035f4b31eb997e1d5718f30352657c7d930/wled00/json.cpp#L140-L147
https://github.com/paul-fornage/wled-json-api-library/blob/87abb06b1ae878b6c8f5ba6d4c11f9f5c9dc68a7/src/structures/state.rs#L244-L249
Related Issues
home-assistant/core#124271
Summary by CodeRabbit
New Features
Bug Fixes