Skip to content

Add media player entity to NSPanel protobufs - #384

Draft
jamesmulcahy wants to merge 1 commit into
NSPManager:develfrom
jamesmulcahy:media-player-protobuf
Draft

jamesmulcahy wants to merge 1 commit into
NSPManager:develfrom
jamesmulcahy:media-player-protobuf

Conversation

@jamesmulcahy

Copy link
Copy Markdown
Contributor

Summary

I've been running media player support on my own NSPanels for several months. That includes Home Assistant media players on room entity pages and a control page on the panel. It started as a local hack with a side-channel MQTT topic and JSON payloads. I'm now unwinding those local changes and upstreaming them properly, in small steps, using the existing protobuf/entity patterns instead of the side channel.

This first PR only changes the manager ↔ panel interface. Nothing produces or consumes these messages yet, and every change is additive, so existing panels and managers are unaffected.

Changes

  • NSPanelEntityState.MediaPlayer: new entity state published on the entity's mqtt_state_topic.
    • Playback: state (off/on/idle/playing/paused/buffering), title and artist.
    • Volume: volume (0-100%) and mute.
    • Capability flags: play, pause, next, previous, set volume and mute. The panel can hide controls the player doesn't support.
    • Optional source volume: for multi-room audio matrices and similar setups, where the source feeding a zone has its own volume (valid only when has_source_volume is set). The panel only sees a volume value. Working out which Home Assistant entity that maps to stays in the manager.
  • NSPanelMQTTManagerCommand.MediaPlayerCommand: panel → manager commands.
    • Playback actions: play, pause, next and previous track.
    • Volume changes: optional volume, source volume and mute, each with a has_* flag, following the pattern already used with protobuf-c.
  • EntitySlot.EntityType.ENTITY_TYPE_MEDIA_PLAYER: lets the panel tell a media player slot from a toggleable one. Tapping it should open the control page instead of sending a toggle.
  • NSPanelStatusReport.state.REBOOTING = 5: the firmware repo's protobuf files already have this (it comes from feat_first_page_react, which defines it identically), but the .proto on devel doesn't. Adding it here keeps the firmware files regenerated from this PR in sync.

Generated code was built with protoc 27.0 and protoc-gen-c 1.4.1, matching the files already on devel. Running those tools on the unmodified .proto files reproduces the committed generated files exactly, so the generated diff only contains the changes above.

Follow-ups

  1. Firmware: copy in the generated protobuf-c files, and add media player handling on the entity page, i.e. the control page and opening it from the room's entities page.
  2. Manager: add a media player entity, following the thermostat pattern, that publishes this state and forwards commands to Home Assistant. Include a global setting to choose how source volume is handled (none, player_attributes or source_entity).
  3. Web UI: add media players to the add/edit entity dialog, plus the settings for the source volume strategy.

I'm opening this as a draft to get early feedback on the message design before the follow-ups build on it.

🤖 Generated with Claude Code

https://claude.ai/code/session_01X7aYyRjzk53Sd7gxF46E3u

Add a MediaPlayer entity state (playback state, title, artist, volume,
mute, optional source volume and capability flags), a MediaPlayerCommand
for panel to manager control, and ENTITY_TYPE_MEDIA_PLAYER for entity
page slots.

Also add the REBOOTING panel state that the firmware protobuf already
carries, so regenerated firmware files keep it.

Generated with protoc 27.0 and protoc-gen-c 1.4.1.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01X7aYyRjzk53Sd7gxF46E3u
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