Skip to content

Commit

Permalink
Fix error when Series missing 'episodeFileCount' or 'episodeCount' (#…
Browse files Browse the repository at this point in the history
…15824)

* Fix error when Series missing 'episodeFileCount' or 'episodeCount'

* Update sonarr.py

* Update sonarr.py
  • Loading branch information
psike authored and balloob committed Aug 6, 2018
1 parent 9cfe0db commit 6031801
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions homeassistant/components/sensor/sonarr.py
Expand Up @@ -158,8 +158,12 @@ 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
Expand Down

0 comments on commit 6031801

Please sign in to comment.