Skip to content

Media player source selection - #396

Draft
jamesmulcahy wants to merge 2 commits into
NSPManager:develfrom
jamesmulcahy:feat/media-player-sources
Draft

jamesmulcahy wants to merge 2 commits into
NSPManager:develfrom
jamesmulcahy:feat/media-player-sources

Conversation

@jamesmulcahy

Copy link
Copy Markdown
Contributor

Home Assistant media players have a list of sources (inputs) and can select one. This sends a media player's sources to the NSPanel and lets the panel select one.

A media player with a source volume strategy (#385) has two source lists: its own, and those of the source player feeding it. In an audio matrix setup that is the zone's inputs (Movie Theatre, James Matrix, …) and the Sonos Favorites of the speaker the zone is currently playing from.

Protobuf

  • NSPanelEntityState.MediaPlayer.player_sources / source_player_sources: a SourceSelection with the sources, the current source and whether one can be selected. source_player_sources is unset when there is no source player.
  • MediaPlayerCommand.select_player_source / select_source_player_source: select by name, empty means no change. By name because the source player's list changes completely when the zone switches source, so an index from an older state could select the wrong entry.
  • current_source is often empty for the source player: Sonos only reports source for Line-in/TV, not for a playing favourite.
  • The firmware C files were missing volume_step from Home Assistant media players and album art for NSPanels #385 and pick it up here.

Manager

  • HomeAssistantMediaPlayer reads source_list / source and calls media_player.select_source.
  • Following the source player now lives in a new HomeAssistantSourcePlayer, used by both source volume strategies. Before, only source_entity followed the source player; player_attributes only read the player's own attributes and so could not see the source player's sources. The strategies now only differ in where the source volume comes from. With player_attributes, the manager now also subscribes to the source player, which costs one Home Assistant state request per source change.
  • When the player switches source, the previous source player's sources are dropped straight away instead of being offered until the new ones arrive.
  • The NSPanel can only receive 4 KB in one MQTT message (larger messages are silently dropped by the firmware today), so at most 32 sources of up to 64 bytes are sent per list. Longer names are cut on a UTF-8 boundary, and the shortened name sent back by the panel is matched to the full name before selecting.

Not in this PR

  • Panel UI: separate firmware PR. It needs to page through lists longer than 12.
  • Tests: will follow on top of the MQTTManager test harness (Add MQTTManager unit test harness and CI #392).
  • No web UI or REST changes; the existing source volume settings already identify the source player.

Status

Draft: compile-checked only so far, not yet built in Docker or run against Home Assistant.

🤖 Generated with Claude Code

jamesmulcahy and others added 2 commits October 7, 2026 22:49
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>
The manager now reads source_list and source from Home Assistant and
sends them to the NSPanel with the media player state. Select commands
from the panel call media_player.select_source.

Sources of the source player (the player feeding this one, as set up
with the source volume strategy) are sent too. Only the source_entity
strategy used to follow the source player in Home Assistant, the
player_attributes strategy only read attributes of the player itself
and so could not see the source player's sources. Following the source
player now lives in HomeAssistantSourcePlayer, which both strategies
use. They only differ in where the source volume comes from. When the
player switches source, the sources of the previous source player are
dropped straight away rather than offered until the new ones arrive.

The NSPanel can only receive 4 KB in one MQTT message, so at most 32
sources of up to 64 bytes each are sent per list. Longer names are
shortened without splitting a UTF-8 character, and the shortened name
the panel sends back is matched to the full one before selecting it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
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.

1 participant