Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Radarr sensor issue #8250

Closed
hoopty opened this issue Jun 29, 2017 · 2 comments · Fixed by #8456
Closed

Radarr sensor issue #8250

hoopty opened this issue Jun 29, 2017 · 2 comments · Fixed by #8456

Comments

@hoopty
Copy link
Contributor

hoopty commented Jun 29, 2017

Home Assistant release (hass --version):
0.47.1

Python release (python3 --version):
3.6.1

Component/platform:
sensor.radarr

Description of problem:
Errors are logged and the upcoming monitored condition sensor entity never shows up.

Expected:
No errors logged and the entity exists (and is populated)

Problem-relevant configuration.yaml entries and steps to reproduce:

- platform: radarr
  api_key: !secret radarr_api_key
  host: media.local
  urlbase: /movies
  monitored_conditions:
    - upcoming
    - commands
    - status
  1. restart hass

Traceback (if applicable):

2017-06-29 13:44:14 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/asyncio/tasks.py", line 179, in _step
    result = coro.send(None)
  File "/home/hass/hass/lib/python3.6/site-packages/homeassistant/helpers/entity_component.py", line 368, in async_process_entity
    new_entity, self, update_before_add=update_before_add
  File "/home/hass/hass/lib/python3.6/site-packages/homeassistant/helpers/entity_component.py", line 225, in async_add_entity
    yield from entity.async_update_ha_state()
  File "/home/hass/hass/lib/python3.6/site-packages/homeassistant/helpers/entity.py", line 246, in async_update_ha_state
    device_attr = self.device_state_attributes
  File "/home/hass/hass/lib/python3.6/site-packages/homeassistant/components/sensor/radarr.py", line 181, in device_state_attributes
    attributes[to_key(movie)] = get_release_date(movie)
  File "/home/hass/hass/lib/python3.6/site-packages/homeassistant/components/sensor/radarr.py", line 219, in get_release_date
    date = data['physicalRelease']
KeyError: 'physicalRelease'

Additional info:

@hoopty
Copy link
Contributor Author

hoopty commented Jul 12, 2017

@tboyce021, I found the issue and propose a tweak to https://github.com/home-assistant/home-assistant/blob/dev/homeassistant/components/sensor/radarr.py#L217

I'll submit a PR, but wanted to post it up here first as it addresses the issue.

def get_release_date(data):
    """Get release date."""
    if 'physicalRelease' in data:
        date = data['physicalRelease']
    else:
        date = data['inCinemas']
    return date

@tboyce021
Copy link
Contributor

tboyce021 commented Jul 12, 2017

Could inCinemas be missing too? If so, maybe using get() could help (assuming data is actually a dictonary):

def get_release_date(data):
    """Get release date."""
    date = data.get('physicalRelease')
    if not date:
        date = data.get('inCinemas')
    return date

Or an even shorter version if you're sure physicalRelease can't be present and set to None:

def get_release_date(data):
    """Get release date."""
    return data.get('physicalRelease', data.get('inCinemas'))

Then just be sure that having a None value for the attribute doesn't cause any issues if inCinemas is also missing.

hoopty added a commit to hoopty/home-assistant that referenced this issue Jul 12, 2017
hoopty added a commit to hoopty/home-assistant that referenced this issue Jul 12, 2017
balloob pushed a commit that referenced this issue Jul 14, 2017
* Radarr sensor fix for issue #8250

* Radarr sensor fix for issue #8250
balloob pushed a commit that referenced this issue Jul 16, 2017
* Radarr sensor fix for issue #8250

* Radarr sensor fix for issue #8250
dethpickle pushed a commit to dethpickle/home-assistant that referenced this issue Aug 18, 2017
@home-assistant home-assistant locked and limited conversation to collaborators Oct 20, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants