Skip to content

Add media player source selection and playback position to the protobufs - #410

Merged
tpanajott merged 2 commits into
NSPManager:develfrom
jamesmulcahy:feat/media-player-protos
Oct 21, 2026
Merged

tpanajott merged 2 commits into
NSPManager:develfrom
jamesmulcahy:feat/media-player-protos

Conversation

@jamesmulcahy

@jamesmulcahy jamesmulcahy commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

Protobuf changes only: the .proto changes 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.MediaPlayer

  • SourceSelection 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) and can_select. source_player_sources is 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 from media_position_updated_at. It must not count from when the retained state arrived.

NSPanelMQTTManagerCommand.MediaPlayerCommand

  • select_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.

🤖 Generated with Claude Code

jamesmulcahy and others added 2 commits October 20, 2026 20:18
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>
@jamesmulcahy

Copy link
Copy Markdown
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.

@tpanajott

Copy link
Copy Markdown
Collaborator

@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.

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.

@tpanajott
tpanajott merged commit 4626d00 into NSPManager:devel Oct 21, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants