mirror of
https://github.com/home-assistant/core.git
synced 2025-07-21 04:07:08 +00:00
Defer Plex sensor retry instead of aborting (#33753)
This commit is contained in:
parent
648b340e8c
commit
b48dcca05d
@ -54,6 +54,7 @@ class PlexSensor(Entity):
|
|||||||
_LOGGER.debug("Refreshing sensor [%s]", self.unique_id)
|
_LOGGER.debug("Refreshing sensor [%s]", self.unique_id)
|
||||||
|
|
||||||
self.sessions = sessions
|
self.sessions = sessions
|
||||||
|
update_failed = False
|
||||||
|
|
||||||
@callback
|
@callback
|
||||||
def update_plex(_):
|
def update_plex(_):
|
||||||
@ -71,8 +72,8 @@ class PlexSensor(Entity):
|
|||||||
_LOGGER.debug(
|
_LOGGER.debug(
|
||||||
"Session temporarily incomplete, will try again: %s", sess
|
"Session temporarily incomplete, will try again: %s", sess
|
||||||
)
|
)
|
||||||
async_call_later(self.hass, 5, update_plex)
|
update_failed = True
|
||||||
return
|
continue
|
||||||
user = sess.usernames[0]
|
user = sess.usernames[0]
|
||||||
device = sess.players[0].title
|
device = sess.players[0].title
|
||||||
now_playing_user = f"{user} - {device}"
|
now_playing_user = f"{user} - {device}"
|
||||||
@ -111,6 +112,9 @@ class PlexSensor(Entity):
|
|||||||
|
|
||||||
self.async_write_ha_state()
|
self.async_write_ha_state()
|
||||||
|
|
||||||
|
if update_failed:
|
||||||
|
async_call_later(self.hass, 5, update_plex)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def name(self):
|
def name(self):
|
||||||
"""Return the name of the sensor."""
|
"""Return the name of the sensor."""
|
||||||
|
Loading…
x
Reference in New Issue
Block a user