mytselection / bibliotheek_be Goto Github PK
View Code? Open in Web Editor NEWBibliotheek.be Home Assistant custom component HACS with overview of lended Belgian library items and services to (automatically) extend loans.
License: MIT License
Bibliotheek.be Home Assistant custom component HACS with overview of lended Belgian library items and services to (automatically) extend loans.
License: MIT License
When trying to retrieve the library details, the site responds with a 301 redirect instead of a 200 code.
The structure of the details also seems to be different as just following the redirect results in a parsing error.
Parsing error when following the redirect
File "/config/custom_components/bibliotheek_be/utils.py", line 218, in library_details
for dl in libraryArticle.find_all('dl',class_='library__date-open'):
^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'find_all'
Debug log for the library details:
2023-10-22 14:26:10.581 DEBUG (SyncWorker_6) [custom_components.bibliotheek_be.utils] library details URL https://gent.bibliotheek.be/adres-en-openingsuren
2023-10-22 14:26:10.877 DEBUG (SyncWorker_6) [custom_components.bibliotheek_be.utils] bibliotheek.be library get result status code: 301
2023-10-22 14:26:10.878 DEBUG (SyncWorker_6) [custom_components.bibliotheek_be.utils] bibliotheek.be library get header: {'Date': 'Sun, 22 Oct 2023 12:26:10 GMT', 'Content-Type': 'text/html; charset=UTF-8', 'Content-Length': '466', 'Connection': 'keep-alive', 'x-redirect-id': '967', 'x-ua-compatible': 'IE=edge', 'content-language': 'nl', 'x-content-type-options': 'nosniff', 'location': 'https://gent.bibliotheek.be/adres-en-openingsuren/nieuw', 'age': '0', 'x-cache': 'MISS ausy-cultuurconnect-web8', 'x-cache-hits': '0', 'Front-End-Https': 'on'}
2023-10-22 14:26:10.879 ERROR (MainThread) [homeassistant.components.sensor] Error while setting up bibliotheek_be platform for sensor
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 359, in _async_setup_platform
await asyncio.shield(task)
File "/config/custom_components/bibliotheek_be/sensor.py", line 95, in async_setup_entry
await dry_setup(hass, config, async_add_devices)
File "/config/custom_components/bibliotheek_be/sensor.py", line 44, in dry_setup
await componentData._force_update()
File "/config/custom_components/bibliotheek_be/sensor.py", line 147, in _force_update
librarydetails = await self._hass.async_add_executor_job(lambda: self._session.library_details(libraryurl))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/concurrent/futures/thread.py", line 58, in run
result = self.fn(*self.args, **self.kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/config/custom_components/bibliotheek_be/sensor.py", line 147, in <lambda>
librarydetails = await self._hass.async_add_executor_job(lambda: self._session.library_details(libraryurl))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/config/custom_components/bibliotheek_be/utils.py", line 211, in library_details
assert response.status_code == 200
^^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError
The services to extend loans are working, but the result is no immediately visible.
Currently the sensors have a throttle configured to only fetch updates from the bibliotheek.be website every hour. So even when forcing a sensor update, only the cached data is returned and it may take up to one hour before the loan extension will become visible.
For now, I don't have an immediate solution to this. Not sure how I can call the forceupdate method on the sensor from within the services.
Error message to be analysed,
This error originated from a custom integration.
Logger: homeassistant.helpers.entity
Source: custom_components/bibliotheek_be/utils.py:88
Integration: Bibliotheek.be (documentation, issues)
First occurred: 12:45:48 AM (1 occurrences)
Last logged: 12:45:48 AM
Update for sensor.bibliotheek_be_jorim_tielemans_stuifzand fails
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 548, in async_update_ha_state
await self.async_device_update()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 746, in async_device_update
raise exc
File "/config/custom_components/bibliotheek_be/sensor.py", line 163, in async_update
await self._data.update()
File "/config/custom_components/bibliotheek_be/sensor.py", line 134, in update
await self._update()
File "/config/custom_components/bibliotheek_be/sensor.py", line 131, in _update
await self._force_update()
File "/config/custom_components/bibliotheek_be/sensor.py", line 113, in _force_update
self._userdetails = await self._hass.async_add_executor_job(lambda: self._session.login(self._username, self._password))
File "/usr/local/lib/python3.10/concurrent/futures/thread.py", line 58, in run
result = self.fn(*self.args, **self.kwargs)
File "/config/custom_components/bibliotheek_be/sensor.py", line 113, in <lambda>
self._userdetails = await self._hass.async_add_executor_job(lambda: self._session.login(self._username, self._password))
File "/config/custom_components/bibliotheek_be/utils.py", line 88, in login
assert response.status_code == 302
AssertionError
When inserting username and password the integration fails.
is it possible to hard code them in the configuration.yaml file?
https://github.com/myTselection/bibliotheek_be/blob/master/custom_components/bibliotheek_be/__init__.py#L19 This is doing I/O during module import, which will hurt Home Assistant startup performance.
An alternative is to use this during the setup https://github.com/home-assistant/core/blob/dev/homeassistant/loader.py#L892
Originally posted by @ludeeus in hacs/default#1723 (comment)
Library website changes resulted in incompatibility, to be checked
Installed latest commit master branch.
Logger: homeassistant.components.sensor
Source: custom_components/bibliotheek_be/utils.py:63
Integration: Sensor (documentation, issues)
First occurred: 11:47:50 AM (2 occurrences)
Last logged: 2:13:33 PM
Error while setting up bibliotheek_be platform for sensor
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 289, in _async_setup_platform
await asyncio.shield(task)
File "/config/custom_components/bibliotheek_be/sensor.py", line 69, in async_setup_entry
await dry_setup(hass, config, async_add_devices)
File "/config/custom_components/bibliotheek_be/sensor.py", line 44, in dry_setup
await componentData._init()
File "/config/custom_components/bibliotheek_be/sensor.py", line 100, in _init
self._user_details = await self._hass.async_add_executor_job(lambda: self._session.login(self._username, self._password))
File "/usr/local/lib/python3.10/concurrent/futures/thread.py", line 58, in run
result = self.fn(*self.args, **self.kwargs)
File "/config/custom_components/bibliotheek_be/sensor.py", line 100, in <lambda>
self._user_details = await self._hass.async_add_executor_job(lambda: self._session.login(self._username, self._password))
File "/config/custom_components/bibliotheek_be/utils.py", line 63, in login
oauth_
NameError: name 'oauth_' is not defined
if loan details attribute 'extend_loan_id' is empty, the item can NOT be extended
awaiting validation / approval of pull request hacs/default#1723
Validation test_setup and/or check_settings is failing, but the validation result is ignored for now
First error:
This error originated from a custom integration.
Logger: homeassistant.helpers.entity
Source: custom_components/bibliotheek_be/sensor.py:127
Integration: Bibliotheek.be (documentation, issues)
First occurred: 10:46:48 (2 occurrences)
Last logged: 11:46:48
Update for sensor.bibliotheek_be_jorim_tielemans_stuifzand fails
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 541, in async_update_ha_state
await self.async_device_update()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 739, in async_device_update
raise exc
File "/config/custom_components/bibliotheek_be/sensor.py", line 179, in async_update
await self._data.update()
File "/config/custom_components/bibliotheek_be/sensor.py", line 149, in update
await self._update()
File "/config/custom_components/bibliotheek_be/sensor.py", line 146, in _update
await self._force_update()
File "/config/custom_components/bibliotheek_be/sensor.py", line 127, in _force_update
assert self._userdetails is not None
AssertionError
And second error:
This error originated from a custom integration.
Logger: homeassistant.helpers.entity
Source: custom_components/bibliotheek_be/sensor.py:183
Integration: Bibliotheek.be (documentation, issues)
First occurred: 10:47:18 (238 occurrences)
Last logged: 12:46:18
Update for sensor.bibliotheek_be_jorim_tielemans_stuifzand fails
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 541, in async_update_ha_state
await self.async_device_update()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 739, in async_device_update
raise exc
File "/config/custom_components/bibliotheek_be/sensor.py", line 183, in async_update
self._num_loans = self._data._userdetails.get(self._userid).get('loans').get('loans')
AttributeError: 'NoneType' object has no attribute 'get'
To be analyzed in detail
Installed version 0.4.0
When trying to reload I get the following error
I double checked by deleting the integration and setting it up again
Logger: homeassistant.config_entries
Source: helpers/entity_component.py:166
First occurred: 9:29:32 PM (1 occurrences)
Last logged: 9:29:32 PM
Error setting up entry Bibliotheek.be for sensor
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/config_entries.py", line 382, in async_setup
result = await component.async_setup_entry(hass, self)
File "/usr/src/homeassistant/homeassistant/components/sensor/__init__.py", line 125, in async_setup_entry
return await component.async_setup_entry(entry)
File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 166, in async_setup_entry
raise ValueError("Config entry has already been setup!")
ValueError: Config entry has already been setup!
When adding 2 accounts to home assistant there is only one warning created.
In the logs you get the following error:
Logger: homeassistant.components.sensor
Source: helpers/entity_platform.py:540
Integration: Sensor (documentation, issues)
First occurred: 17:42:59 (1 occurrences)
Last logged: 17:42:59
Platform bibliotheek_be does not generate unique IDs. ID Bibliotheek.be warning already exists - ignoring sensor.bibliotheek_be_warning
sensor that indicates by which date any loand item has to be returned
including attribute to indicate if it can be extended or not
When extending with service, the Refresh required Boolean will be set to true, but it might be reset to false in the loop of another library or user before the sensor update has triggered. If the Refresh required is true it may only be reset to false by the sensor update, not by the service.
waiting for acceptance of pull request: home-assistant/brands#4082
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.