From b48dcca05d304c58305877b05bb84c0a8063463a Mon Sep 17 00:00:00 2001 From: jjlawren Date: Mon, 6 Apr 2020 18:18:13 -0500 Subject: [PATCH] Defer Plex sensor retry instead of aborting (#33753) --- homeassistant/components/plex/sensor.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/homeassistant/components/plex/sensor.py b/homeassistant/components/plex/sensor.py index 65c2fab3614..21e8e1a8a58 100644 --- a/homeassistant/components/plex/sensor.py +++ b/homeassistant/components/plex/sensor.py @@ -54,6 +54,7 @@ class PlexSensor(Entity): _LOGGER.debug("Refreshing sensor [%s]", self.unique_id) self.sessions = sessions + update_failed = False @callback def update_plex(_): @@ -71,8 +72,8 @@ class PlexSensor(Entity): _LOGGER.debug( "Session temporarily incomplete, will try again: %s", sess ) - async_call_later(self.hass, 5, update_plex) - return + update_failed = True + continue user = sess.usernames[0] device = sess.players[0].title now_playing_user = f"{user} - {device}" @@ -111,6 +112,9 @@ class PlexSensor(Entity): self.async_write_ha_state() + if update_failed: + async_call_later(self.hass, 5, update_plex) + @property def name(self): """Return the name of the sensor."""