From 60318012061700cdc886f2ddc1b243e196463806 Mon Sep 17 00:00:00 2001 From: psike Date: Mon, 6 Aug 2018 13:18:36 +0300 Subject: [PATCH] Fix error when Series missing 'episodeFileCount' or 'episodeCount' (#15824) * Fix error when Series missing 'episodeFileCount' or 'episodeCount' * Update sonarr.py * Update sonarr.py --- homeassistant/components/sensor/sonarr.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/homeassistant/components/sensor/sonarr.py b/homeassistant/components/sensor/sonarr.py index 090addb5b6e..c2fd6c80663 100644 --- a/homeassistant/components/sensor/sonarr.py +++ b/homeassistant/components/sensor/sonarr.py @@ -158,8 +158,12 @@ class SonarrSensor(Entity): ) 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