custom-components / sensor.radarr_upcoming_media

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

Not receiving any data #12

Closed TheFes closed 4 years ago

TheFes commented 4 years ago

The component seems to be working, but I do not receive any data, while there are upcoming movies.

Seems to be the same as described here: https://github.com/custom-cards/upcoming-media-card/issues/20

configuration.yaml

sensor:
  - platform: radarr_upcoming_media
    api_key: !secret radarr_api
    host: 192.168.2.2
    port: 7878
    theaters: false
    days: 300
    max: 10

Indicate if you followed all steps in the troubleshooting doc Sure

What data does the sensor display if any? Status: online Attributes: data: [{"title_default": "$title", "line1_default": "$release", "line2_default": "$genres", "line3_default": "$rating - $runtime", "line4_default": "$studio", "icon": "mdi:arrow-down-bold"}] friendly_name: Radarr_Upcoming_Media

What displays when visiting the API URL from the troubleshooting guide? [ { "title": "Artemis Fowl", "alternativeTitles": [], "secondaryYearSourceId": 0, "sortTitle": "artemis fowl", "sizeOnDisk": 0, "status": "announced", "overview": "With the help of his loyal protector Butler, 12-year-old genius Artemis Fowl, descendant of a long line of criminal masterminds, seeks to find his mysteriously disappeared father, and in doing so, uncovers an ancient, underground civilization—the amazingly advanced world of fairies. Deducing that his father’s disappearance is somehow connected to the secretive, reclusive fairy world, cunning Artemis concocts a dangerous plan—so dangerous that he ultimately finds himself in a perilous war of wits with the all-powerful fairies.", "inCinemas": "2020-06-11T22:00:00Z", "physicalRelease": "2020-06-12T00:00:00Z", "images": [ { "coverType": "poster", "url": "/radarr/MediaCover/887/poster.jpg" }, { "coverType": "fanart", "url": "/radarr/MediaCover/887/fanart.jpg" } ], "website": "", "downloaded": false, "year": 2020, "hasFile": false, "youTubeTrailerId": "wXlBep9uFjI", "studio": "Tribeca Productions", "path": "E:\\Movies\\Artemis Fowl (2020)", "profileId": 6, "pathState": "static", "monitored": true, "minimumAvailability": "released", "isAvailable": false, "folderName": "E:\\Movies\\Artemis Fowl (2020)", "runtime": 0, "lastInfoSync": "2020-05-15T00:57:07.3343431Z", "cleanTitle": "artemisfowl", "imdbId": "tt3089630", "tmdbId": 475430, "titleSlug": "artemis-fowl-475430", "genres": [], "tags": [], "added": "2020-05-13T13:20:55.8897037Z", "ratings": { "votes": 0, "value": 0.0 }, "qualityProfileId": 6, "id": 887 } ]

Does the default Home Assistant Radarr component work for you? Yes, works fine. As a state I get a full list of all my movies.

Home Assistant Version HassOS 3.13

TheFes commented 4 years ago

Additional information from debug log:

2020-05-15 17:01:47 WARNING (MainThread) [homeassistant.loader] You are using a custom integration for radarr_upcoming_media which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant.
2020-05-15 17:01:49 INFO (MainThread) [homeassistant.components.sensor] Setting up sensor.radarr_upcoming_media
2020-05-15 17:01:51 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event state_changed[L]: entity_id=sensor.radarr_upcoming_media, old_state=None, new_state=<state sensor.radarr_upcoming_media=Online; data=[{"title_default": "$title", "line1_default": "$release", "line2_default": "$genres", "line3_default": "$rating - $runtime", "line4_default": "$studio", "icon": "mdi:arrow-down-bold"}], friendly_name=Radarr_Upcoming_Media @ 2020-05-15T17:01:51.490210+02:00>>
2020-05-15 17:02:00 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event hacs/repository[L]: id=1337, action=registration, repository=custom-components/sensor.radarr_upcoming_media, repository_id=None>
2020-05-15 17:02:26 DEBUG (SyncWorker_1) [homeassistant.util.json] JSON file not found: /config/custom_components/radarr_upcoming_media/translations/sensor.nl.json
2020-05-15 17:02:26 DEBUG (SyncWorker_9) [homeassistant.util.json] JSON file not found: /config/custom_components/radarr_upcoming_media/translations/sensor.en.json

And some other items, but they are all in a wall of text with other sensors. I get the same JSON related entries for the sonarr upcoming sensor, which is working.

Changes condition of HA Radarr component to upcoming with 40 days, and then I get this result:

Artemis Fowl (2020): 2020-06-12T00:00:00Z
unit_of_measurement: Movies
friendly_name: Radarr Upcoming
icon: mdi:television

So the connection with Radarr is okay, API is working. But sensor.radarr_upcoming_media is not getting any data.

maykar commented 4 years ago

Few things to try:

Remove theaters: false from your config. Artemis Fowl is a strange one it seems, it's physical release is only one day after it's theater release. I may have to adjust some things for cases like this in the future. With cinemas closed due to the pandemic, things like this have become more likely.

Add urlbase: '/radarr' to your config. The image results from your API show you are using a urlbase, but you haven't added that to your config. Usually this shouldn't be a problem as sonarr and radarr seem to ignore or automatically redirect with api requests, but I've seen it cause issues before on certain versions.

TheFes commented 4 years ago

Thanks for the reply.

If I remove theaters: false from my config, the sensor doesn't work anymore. It doesn't appear in "Develop tools" -> "State" anymore. When I add theaters: false again, and restart HA, the sensor is there, but only with the headers (also with the url base still added to the configuration).

It could be Artemis Fowl which is causing this, but I tried to add something which does become available in the coming period, but everything I tried just downloaded ;-)

maykar commented 4 years ago

Adding your baseurl didn't help either?

I added Artemis Fowl to test myself and it shows fine. When you remove theaters: false there should be an error in your HA logs if the sensor no longer works. At least that's what I'm hoping since it would provide a clue.

TheFes commented 4 years ago

I see the following in Developer tools > Log

Error while setting up radarr_upcoming_media platform for sensor 09:42:10 – Sensor (ERROR)

Log details (ERROR) Logger: homeassistant.components.sensor Source: custom_components/radarr_upcoming_media/sensor.py:120 Integration: Sensor (documentation, issues) First occurred: 09:42:10 (1 occurrences) Last logged: 09:42:10

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 186, in _async_setup_platform
    await asyncio.gather(*pending)
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 295, in async_add_entities
    await asyncio.gather(*tasks)
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 446, in _async_add_entity
    entity.async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 297, in async_write_ha_state
    self._async_write_ha_state()  # type: ignore
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 324, in _async_write_ha_state
    attr.update(self.device_state_attributes or {})
  File "/config/custom_components/radarr_upcoming_media/sensor.py", line 120, in device_state_attributes
    if '.jpg' in movie['images'][1]:
IndexError: list index out of range
maykar commented 4 years ago

Looks like you're using an older version of the component, released an upgrade to fix this error a few days ago. Can you try upgrading to the latest ( 0.3.2 )?

TheFes commented 4 years ago

Great, that seemed to be it! Thanks! It's working now

TheFes commented 4 years ago

Only thing: Artemis Fowl only shows with theaters: true. But I'll live with that :)

maykar commented 4 years ago

Yeah, I need to tweak things a bit now that physical releases can happen directly after theater releases. Currently I'm using some logic to keep the same movie from displaying twice, one right after the other, but I should disable that when theaters: false is set. I'll try to get that in the next release. Thanks!