More graceful exception handling in Plex library sensors (#52969)
This commit is contained in:
parent
ff56ede960
commit
f39f087b10
2 changed files with 39 additions and 0 deletions
|
@ -2,6 +2,7 @@
|
|||
import logging
|
||||
|
||||
from plexapi.exceptions import NotFound
|
||||
import requests.exceptions
|
||||
|
||||
from homeassistant.components.sensor import SensorEntity
|
||||
from homeassistant.helpers.debounce import Debouncer
|
||||
|
@ -148,6 +149,13 @@ class PlexLibrarySectionSensor(SensorEntity):
|
|||
self._attr_available = True
|
||||
except NotFound:
|
||||
self._attr_available = False
|
||||
except requests.exceptions.RequestException as err:
|
||||
_LOGGER.error(
|
||||
"Could not update library sensor for '%s': %s",
|
||||
self.library_section.title,
|
||||
err,
|
||||
)
|
||||
self._attr_available = False
|
||||
self.async_write_ha_state()
|
||||
|
||||
def _update_state_and_attrs(self):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue