J-Lindvig / Bibliotek_dk

Custom integration for Home Assistant, scraping loaner status from public libraries in Denmark
GNU General Public License v3.0
9 stars 3 forks source link

Not working for Aalborg Bibliotek #12

Open chrjoedal opened 2 months ago

chrjoedal commented 2 months ago

Hi,

Aalborg blibliotek has got a new webpage. I seems like the integration cannot handle that.

It has been working for me for a long time, but then it suddenly threw errors all the time, and did not update sensors.

I removed it, and tried to re-add it, but could not, due to unexpected error. In the log, I see following erros:

1

This error originated from a custom integration.

Logger: custom_components.bibliotek_dk.library_api Source: custom_components/bibliotek_dk/library_api.py:139 integration: Bibliotek (documentation, issues) First occurred: May 29, 2024 at 18:01:29 (4 occurrences) Last logged: 20:21:33

HTTP Error while fetching https://www.aalborgbibliotekerne.dk/adgangsplatformen/login?destination=ding_frontpage: 404 Client Error: Not Found for url: https://www.aalborgbibliotekerne.dk/adgangsplatformen/login?destination=ding_frontpage

2

This error originated from a custom integration.

Logger: custom_components.bibliotek_dk.library_api Source: custom_components/bibliotek_dk/library_api.py:356 integration: Bibliotek (documentation, issues) First occurred: May 29, 2024 at 18:01:29 (4 occurrences) Last logged: 20:21:33

Error processing the

