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.
Summary
Fixes: #1475
So this is an interesting sensor because the media sessions require either a system only permission, which we won't qualify for, or the notification listener (aka notification manager). This listener is required for getting the data so this sensor is like a notification sensor but only for media sessions.
For the state I had a few considerations. First keeping the state as the total count of sessions won't work because when the user has 1 session (primary) none of the attributes will update. Keeping the state as just the playback state of the primary controller wont update the attributes often either especially when playing for a long period of time. Things like artist and title won't change so almost whats the point in including them. We will first attempt to set the state as the title of the media when it is actively playing. Otherwise, the state will be the playback state or unavailable if we have no active sessions. I figure the more updates we get in the better for users.
Attributes will include data from all active media sessions including a total count of active media sessions. The attributes will have the package name appended.
Screenshots
Link to pull request in Documentation repository
Documentation: home-assistant/companion.home-assistant#492
Any other notes