custom-components / sensor.radarr_upcoming_media

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

Error with version 4 #33

Closed w1tw0lf closed 4 months ago

w1tw0lf commented 4 months ago

Describe the Bug Updated to version 4 and want to add via integrations, just says error has occured.

The Error Logger: aiohttp.server Source: /usr/local/lib/python3.12/site-packages/aiohttp/web_protocol.py:421 First occurred: 07:08:44 (8 occurrences) Last logged: 07:41:48

Error handling request Traceback (most recent call last): File "/usr/local/lib/python3.12/site-packages/requests/models.py", line 971, in json return complexjson.loads(self.text, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/simplejson/init.py", line 514, in loads return _default_decoder.decode(s) ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/simplejson/decoder.py", line 386, in decode obj, end = self.raw_decode(s) ^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/simplejson/decoder.py", line 416, in raw_decode return self.scan_once(s, idx=_w(s, idx).end()) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ simplejson.errors.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/usr/local/lib/python3.12/site-packages/aiohttp/web_protocol.py", line 452, in _handle_request resp = await request_handler(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/aiohttp/web_app.py", line 543, in _handle resp = await handler(request) ^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/aiohttp/web_middlewares.py", line 114, in impl return await handler(request) ^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/components/http/security_filter.py", line 92, in security_filter_middleware return await handler(request) ^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/components/http/forwarded.py", line 210, in forwarded_middleware return await handler(request) ^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/components/http/request_context.py", line 26, in request_context_middleware return await handler(request) ^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/components/http/ban.py", line 88, in ban_middleware return await handler(request) ^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/components/http/auth.py", line 236, in auth_middleware return await handler(request) ^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/components/http/headers.py", line 32, in headers_middleware response = await handler(request) ^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/helpers/http.py", line 73, in handle result = await handler(request, request.match_info) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/components/http/decorators.py", line 71, in with_admin return await func(self, request, *args, *kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/components/config/config_entries.py", line 222, in post return await super().post(request, flow_id) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/components/http/data_validator.py", line 73, in wrapper result = await method(view, request, data, args, kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/helpers/data_entry_flow.py", line 122, in post result = await self._flow_mgr.async_configure(flow_id, data) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 356, in async_configure result = await self._async_configure(flow_id, user_input) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 402, in _async_configure result = await self._async_handle_step( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 506, in _async_handle_step result: _FlowResultT = await getattr(flow, method)(user_input) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/radarr_upcoming_media/config_flow.py", line 49, in async_step_user await self.hass.async_add_executor_job( File "/usr/local/lib/python3.12/concurrent/futures/thread.py", line 58, in run result = self.fn(*self.args, **self.kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/radarr_upcoming_media/helpers.py", line 17, in setup_client client.update() File "/config/custom_components/radarr_upcoming_media/radarr_api.py", line 76, in update 'data': parse_data(api.json()[:self._max], tz, self._host, self._port, self._ssl, self._theaters) ^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/requests/models.py", line 975, in json raise RequestsJSONDecodeError(e.msg, e.doc, e.pos) requests.exceptions.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

Indicate if you followed all steps in the troubleshooting doc yes

What data does the sensor display if any? none

What displays when visiting the API URL from the troubleshooting guide? Works perfectly, just need to correct url in guide.

http(s)://[IP]:[port]/api/calendar?apikey=[API_key]&start=[start_date]&end=[end_date] to http(s)://[IP]:[port]/api/v3/calendar?apikey=[API_key]&start=[start_date]&end=[end_date]

Does the default Home Assistant Radarr component work for you? Previous version 0.3.9 worked without issues

Home Assistant Version 2024.4.4

Additional Context Add any other context about the problem here.

mkanet commented 4 months ago

Hi @w1tw0lf that error seems to suggest you're not getting any json data from your Radarr installation. Could you tell me what you specified for each field in the below Integration settings? image

Maybe @Makhuta can chime in here. He might know better what's going on since he completely reworked this Integration (4.0.0 release) to support installing it directly from Home Assistant's GUI . In any case, you should be able to use the same settings you had previously in configuration.yaml without any issues.

If you haven't tried already, try completely removing this integration, then reboot Home Assistant. Then, try to install it again. Maybe there's something stuck/lingering from the previous version?

PS: Also,, if you installed this Integration via HACS (by manually adding the repo URL to HACS), you will need to click "SHOW" when you see the message below: image

Then, click "IGNORE": image

w1tw0lf commented 4 months ago

Thank you for the detailed feedback.

The settings was the same in configuration.yaml and worked 100s without any issues.

Radarr not running on home assistant, but on separate server.

Going to the api url gives the json data without any issues.

Wil remove the integration and try again. Will keep you posted.

Makhuta commented 4 months ago

Good to know that there is issue like that, meaning if the URL is wrong or the Radarr return non json response the parser will fail, I need to make fix this to show better info in log. BTW I am glad that you figured what the issue was on your part

w1tw0lf commented 4 months ago

No luck....

as per @mkanet, I removed the integration, rebooted, added back and rebooted again. Same error still.

Double check that the the ip and api key and it is correct.

going to http(s)://[IP]:[port]/api/v3/calendar?apikey=[API_key]&start=[start_date]&end=[end_date] gives the json as well.

@Makhuta didn't solve it as the issue is still there.

Makhuta commented 4 months ago

If you would be willing to share the screen of adding the instance (you can censor sensitive data like key ect.) so it will be easier to help you

w1tw0lf commented 4 months ago

here is the screenshot

image

w1tw0lf commented 4 months ago

here is the api url as well

image

Makhuta commented 4 months ago

Ok @w1tw0lf, I found the problem, it was in missplaced bracket which resulted in url be like this: http(s)://[IP]:[port]//api/v3/calendar?apikey=[API_key]&start=[start_date]&end=[end_date]

The reason I missed it is that I personally run 2 instances of Radarr with different URL base for each one (so for me it is defined) and I forgot to test it without it (the Sonarr is fine, tested the same issue and for it it is ok)

full merge can be found here

w1tw0lf commented 4 months ago

Awesome! Thank you @Makhuta.

mkanet commented 4 months ago

Guys, I just merged the fix to the repo. @w1tw0lf let us know if this worked for you. Thanks @Makhuta for the quick fix!

Makhuta commented 4 months ago

Happy to help

w1tw0lf commented 4 months ago

All sorted. Redownloaded and worked first time.