From 31f77aea610a05abb9353669d3436d21c4b838a2 Mon Sep 17 00:00:00 2001 From: psike Date: Fri, 3 Aug 2018 23:36:16 +0300 Subject: [PATCH 1/3] Fix error when Series missing 'episodeFileCount' or 'episodeCount' --- homeassistant/components/sensor/sonarr.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/homeassistant/components/sensor/sonarr.py b/homeassistant/components/sensor/sonarr.py index 090addb5b6ee5..e200e9f5cc0a8 100644 --- a/homeassistant/components/sensor/sonarr.py +++ b/homeassistant/components/sensor/sonarr.py @@ -158,8 +158,11 @@ def device_state_attributes(self): ) elif self.type == 'series': for show in self.data: - attributes[show['title']] = '{}/{} Episodes'.format( - show['episodeFileCount'], show['episodeCount']) + if 'episodeFileCount' not in show or 'episodeCount' not in show: + attributes[show['title']] = 'N/A' + else: + attributes[show['title']] = '{}/{} Episodes'.format( + show['episodeFileCount'], show['episodeCount']) elif self.type == 'status': attributes = self.data return attributes From 6a71f0866e03ada76e1e91beaf4dd3e83b44ed65 Mon Sep 17 00:00:00 2001 From: psike Date: Sat, 4 Aug 2018 21:30:45 +0300 Subject: [PATCH 2/3] Update sonarr.py --- homeassistant/components/sensor/sonarr.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/homeassistant/components/sensor/sonarr.py b/homeassistant/components/sensor/sonarr.py index e200e9f5cc0a8..021d34d58ee14 100644 --- a/homeassistant/components/sensor/sonarr.py +++ b/homeassistant/components/sensor/sonarr.py @@ -158,7 +158,8 @@ def device_state_attributes(self): ) elif self.type == 'series': for show in self.data: - if 'episodeFileCount' not in show or 'episodeCount' not in show: + if 'episodeFileCount' not in show + or 'episodeCount' not in show: attributes[show['title']] = 'N/A' else: attributes[show['title']] = '{}/{} Episodes'.format( From 32dd2bb92565a4e8be0ce65e0ef49923a58dd49b Mon Sep 17 00:00:00 2001 From: psike Date: Sat, 4 Aug 2018 21:36:53 +0300 Subject: [PATCH 3/3] Update sonarr.py --- homeassistant/components/sensor/sonarr.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/homeassistant/components/sensor/sonarr.py b/homeassistant/components/sensor/sonarr.py index 021d34d58ee14..c2fd6c8066330 100644 --- a/homeassistant/components/sensor/sonarr.py +++ b/homeassistant/components/sensor/sonarr.py @@ -158,8 +158,8 @@ def device_state_attributes(self): ) elif self.type == 'series': for show in self.data: - if 'episodeFileCount' not in show - or 'episodeCount' not in show: + if 'episodeFileCount' not in show \ + or 'episodeCount' not in show: attributes[show['title']] = 'N/A' else: attributes[show['title']] = '{}/{} Episodes'.format(