tag and subtags (https://www.aalborgbibliotekerne.dk/adgangsplatformen/login?destination=ding_frontpage). Error: ('NoneType' object has no attribute 'find')

3

This error originated from a custom integration.

Logger: custom_components.bibliotek_dk.library_api Source: custom_components/bibliotek_dk/library_api.py:163 integration: Bibliotek (documentation, issues) First occurred: May 29, 2024 at 18:01:29 (4 occurrences) Last logged: 20:21:33

Error in finding (logget ind) in the title of the page. Error: ('NoneType' object has no attribute 'title')

4

This error originated from a custom integration.

Logger: custom_components.bibliotek_dk.config_flow Source: custom_components/bibliotek_dk/config_flow.py:210 integration: Bibliotek (documentation, issues) First occurred: June 1, 2024 at 17:17:16 (2 occurrences) Last logged: 20:21:33

Unexpected exception Traceback (most recent call last): File "/config/custom_components/bibliotek_dk/config_flow.py", line 210, in async_step_user info = await validate_input(self.hass, user_input, libraries) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/bibliotek_dk/config_flow.py", line 86, in validate_input if not await hass.async_add_executor_job(myLibrary.login): ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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/bibliotek_dk/library_api.py", line 363, in login self.loggedIn = self._titleInSoup(soup, LOGGED_IN) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/bibliotek_dk/library_api.py", line 168, in _titleInSoup return result ^^^^^^ UnboundLocalError: cannot access local variable 'result' where it is not associated with a value

TermeHansen commented 2 months ago

I have the same error for https://bibliotek.kk.dk/adgangsplatformen/login?destination=ding_frontpage

homeassistant  | 2024-06-12 21:47:25.356 ERROR (SyncWorker_2) [custom_components.bibliotek_dk.library_api] HTTP Error while fetching https://bibliotek.kk.dk/adgangsplatformen/login?destination=ding_frontpage: 404 Client Error: Not Found for url: https://bibliotek.kk.dk/adgangsplatformen/login?destination=ding_frontpage
homeassistant  | 2024-06-12 21:47:25.356 ERROR (SyncWorker_2) [custom_components.bibliotek_dk.library_api] Error processing the <form> tag and subtags (https://bibliotek.kk.dk/adgangsplatformen/login?destination=ding_frontpage). Error: ('NoneType' object has no attribute 'find')
homeassistant  | 2024-06-12 21:47:25.356 ERROR (SyncWorker_2) [custom_components.bibliotek_dk.library_api] Error in finding (logget ind) in the title of the page. Error: ('NoneType' object has no attribute 'title')
homeassistant  | 2024-06-12 21:47:25.357 ERROR (MainThread) [custom_components.bibliotek_dk.sensor] Unexpected error fetching sensor data
homeassistant  | Traceback (most recent call last):
homeassistant  |   File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 312, in _async_refresh
homeassistant  |     self.data = await self._async_update_data()
homeassistant  |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
homeassistant  |   File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 268, in _async_update_data
homeassistant  |     return await self.update_method()
homeassistant  |            ^^^^^^^^^^^^^^^^^^^^^^^^^^
homeassistant  |   File "/config/custom_components/bibliotek_dk/sensor.py", line 58, in async_update_data
homeassistant  |     await hass.async_add_executor_job(myLibrary.update)
homeassistant  |   File "/usr/local/lib/python3.12/concurrent/futures/thread.py", line 58, in run
homeassistant  |     result = self.fn(*self.args, **self.kwargs)
homeassistant  |              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
homeassistant  |   File "/config/custom_components/bibliotek_dk/library_api.py", line 89, in update
homeassistant  |     if self.login():
homeassistant  |        ^^^^^^^^^^^^
homeassistant  |   File "/config/custom_components/bibliotek_dk/library_api.py", line 363, in login
homeassistant  |     self.loggedIn = self._titleInSoup(soup, LOGGED_IN)
homeassistant  |                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
homeassistant  |   File "/config/custom_components/bibliotek_dk/library_api.py", line 168, in _titleInSoup
homeassistant  |     return result
homeassistant  |            ^^^^^^
homeassistant  | UnboundLocalError: cannot access local variable 'result' where it is not associated with a value
torgert commented 1 month ago

Similar/same problem for Allerød:

2024-07-02 14:45:54.201 ERROR (SyncWorker_4) [custom_components.bibliotek_dk.library_api] HTTP Error while fetching https://www.bibliotek.alleroed.dk/adgangsplatformen/login?destination=ding_frontpage: 404 Client Error: Not Found for url: https://www.bibliotek.alleroed.dk/adgangsplatformen/login?destination=ding_frontpage 2024-07-02 14:45:54.201 ERROR (SyncWorker_4) [custom_components.bibliotek_dk.library_api] Error processing the tag and subtags (https://www.bibliotek.alleroed.dk/adgangsplatformen/login?destination=ding_frontpage). Error: ('NoneType' object has no attribute 'find') 2024-07-02 14:45:54.201 ERROR (SyncWorker_4) [custom_components.bibliotek_dk.library_api] Error in finding (logget ind) in the title of the page. Error: ('NoneType' object has no attribute 'title') 2024-07-02 14:45:54.203 ERROR (SyncWorker_5) [custom_components.bibliotek_dk.library_api] HTTP Error while fetching https://www.bibliotek.alleroed.dk/adgangsplatformen/login?destination=ding_frontpage: 404 Client Error: Not Found for url: https://www.bibliotek.alleroed.dk/adgangsplatformen/login?destination=ding_frontpage 2024-07-02 14:45:54.203 ERROR (SyncWorker_5) [custom_components.bibliotek_dk.library_api] Error processing the tag and subtags (https://www.bibliotek.alleroed.dk/adgangsplatformen/login?destination=ding_frontpage). Error: ('NoneType' object has no attribute 'find') 2024-07-02 14:45:54.203 ERROR (SyncWorker_5) [custom_components.bibliotek_dk.library_api] Error in finding (logget ind) in the title of the page. Error: ('NoneType' object has no attribute 'title') 2024-07-02 14:45:54.213 ERROR (MainThread) [custom_components.bibliotek_dk.sensor] Unexpected error fetching sensor data Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 312, in _async_refresh self.data = await self._async_update_data() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 268, in _async_update_data return await self.update_method() ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/bibliotek_dk/sensor.py", line 58, in async_update_data await hass.async_add_executor_job(myLibrary.update) 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/bibliotek_dk/library_api.py", line 89, in update if self.login(): ^^^^^^^^^^^^ File "/config/custom_components/bibliotek_dk/library_api.py", line 363, in login self.loggedIn = self._titleInSoup(soup, LOGGED_IN) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/bibliotek_dk/library_api.py", line 168, in _titleInSoup return result ^^^^^^ UnboundLocalError: cannot access local variable 'result' where it is not associated with a value 2024-07-02 14:45:54.230 DEBUG (MainThread) [custom_components.bibliotek_dk.sensor] Finished fetching sensor data in 0.786 seconds (success: False) 2024-07-02 14:45:54.230 ERROR (MainThread) [custom_components.bibliotek_dk.sensor] Unexpected error fetching sensor data Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 312, in _async_refresh self.data = await self._async_update_data() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 268, in _async_update_data return await self.update_method() ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/bibliotek_dk/sensor.py", line 58, in async_update_data await hass.async_add_executor_job(myLibrary.update) 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/bibliotek_dk/library_api.py", line 89, in update if self.login(): ^^^^^^^^^^^^ File "/config/custom_components/bibliotek_dk/library_api.py", line 363, in login self.loggedIn = self._titleInSoup(soup, LOGGED_IN) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/bibliotek_dk/library_api.py", line 168, in _titleInSoup return result ^^^^^^ UnboundLocalError: cannot access local variable 'result' where it is not associated with a value 2024-07-02 14:45:54.231 DEBUG (MainThread) [custom_components.bibliotek_dk.sensor] Finished fetching sensor data in 0.787 seconds (success: False)

SorenMaagaard commented 6 days ago

Same error for Herlev on https://www.herlevbibliotek.dk

The new web page for Herlev bibliotek look similar to ones mentioned above.