custom-components / sensor.radarr_upcoming_media

🎬 Radarr component to feed Upcoming Media Card.
Apache License 2.0
58 stars 24 forks source link

Error in 2021.12.7 and later #20

Closed DavidFW1960 closed 5 months ago

DavidFW1960 commented 2 years ago

Describe the Bug Radarr_upcoming_media sensor not loading

The Error

2022-01-05 18:34:40 ERROR (MainThread) [homeassistant.components.sensor] Error adding entities for domain sensor with platform radarr_upcoming_media
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 382, in async_add_entities
    await asyncio.gather(*tasks)
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 613, in _async_add_entity
    await entity.add_to_platform_finish()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 748, in add_to_platform_finish
    self.async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 505, in async_write_ha_state
    self._async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 541, in _async_write_ha_state
    extra_state_attributes = self.extra_state_attributes
  File "/config/custom_components/radarr_upcoming_media/sensor.py", line 113, in extra_state_attributes
    if 'ratings' in movie and movie['ratings']['value'] > 0:
KeyError: 'value'
2022-01-05 18:34:40 ERROR (MainThread) [homeassistant.components.sensor] Error while setting up radarr_upcoming_media platform for sensor
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 257, in _async_setup_platform
    await asyncio.gather(*pending)
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 382, in async_add_entities
    await asyncio.gather(*tasks)
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 613, in _async_add_entity
    await entity.add_to_platform_finish()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 748, in add_to_platform_finish
    self.async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 505, in async_write_ha_state
    self._async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 541, in _async_write_ha_state
    extra_state_attributes = self.extra_state_attributes
  File "/config/custom_components/radarr_upcoming_media/sensor.py", line 113, in extra_state_attributes
    if 'ratings' in movie and movie['ratings']['value'] > 0:
KeyError: 'value'

Indicate if you followed all steps in the troubleshooting doc Well, did you? Yes

What data does the sensor display if any? Feel free to censor information pertaining to titles, networks, etc.

What displays when visiting the API URL from the troubleshooting guide? Feel free to censor information pertaining to titles, networks, etc. I get valid data from the API (v3 of API) Does the default Home Assistant Radarr component work for you? This is important to know, helps rule out issues with your Radarr installation. It doesn't the current core API is broken as it uses the older API etc. A PR to fix it for APIv3 is pending merge and I have a dev version of it that is working correctly Home Assistant Version What version of HA are you running? 2021.12.8 Additional Context Add any other context about the problem here. this only broke in the .7 release I think it was fine before that. Sonarr is working fine and seems to have similar code?

KerbeRoss-HA commented 2 years ago

Seem to be suffering with the same issue with Radarr, Sonarr works fine also. When testing radarrs calendar API, it only works via the v3

ip:port/api/v3/calendar?apikey=[APIKeyRemoved]&start=2022-01-07&end=2022-06-07

Also Running HA 2021.12.8

XxInvictus commented 2 years ago

The error is because in the below commit Radarr implemented more rating options meanwhile before it was just TVDB, I have fixed mine locally by changing the lines of /config/custom_components/radarr_upcoming_media/sensor.py below From This (start Line 113): if 'ratings' in movie and movie['ratings']['value'] > 0: card_item['rating'] = ('\N{BLACK STAR} ' + str(movie['ratings']['value'])) else: To This: if 'ratings' in movie and movie['ratings']['rottenTomatoes']['value'] > 0: card_item['rating'] = ('\N{BLACK STAR} ' + str(movie['ratings']['rottenTomatoes']['value'])) else: I personally chose Rotten Tomatoes ratings as they tend to be more "true" but the below are the current options

Relevant Radarr Commit - https://github.com/Radarr/Radarr/commit/599f4907f46f0751fc32fe50dfff951bda294813

ToXinE commented 2 years ago

same here running HA 2021.12.10 sonarr is working fine but radarr don't.


2022-01-31 22:41:11 ERROR (MainThread) [homeassistant.components.sensor] Error adding entities for domain sensor with platform radarr_upcoming_media
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 382, in async_add_entities
    await asyncio.gather(*tasks)
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 613, in _async_add_entity
    await entity.add_to_platform_finish()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 748, in add_to_platform_finish
    self.async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 505, in async_write_ha_state
    self._async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 541, in _async_write_ha_state
    extra_state_attributes = self.extra_state_attributes
  File "/config/custom_components/radarr_upcoming_media/sensor.py", line 113, in extra_state_attributes
    if 'ratings' in movie and movie['ratings']['value'] > 0:
KeyError: 'value'
DavidFW1960 commented 2 years ago

sonarr is working fine but radarr don't.

The solution is manually editing the sensor.py file as shown in the post directly above yours

CDRX2 commented 2 years ago

Had the same issue, I can confirm editing the code as described above works, thank you!

mkanet commented 5 months ago

I recently added this to the regular release of this integration.