-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
92 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
"""Support for media browsing.""" | ||
|
||
from homeassistant.components.media_player import BrowseMedia | ||
from homeassistant.components.media_player.const import ( | ||
MEDIA_CLASS_APP, | ||
MEDIA_CLASS_DIRECTORY, | ||
MEDIA_TYPE_APP, | ||
MEDIA_TYPE_APPS, | ||
) | ||
|
||
|
||
def build_app_list(app_list): | ||
"""Create response payload for app list.""" | ||
title = None | ||
media = None | ||
children_media_class = None | ||
|
||
title = "Apps" | ||
media = [ | ||
{"app_id": app_id, "title": app_name, "type": MEDIA_TYPE_APP} | ||
for app_name, app_id in app_list.items() | ||
] | ||
children_media_class = MEDIA_CLASS_APP | ||
|
||
return BrowseMedia( | ||
media_class=MEDIA_CLASS_DIRECTORY, | ||
media_content_id=None, | ||
media_content_type=MEDIA_TYPE_APPS, | ||
title=title, | ||
can_play=True, | ||
can_expand=False, | ||
children=[item_payload(item) for item in media], | ||
children_media_class=children_media_class, | ||
) | ||
|
||
|
||
def item_payload(item): | ||
""" | ||
Create response payload for a single media item. | ||
Used by async_browse_media. | ||
""" | ||
return BrowseMedia( | ||
title=item["title"], | ||
media_class=MEDIA_CLASS_APP, | ||
media_content_type=MEDIA_TYPE_APP, | ||
media_content_id=item["app_id"], | ||
can_play=False, | ||
can_expand=False, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters