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:
1 parent
31d92683f7
commit
c3e9bd1444
1 file changed
+1
-1
@@ -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):
|
||||
|
||||
Reference in new issue
Block a user