core
core copied to clipboard
PrusaLink fills up the log when the printer is turned off
The problem
The PrusaLink logs an error every minute when the printer is off (unreachable over the network). This creates around 70000 log lines per day, fills up the disk fast and makes the log unreadable.
What version of Home Assistant Core has the issue?
core-2024.4.4
What was the last working version of Home Assistant Core?
No response
What type of installation are you running?
Home Assistant Core
Integration causing the issue
PrusaLink
Link to integration documentation on our website
https://www.home-assistant.io/integrations/prusalink/
Diagnostics information
The repeating log entry:
2024-04-26 04:02:19.913 ERROR (MainThread) [homeassistant.components.prusalink] Unexpected error fetching prusalink data: All connection attempts failed
Traceback (most recent call last):
File "/opt/ha/lib/python3.12/site-packages/httpx/_transports/default.py", line 69, in map_httpcore_exceptions
yield
File "/opt/ha/lib/python3.12/site-packages/httpx/_transports/default.py", line 373, in handle_async_request
resp = await self._pool.handle_async_request(req)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/ha/lib/python3.12/site-packages/httpcore/_async/connection_pool.py", line 216, in handle_async_request
raise exc from None
File "/opt/ha/lib/python3.12/site-packages/httpcore/_async/connection_pool.py", line 196, in handle_async_request
response = await connection.handle_async_request(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/ha/lib/python3.12/site-packages/httpcore/_async/connection.py", line 99, in handle_async_request
raise exc
File "/opt/ha/lib/python3.12/site-packages/httpcore/_async/connection.py", line 76, in handle_async_request
stream = await self._connect(request)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/ha/lib/python3.12/site-packages/httpcore/_async/connection.py", line 122, in _connect
stream = await self._network_backend.connect_tcp(**kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/ha/lib/python3.12/site-packages/httpcore/_backends/auto.py", line 30, in connect_tcp
return await self._backend.connect_tcp(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/ha/lib/python3.12/site-packages/httpcore/_backends/anyio.py", line 112, in connect_tcp
with map_exceptions(exc_map):
File "/opt/python/lib/python3.12/contextlib.py", line 158, in __exit__
self.gen.throw(value)
File "/opt/ha/lib/python3.12/site-packages/httpcore/_exceptions.py", line 14, in map_exceptions
raise to_exc(exc) from exc
httpcore.ConnectError: All connection attempts failed
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/opt/ha/lib/python3.12/site-packages/homeassistant/helpers/update_coordinator.py", line 315, in _async_refresh
self.data = await self._async_update_data()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/ha/lib/python3.12/site-packages/homeassistant/components/prusalink/__init__.py", line 153, in _async_update_data
data = await self._fetch_data()
^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/ha/lib/python3.12/site-packages/homeassistant/components/prusalink/__init__.py", line 193, in _fetch_data
return await self.api.get_legacy_printer()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/ha/lib/python3.12/site-packages/pyprusalink/__init__.py", line 48, in get_legacy_printer
async with self.client.request("GET", "/api/printer") as response:
File "/opt/python/lib/python3.12/contextlib.py", line 210, in __aenter__
return await anext(self.gen)
^^^^^^^^^^^^^^^^^^^^^
File "/opt/ha/lib/python3.12/site-packages/pyprusalink/client.py", line 69, in request
response = await self._async_client.request(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/ha/lib/python3.12/site-packages/httpx/_client.py", line 1574, in request
return await self.send(request, auth=auth, follow_redirects=follow_redirects)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/ha/lib/python3.12/site-packages/httpx/_client.py", line 1661, in send
response = await self._send_handling_auth(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/ha/lib/python3.12/site-packages/httpx/_client.py", line 1689, in _send_handling_auth
response = await self._send_handling_redirects(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/ha/lib/python3.12/site-packages/httpx/_client.py", line 1726, in _send_handling_redirects
response = await self._send_single_request(request)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/ha/lib/python3.12/site-packages/httpx/_client.py", line 1763, in _send_single_request
response = await transport.handle_async_request(request)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/ha/lib/python3.12/site-packages/httpx/_transports/default.py", line 372, in handle_async_request
with map_httpcore_exceptions():
File "/opt/python/lib/python3.12/contextlib.py", line 158, in __exit__
self.gen.throw(value)
File "/opt/ha/lib/python3.12/site-packages/httpx/_transports/default.py", line 86, in map_httpcore_exceptions
raise mapped_exc(message) from exc
httpx.ConnectError: All connection attempts failed
Example YAML snippet
No response
Anything in the logs that might be useful for us?
No response
Additional information
No response
Hey there @balloob, @skaronator, mind taking a look at this issue as it has been labeled with an integration (prusalink
) you are listed as a code owner for? Thanks!
Code owner commands
Code owners of prusalink
can trigger bot actions by commenting:
-
@home-assistant close
Closes the issue. -
@home-assistant rename Awesome new title
Renames the issue. -
@home-assistant reopen
Reopen the issue. -
@home-assistant unassign prusalink
Removes the current integration label and assignees on the issue, add the integration domain after the command. -
@home-assistant add-label needs-more-information
Add a label (needs-more-information, problem in dependency, problem in custom component) to the issue. -
@home-assistant remove-label needs-more-information
Remove a label (needs-more-information, problem in dependency, problem in custom component) on the issue.
(message by CodeOwnersMention)
prusalink documentation prusalink source (message by IssueLinks)
@terba plz vote for your own issue :)
I have to vote to solve an error? It's exactly like democracy :) Where do I have to vote? Link please!
Well, more votes means more visibility. Click the thumb above. You can see my one thumb in the screenshot.
The exception is thrown by the httpx library and then escalated by the pyprusalink library. I think this should be handled by pyprusalink, as it already has a NotFound()
class that's used upon a 404 error and could also be used for connection errors. I've filed an issue over there: https://github.com/home-assistant-libs/pyprusalink/issues/93
Still happening on 2024.5.5. Logs fill up fast, especially with 2 printers being offline most of the time.
Well, I've submitted a PR with a fix that works for me but there hasn't been a response from the maintainers. If you want to mess around yourself you can check out this repo: https://github.com/Gnarflord/pyprusalink/tree/main
Or change the lines manually: https://github.com/home-assistant-libs/pyprusalink/pull/94/commits/d3e5193dc44985c5eca1604842dcb43daf5ed5c5
I don't know how to speed up this process as I've never contributed to HA before.
My log is also full.
For anyone watching this, it was rejected in pyprusalink : "This should be handled in core as it's a connection error."
https://github.com/home-assistant-libs/pyprusalink/pull/94