Repository navigation
Add media player source selection and playback position to the protobufs - #410
Merged
tpanajott merged 2 commits intoOct 21, 2026
Merged
Conversation
Home Assistant media players have a list of sources (inputs) and can select one. A media player with a source volume strategy also has a source player feeding it, which has its own sources, for example the Sonos Favorites of the speaker an audio matrix zone is playing from. NSPanelEntityState.MediaPlayer gets both lists as a SourceSelection (sources, current source and whether one can be selected). source_player_sources is unset when there is no source player. MediaPlayerCommand selects a source from either list by name. The lists change when the player switches source, so an index from an older state could select the wrong one. An empty name means no change, as no source is called "". The firmware C files were also missing volume_step from NSPManager#385 and pick it up here. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
NSPanelEntityState.MediaPlayer gets the playback position and duration of the current media, so panels can show a progress bar. Home Assistant only reports the position when playback starts, stops or seeks, together with the time it was taken. Sending that time as well lets a panel advance the position itself while playing, without the manager publishing a state every second. The state is retained, so a panel can receive it long after it was sent; the time is absolute (Unix seconds) rather than relative to when the state arrived for that reason. has_media_position is unset when there is no position, and a duration of 0 means it is unknown, as for a live stream. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Oct 21, 2026
Contributor
Author
|
@tpanajott I pulled the protobuf changes out of the sources+position PRs. If you're happy to merge these independently of the associated code (which is in the other PRs), I can finish getting the firmware side wired up to the real data. |
Collaborator
Sure, I'll try and read through this one and #409 and #396 but they are quite massive so it may take me a while. |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Protobuf changes only: the
.protochanges and the regenerated C++ and firmware C code for media player source selection (#396) and playback position (#409). This PR contains only messages and fields; no code uses them yet.Splitting them out lets this merge on its own. The firmware can then be built against these definitions while the manager PRs are reviewed. #396 and #409 are rebased onto this branch and will only contain manager code once this merges.
NSPanelEntityState.MediaPlayerSourceSelection player_sources = 18,source_player_sources = 19: the sources (inputs) of the player, and of the source player feeding it, if it has one (an audio matrix zone and the Sonos speaker it is playing from, for example). Each has its sources, the current source (empty if unknown) andcan_select.source_player_sourcesis unset when there is no source player.has_media_position = 20,media_position = 21,media_position_updated_at = 22,media_duration = 23: the playback position in seconds, the Unix time it was taken at, and the duration (0 if unknown, for example on a live stream). Home Assistant only reports the position when playback starts, stops or seeks. A panel advances the position itself while playing, starting frommedia_position_updated_at. It must not count from when the retained state arrived.NSPanelMQTTManagerCommand.MediaPlayerCommandselect_player_source = 9,select_source_player_source = 10: select a source by name, with an empty name meaning no change. Names are used rather than indexes because the source player's list changes completely when the zone switches source, so an index from an older state could pick the wrong entry.Generated code
The generated code was made with #395's
docker/protobuf/regenerate.sh(protoc 27.0, protobuf-c 1.4.1). Regenerating each commit gives exactly the files committed here.volume_stepfrom Home Assistant media players and album art for NSPanels #385, which was missing from them.protobuf_firmware/protobuf_nspanel.pb-c.*for the buzzer sounds (Send per-event buzzer sounds to panels in NSPanelConfig #394) andtz_posix(Send NSPanels the POSIX TZ rule for the manager's timezone #405), which were never regenerated for the firmware. That drift isn't related to media players and Add pull request checks for Django, Docker, protobuf and React #395 already covers those files, so it's left out of this PR. Whichever of this PR and Add pull request checks for Django, Docker, protobuf and React #395 merges second will need its generated files regenerated.🤖 Generated with Claude Code