Revise media source documentation for search support#3229
Conversation
Updated the media source documentation to reflect changes in the data types and added examples for enabling search support based on specific paths.
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
✅ Files skipped from review due to trivial changes (1)
📝 WalkthroughWalkthroughDocumentation for media-source searching is updated: ChangesMedia source search documentation
Estimated code review effort: 1 (Trivial) | ~5 minutes Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Pull request overview
Updates the Media Source platform documentation to align search-related type hints with current Home Assistant models and to clarify how integrations should advertise search support in the media browser.
Changes:
- Updated
SearchMedia.resulttype documentation toSequence[BrowseMedia]. - Revised the “Advertising search support” guidance and expanded the examples, including conditional search enablement based on the current
MediaSourceItem.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| return BrowseMediaSource( | ||
| domain=DOMAIN, | ||
| identifier=None, | ||
| media_class=MediaClass.APP, | ||
| media_content_type="", |
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
|
|
||
| return BrowseMediaSource( | ||
| domain=DOMAIN, | ||
| identifier=None, |
There was a problem hiding this comment.
| identifier=None, | |
| identifier=item.identifier, |
is probably the more correct default for most cases
There was a problem hiding this comment.
AFAIK the identifier should be None for the root element and only the child elements should get their correct identifier set.
https://developers.home-assistant.io/docs/core/platform/media_source#browsemediasource
Parameter Type Description identifierstr | NoneItem-specific identifier. Use Nonefor root items.
it's also in all other examples above, that the root element always has identifier=None
There was a problem hiding this comment.
That's why I am saying not using one is probably the better default as None only works for root specifically and could be a common pitfall if the frontend is not aware of the current position in the directory structure
There was a problem hiding this comment.
I think I got it now - the returned BrowseMediaSource is the current visible container, whereas the childs are those are displayed? So the BrowseMediaSource is not the root of the integrations media source.
Co-authored-by: Josef Zweck <josef@zweck.dev>
Updated the media source documentation to reflect changes in the data types and added examples for enabling search support based on specific paths.
Proposed change
This tries to improve and clarify how to advertise search support.
Type of change
Checklist
Additional information
Summary by CodeRabbit
can_search=Trueon the root media source returned byasync_browse_media().can_searchvalue from the current media item identifier (for example, via anis_searchable(...)-style check for directories).