Improve Plex media_player entity naming (#31755)

This commit is contained in:
jjlawren 2020-02-12 11:55:18 -06:00 committed by GitHub
parent 8498ca37cd
commit 1b2f4fa19f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 53 additions and 13 deletions

View file

@ -51,6 +51,7 @@ class PlexServer:
self._verify_ssl = server_config.get(CONF_VERIFY_SSL, DEFAULT_VERIFY_SSL)
self.options = options
self.server_choice = None
self._owner_username = None
# Header conditionally added as it is not available in config entry v1
if CONF_CLIENT_IDENTIFIER in server_config:
@ -93,6 +94,14 @@ class PlexServer:
else:
_connect_with_token()
owner_account = [
account.name
for account in self._plex_server.systemAccounts()
if account.accountID == 1
]
if owner_account:
self._owner_username = owner_account[0]
def refresh_entity(self, machine_identifier, device, session):
"""Forward refresh dispatch to media_player."""
unique_id = f"{self.machine_identifier}:{machine_identifier}"
@ -182,6 +191,11 @@ class PlexServer:
"""Return the plexapi PlexServer instance."""
return self._plex_server
@property
def owner(self):
"""Return the Plex server owner username."""
return self._owner_username
@property
def friendly_name(self):
"""Return name of connected Plex server."""