From d8b9bee7fb0d8cb811e3d4d0044161804e248a85 Mon Sep 17 00:00:00 2001 From: ludeeus Date: Sat, 1 Dec 2018 13:02:15 +0100 Subject: [PATCH 1/4] Fix IndexError for home stats --- homeassistant/components/sensor/tautulli.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/homeassistant/components/sensor/tautulli.py b/homeassistant/components/sensor/tautulli.py index 7b0d8e491d2..419ef6a11a1 100644 --- a/homeassistant/components/sensor/tautulli.py +++ b/homeassistant/components/sensor/tautulli.py @@ -19,7 +19,7 @@ import homeassistant.helpers.config_validation as cv from homeassistant.helpers.entity import Entity from homeassistant.util import Throttle -REQUIREMENTS = ['pytautulli==0.4.0'] +REQUIREMENTS = ['pytautulli==0.4.1'] _LOGGER = logging.getLogger(__name__) @@ -90,9 +90,9 @@ class TautulliSensor(Entity): await self.tautulli.async_update() self.home = self.tautulli.api.home_data self.sessions = self.tautulli.api.session_data - self._attributes['Top Movie'] = self.home[0]['rows'][0]['title'] - self._attributes['Top TV Show'] = self.home[3]['rows'][0]['title'] - self._attributes['Top User'] = self.home[7]['rows'][0]['user'] + self._attributes['Top Movie'] = self.home['movie'] + self._attributes['Top TV Show'] = self.home['tv'] + self._attributes['Top User'] = self.home['user'] for key in self.sessions: if 'sessions' not in key: self._attributes[key] = self.sessions[key] From 89bd6fa4949a38ffc7cd9e4ddbe9e96af9fd840d Mon Sep 17 00:00:00 2001 From: ludeeus Date: Sat, 1 Dec 2018 13:07:32 +0100 Subject: [PATCH 2/4] Fix requirements_all --- requirements_all.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements_all.txt b/requirements_all.txt index 40cc0d39c43..0a4f41a09e0 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -1158,7 +1158,7 @@ pystride==0.1.7 pysyncthru==0.3.1 # homeassistant.components.sensor.tautulli -pytautulli==0.4.0 +pytautulli==0.4.1 # homeassistant.components.media_player.liveboxplaytv pyteleloisirs==3.4 From da715c2a0396d8e479be89ce4e53db561dc5f485 Mon Sep 17 00:00:00 2001 From: ludeeus Date: Sat, 1 Dec 2018 21:32:31 +0100 Subject: [PATCH 3/4] Use dict.get('key') instead of dict['key'] --- homeassistant/components/sensor/tautulli.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/homeassistant/components/sensor/tautulli.py b/homeassistant/components/sensor/tautulli.py index 419ef6a11a1..29c11c934f9 100644 --- a/homeassistant/components/sensor/tautulli.py +++ b/homeassistant/components/sensor/tautulli.py @@ -90,9 +90,9 @@ class TautulliSensor(Entity): await self.tautulli.async_update() self.home = self.tautulli.api.home_data self.sessions = self.tautulli.api.session_data - self._attributes['Top Movie'] = self.home['movie'] - self._attributes['Top TV Show'] = self.home['tv'] - self._attributes['Top User'] = self.home['user'] + self._attributes['Top Movie'] = self.home.get('movie') + self._attributes['Top TV Show'] = self.home,get('tv') + self._attributes['Top User'] = self.home.get('user') for key in self.sessions: if 'sessions' not in key: self._attributes[key] = self.sessions[key] From 1dac84e9dd9dd02b6b69708a3f305fbf0eff8334 Mon Sep 17 00:00:00 2001 From: ludeeus Date: Sat, 1 Dec 2018 21:34:31 +0100 Subject: [PATCH 4/4] corrects , -> . typo --- homeassistant/components/sensor/tautulli.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/homeassistant/components/sensor/tautulli.py b/homeassistant/components/sensor/tautulli.py index 29c11c934f9..f47f0e5c382 100644 --- a/homeassistant/components/sensor/tautulli.py +++ b/homeassistant/components/sensor/tautulli.py @@ -91,7 +91,7 @@ class TautulliSensor(Entity): self.home = self.tautulli.api.home_data self.sessions = self.tautulli.api.session_data self._attributes['Top Movie'] = self.home.get('movie') - self._attributes['Top TV Show'] = self.home,get('tv') + self._attributes['Top TV Show'] = self.home.get('tv') self._attributes['Top User'] = self.home.get('user') for key in self.sessions: if 'sessions' not in key: