Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a media session sensor #1499

Merged
merged 7 commits into from
Apr 17, 2021

Conversation

dshokouhi
Copy link
Member

@dshokouhi dshokouhi commented Apr 10, 2021

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

image

Link to pull request in Documentation repository

Documentation: home-assistant/companion.home-assistant#492

Any other notes

@JBassett
Copy link
Collaborator

Just need to fix merge conflicts.

@JBassett JBassett merged commit 5048240 into home-assistant:master Apr 17, 2021
@dshokouhi dshokouhi deleted the media_session_sensor branch May 20, 2021 16:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Media sensors
3 participants