dylandoamaral / trakt-integration

A Trakt integration for Home Assistant compatible with upcoming media card
MIT License
30 stars 12 forks source link

Failing to Initialise #67

Closed seanmccabe closed 1 year ago

seanmccabe commented 1 year ago

I installed this 2 days, got everything into the config and activated it, after about half hour got hit with the 500 errors.

Updated today and done a restart of HA, and I am getting nothing, appears the integration just will not load and there is nothing in the logs. I've left it for 2 hours and it appears to get nowhere.

I've just turned on debugging and now got the following log entries:

Unexpected error fetching trakt data: Can't request shows/107677/progress/watched with get because it returns a 500 status code with content . If you find this error, please raise an issue at https://github.com/dylandoamaral/trakt-integration/issues.
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 225, in _async_refresh
    self.data = await self._async_update_data()
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 181, in _async_update_data
    return await self.update_method()
  File "/config/custom_components/trakt_tv/apis/trakt.py", line 294, in retrieve_data
    data = await gather(
  File "/config/custom_components/trakt_tv/apis/trakt.py", line 241, in fetch_next_to_watch
    data = await gather(
  File "/config/custom_components/trakt_tv/apis/trakt.py", line 196, in fetch_upcoming
    raw_medias = await self.fetch_watched(excluded_shows)
  File "/config/custom_components/trakt_tv/apis/trakt.py", line 128, in fetch_watched
    raw_episode = await self.fetch_show_progress(ids["trakt"])
  File "/config/custom_components/trakt_tv/apis/trakt.py", line 146, in fetch_show_progress
    return await self.request("get", f"shows/{id}/progress/watched")
  File "/config/custom_components/trakt_tv/apis/trakt.py", line 80, in request
    raise TraktException(f"{error}\n{guidance}")
custom_components.trakt_tv.exception.TraktException: Can't request shows/107677/progress/watched with get because it returns a 500 status code with content .
If you find this error, please raise an issue at https://github.com/dylandoamaral/trakt-integration/issues.
Config entry 'Trakt' for trakt_tv integration not ready yet: Can't request shows/107677/progress/watched with get because it returns a 500 status code with content . If you find this error, please raise an issue at https://github.com/dylandoamaral/trakt-integration/issues.; Retrying in background

Any thoughts for resolving?

dylandoamaral commented 1 year ago

The issue with these errors (5XX one) is that we can't manage them ourselves. According to https://trakt.docs.apiary.io/#introduction/status-codes, when it is 500 error, it is a "Server Error" and you should "open a support ticket" somewhere 🤷‍♂️.

Thus it is maybe our fault but I can't figure out why without any information.

It seems that the trakt API is a bit flaky...

seanmccabe commented 1 year ago

I've posted here so hopefully get something done.

seanmccabe commented 1 year ago

This is my config:

language: en
timezone: Pacific/Auckland
sensors:
  upcoming:
    show:
      days_to_fetch: 7 # How many days in the future you want to fetch
      max_medias: 3 # How many medias you want to fetch
    new_show:
      days_to_fetch: 7
      max_medias: 3
    premiere:
      days_to_fetch: 7
      max_medias: 3
    movie:
      days_to_fetch: 7
      max_medias: 3
  next_to_watch:
    all:
      max_medias: 30
      #exclude:
      #  - veep
      #  - the-original
      #  - friends
    only_aired:
      max_medias: 7
      #exclude:
      #  - veep
      #  - the-original
      #  - friends
    only_upcoming:
      max_medias: 7

How long should I be expecting the Trakt integration to take in terms of starting up, because again it is taking quite some time.

dylandoamaral commented 1 year ago

Normally not that much max 10 minutes I would say. Try to remove next_to_watch sensors to see if something happen please.

seanmccabe commented 1 year ago

Normally not that much max 10 minutes I would say. Try to remove next_to_watch sensors to see if something happen please.

Will update in about 10 minutes. So far, its been taking hours and nothing, and then there is the occasional 500 error in the log.

seanmccabe commented 1 year ago

Now its just blank

image

I hit reload, says its reloaded, and nothing

seanmccabe commented 1 year ago

Ok seems like it is the next_to_watch piece that maybe broken?! Got the sensors etc now

dylandoamaral commented 1 year ago

Indeed, I should handle the error differently to ignore the sensors that can't be loaded.

seanmccabe commented 1 year ago

Indeed, I should handle the error differently to ignore the sensors that can't be loaded.

Yer that would be good. Be good to get an output log as well of which endpoints are getting 500 so they can be reported to Trakt

engeld commented 1 year ago

I do have the exact same issue here. Any way I can help troubleshooting the issue?

dylandoamaral commented 1 year ago

In 0.8.0 I implement a retry mechanism, I hope it will be enough. I close the PR for now, if the issue persist, feel free to open the issue again.