Skip to content

[RFC] Publish multiple active media sessions to separate MQTT topics #26

Description

@qweritos

Android may have several MediaSessions active at once. Currently the app selects one current session and publishes only its state.

I propose keeping the existing topics unchanged for backward compatibility:

mediaSession/{deviceId}/playbackState
mediaSession/{deviceId}/playbackPosition
...

They would continue to represent the currently selected session.

Each active session could additionally be published under:

mediaSession/{deviceId}/sessions/{sessionId}/applicationId
mediaSession/{deviceId}/sessions/{sessionId}/playbackState
mediaSession/{deviceId}/sessions/{sessionId}/playbackPosition
mediaSession/{deviceId}/sessions/{sessionId}/mediaTitle
mediaSession/{deviceId}/sessions/{sessionId}/mediaDuration
mediaSession/{deviceId}/sessions/{sessionId}/mediaArtwork

sessionId could be assigned when a new MediaSession.Token is detected and remain stable while that session exists. This also supports multiple sessions created by the same application.

An additional retained topic could list active sessions:

mediaSession/{deviceId}/sessions/active

When a session disappears, its retained topics should be removed. The existing Home Assistant entities could remain unchanged.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions