Change state() to try/except to catch KeyError (#19935)

* Change state() to try/except to catch KeyError

When Tautulli is up but Plex is down, the API doesn't return a 'stream_count' key. This causes calls to state() to raise KeyError exceptions. The new code includes a try/except to catch the KeyError and return -1 signifying that the Tautulli API cannot talk to Plex

* Update tautulli.py
This commit is contained in:
Tyler Page 2019-01-11 07:48:36 +00:00 committed by Daniel Høyer Iversen
parent 31d92683f7
commit c3e9bd1444

View File

@ -119,7 +119,7 @@ class TautulliSensor(Entity):
@property
def state(self):
"""Return the state of the sensor."""
return self.sessions['stream_count']
return self.sessions.get('stream_count')
@property
def icon(self):