Repository navigation
Media player source selection - #396
Draft
jamesmulcahy wants to merge 2 commits into
Draft
jamesmulcahy wants to merge 2 commits into
jamesmulcahy wants to merge 2 commits into
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>
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
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.
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: aSourceSelectionwith the sources, the current source and whether one can be selected.source_player_sourcesis 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_sourceis often empty for the source player: Sonos only reportssourcefor Line-in/TV, not for a playing favourite.volume_stepfrom Home Assistant media players and album art for NSPanels #385 and pick it up here.Manager
HomeAssistantMediaPlayerreadssource_list/sourceand callsmedia_player.select_source.HomeAssistantSourcePlayer, used by both source volume strategies. Before, onlysource_entityfollowed the source player;player_attributesonly 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. Withplayer_attributes, the manager now also subscribes to the source player, which costs one Home Assistant state request per source change.Not in this PR
Status
Draft: compile-checked only so far, not yet built in Docker or run against Home Assistant.
🤖 Generated with Claude Code