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.
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:
They would continue to represent the currently selected session.
Each active session could additionally be published under:
sessionIdcould be assigned when a newMediaSession.Tokenis 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:
When a session disappears, its retained topics should be removed. The existing Home Assistant entities could remain unchanged.