Fix Plex when using local tokenless authentication (#37096)

This commit is contained in:
jjlawren authored and GitHub committed 2020-06-25 17:10:40 -07:00
1 parent f42eb0d5ca
commit fd1a8dd96c
7 files changed
+157 -84

No files matched your search

+14 -6
View File
@@ -161,12 +161,20 @@ async def async_setup_entry(hass, entry):
}
)
hass.services.async_register(
PLEX_DOMAIN,
SERVICE_PLAY_ON_SONOS,
async_play_on_sonos_service,
schema=play_on_sonos_schema,
)
def get_plex_account(plex_server):
try:
return plex_server.account
except plexapi.exceptions.Unauthorized:
return None
plex_account = await hass.async_add_executor_job(get_plex_account, plex_server)
if plex_account:
hass.services.async_register(
PLEX_DOMAIN,
SERVICE_PLAY_ON_SONOS,
async_play_on_sonos_service,
schema=play_on_sonos_schema,
)
return True