-
-
Notifications
You must be signed in to change notification settings - Fork 28.4k
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
Add metadata support to Snapcast media players #117372
base: dev
Are you sure you want to change the base?
Conversation
Hey there @luar123, mind taking a look at this pull request as it has been labeled with an integration ( Code owner commandsCode owners of
|
This reverts commit fca4360.
704bd19
to
8cbf558
Compare
That looks like a nice addition, thanks! |
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.
I have added a few small comments, nothing critical. In general it would be much easier to review if you would split it in two PRs: one for the refactor and one for metadata support. Metadata support could be simplified by adding metadata properties to the python-snapcast client/group classes first but I think your solution is fine.
self._entry_id = entry_id | ||
self._attr_unique_id = f"{GROUP_PREFIX}{uid_part}_{self._group.identifier}" | ||
self._attr_media_content_type = MediaType.MUSIC |
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.
I would not hard-code this. Snapcast could be anything, not only music.
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.
I understand where you're coming from as the stream could be a broadcast, notification, etc,
But
A. MediaType.MUSIC
is required for artist
and album
metadata to be parsed.
B. Snapcast doesn't currently provide a means to specify this.
Of the available MediaType, MUSIC
and PODCAST
might be the only relevant types.
class MediaType(StrEnum):
"""Media type for media player entities."""
ALBUM = "album"
APP = "app"
APPS = "apps"
ARTIST = "artist"
CHANNEL = "channel"
CHANNELS = "channels"
COMPOSER = "composer"
CONTRIBUTING_ARTIST = "contributing_artist"
EPISODE = "episode"
GAME = "game"
GENRE = "genre"
IMAGE = "image"
MOVIE = "movie"
MUSIC = "music"
PLAYLIST = "playlist"
PODCAST = "podcast"
SEASON = "season"
TRACK = "track"
TVSHOW = "tvshow"
URL = "url"
VIDEO = "video"
We could attempt to deduce the type by checking the metadata. If an album
or artist
property is present set the type to MUSIC
otherwise leave it empty.
self._entry_id = entry_id | ||
self._attr_unique_id = f"{GROUP_PREFIX}{uid_part}_{self._group.identifier}" | ||
self._attr_media_content_type = MediaType.MUSIC | ||
self._attr_device_class = MediaPlayerDeviceClass.SPEAKER |
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.
I would not hard-code this. Snapcast clients could also run on a TV/kodi. And for groups it does not apply, does it? (badaix/snapcast#956)
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.
Ok. I went with speaker because even if running on a TV Snapcast can still only play audio.
Since that issue has not been addressed and no client type information is passed back to the server, what would you recommend? Leave it unset?
Thanks for taking time to review. I'll check out the comments.
If you want me to split the PR in two that's no problem. I am also working on another change to implement the grouping in line with this architecture discussion. It adds the media player grouping services and attributes. That PR would make the refactor here redundant as it eliminates the Group entities all together. |
Proposed change
Add metadata support to Snapcast media players.
Snapcast streams can contain metadata provided via a stream plugin or natively.
Snapcast includes support for the following sources:
Additionally I have developed a stream plugin for UPnP renderers: https://github.com/mill1000/snapcast-upnp
Example Screenshots
UPnP Stream Plugin
Airplay Native
Type of change
Additional information
Checklist
ruff format homeassistant tests
)If user exposed functionality or configuration variables are added/changed:
If the code communicates with devices, web services, or third-party tools:
Updated and included derived files by running:
python3 -m script.hassfest
.requirements_all.txt
.Updated by running
python3 -m script.gen_requirements_all
..coveragerc
.To help with the load of incoming pull requests: