Skip to content

Add a button mode that opens the room's first media player - #425

Draft
jamesmulcahy wants to merge 3 commits into
NSPManager:develfrom
jamesmulcahy:feat/button-open-media-player
Draft

jamesmulcahy wants to merge 3 commits into
NSPManager:develfrom
jamesmulcahy:feat/button-open-media-player

Conversation

@jamesmulcahy

Copy link
Copy Markdown
Contributor

Summary

This PR adds a button mode that opens the room's first media player. Pressing the panel's physical button opens the media player page for the first media player in the panel's room.

Stacked on #423 (the protobuf change). Until that merges, its commit also shows here. Review the last two commits.

Behaviour

  • Mode: "Open the room's first media player", stored as buttonN_mode = 6. It's appended to ButtonMode, because the value is stored in the database.
  • Which player: the first media player in the panel's own room, in the order the room's entities page shows them (pages by display order, then slot). Room scope is deliberate: a fleet-wide "first" would be arbitrary, and with a player from its own room, back from the media player page lands on that room's entities.
  • What the panel gets: OPEN_ENTITY_PAGE, with that player's state topic. The panel opens the page itself, with no round trip to the manager.
  • Room with no media player: the button is sent as NOTIFY_MANAGER, so the relay is left alone, and the manager logs a warning. A press is only logged.

Keeping the topic current

The config is rebuilt whenever the room's media players change. Every REST view that adds, edits, moves or deletes an entity, or creates, deletes or reorders an entities page, already calls send_mqttmanager_reload_command(). That reload runs EntityManager::load_entities(), which resends each panel's config after rooms and entities have reloaded. The config is retained, so a panel that was offline gets it on reconnect. No new code was needed for this.

Web UI

The new mode is one <option> per button in edit_nspanel.html. It has no settings of its own, so views.py and edit_nspanel.js already handle it: saving it clears the detached entity and the custom MQTT settings. There's no migration.

Tests

  • MQTTManager (nspanel_test.cpp, all 51 NSPanelTest pass):
    • picks the first player by slot order;
    • ignores players in other rooms;
    • falls back once the player is removed and the config is resent;
    • other modes send no topic;
    • a press in this mode with no media player is only logged.
  • Django (test_panels.py): the mode saves for both buttons, clears the detached entity, reloads the manager, and the edit page shows it selected.

Also run end to end with the matching firmware against the dev stack (#421) and a QEMU-emulated panel. A press from the screensaver opens the media player page without touching the relay or messaging the manager, a room with no player falls back, and deleting the player resends the fallback config.

🤖 Generated with Claude Code

jamesmulcahy and others added 3 commits November 1, 2026 07:17
OPEN_ENTITY_PAGE tells the panel to open the entity page for
buttonN_entity_page_topic when the button is pressed, without a round
trip to the manager. The relay is left alone.

Older firmware that receives mode 5 logs "Unknown button action" and
does nothing; newer firmware paired with an older manager never
receives it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A button in OPEN_MEDIA_PLAYER mode (stored value 6) is sent to the panel
as OPEN_ENTITY_PAGE with the state topic of the first media player in
the panel's room, in the order the entities page shows them. The panel
opens the page itself, with no round trip to the manager.

If the room has no media player, the button is sent as NOTIFY_MANAGER,
so the relay is left alone and a press is only logged.

The topic follows the room's entities: every change to them reloads the
manager, which resends each panel's config.

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

The mode has no settings of its own. Saving it clears the detached
entity and the custom MQTT settings, as for any mode other than those.

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