Closed Mariusthvdb closed 1 year ago
luftdaten documentation luftdaten source (message by IssueLinks)
Hey there @fabaff, mind taking a look at this issue as it has been labeled with an integration (luftdaten
) you are listed as a code owner for? Thanks!
(message by CodeOwnersMention)
if this was supposed to be solved by 2022.2.0.dev20211222:
it is not... error has changed, but issue remains?:
2021-12-22 14:07:28 ERROR (MainThread) [homeassistant.components.luftdaten] Unexpected error fetching luftdaten_37248 data:
Traceback (most recent call last):
File "/usr/local/lib/python3.9/site-packages/anyio/_core/_sockets.py", line 180, in connect_tcp
await event.wait()
File "/usr/local/lib/python3.9/site-packages/anyio/_backends/_asyncio.py", line 1654, in wait
if await self._event.wait():
File "/usr/local/lib/python3.9/asyncio/locks.py", line 226, in wait
await fut
asyncio.exceptions.CancelledError
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/lib/python3.9/site-packages/httpcore/backends/asyncio.py", line 97, in connect_tcp
stream: anyio.abc.ByteStream = await anyio.connect_tcp(
File "/usr/local/lib/python3.9/site-packages/anyio/_core/_sockets.py", line 180, in connect_tcp
await event.wait()
File "/usr/local/lib/python3.9/site-packages/anyio/_backends/_asyncio.py", line 570, in __aexit__
raise CancelledError
asyncio.exceptions.CancelledError
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/lib/python3.9/site-packages/httpcore/_exceptions.py", line 8, in map_exceptions
yield
File "/usr/local/lib/python3.9/site-packages/httpcore/backends/asyncio.py", line 97, in connect_tcp
stream: anyio.abc.ByteStream = await anyio.connect_tcp(
File "/usr/local/lib/python3.9/site-packages/anyio/_core/_tasks.py", line 103, in __exit__
raise TimeoutError
TimeoutError
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/lib/python3.9/site-packages/httpx/_transports/default.py", line 60, in map_httpcore_exceptions
yield
File "/usr/local/lib/python3.9/site-packages/httpx/_transports/default.py", line 291, in handle_async_request
resp = await self._pool.handle_async_request(req)
File "/usr/local/lib/python3.9/site-packages/httpcore/_async/connection_pool.py", line 248, in handle_async_request
raise exc
File "/usr/local/lib/python3.9/site-packages/httpcore/_async/connection_pool.py", line 232, in handle_async_request
response = await connection.handle_async_request(request)
File "/usr/local/lib/python3.9/site-packages/httpcore/_async/connection.py", line 90, in handle_async_request
raise exc
File "/usr/local/lib/python3.9/site-packages/httpcore/_async/connection.py", line 67, in handle_async_request
stream = await self._connect(request)
File "/usr/local/lib/python3.9/site-packages/httpcore/_async/connection.py", line 115, in _connect
stream = await self._network_backend.connect_tcp(**kwargs)
File "/usr/local/lib/python3.9/site-packages/httpcore/backends/auto.py", line 23, in connect_tcp
return await self._backend.connect_tcp(
File "/usr/local/lib/python3.9/site-packages/httpcore/backends/asyncio.py", line 97, in connect_tcp
stream: anyio.abc.ByteStream = await anyio.connect_tcp(
File "/usr/local/lib/python3.9/contextlib.py", line 137, in __exit__
self.gen.throw(typ, value, traceback)
File "/usr/local/lib/python3.9/site-packages/httpcore/_exceptions.py", line 12, in map_exceptions
raise to_exc(exc)
httpcore.ConnectTimeout
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 187, in _async_refresh
self.data = await self._async_update_data()
File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 147, in _async_update_data
return await self.update_method()
File "/usr/src/homeassistant/homeassistant/components/luftdaten/__init__.py", line 39, in async_update
await luftdaten.get_data()
File "/usr/local/lib/python3.9/site-packages/luftdaten/__init__.py", line 29, in get_data
response = await client.get(str(url))
File "/usr/local/lib/python3.9/site-packages/httpx/_client.py", line 1736, in get
return await self.request(
File "/usr/local/lib/python3.9/site-packages/httpx/_client.py", line 1513, in request
return await self.send(request, auth=auth, follow_redirects=follow_redirects)
File "/usr/local/lib/python3.9/site-packages/httpx/_client.py", line 1600, in send
response = await self._send_handling_auth(
File "/usr/local/lib/python3.9/site-packages/httpx/_client.py", line 1628, in _send_handling_auth
response = await self._send_handling_redirects(
File "/usr/local/lib/python3.9/site-packages/httpx/_client.py", line 1665, in _send_handling_redirects
response = await self._send_single_request(request)
File "/usr/local/lib/python3.9/site-packages/httpx/_client.py", line 1702, in _send_single_request
response = await transport.handle_async_request(request)
File "/usr/local/lib/python3.9/site-packages/httpx/_transports/default.py", line 291, in handle_async_request
resp = await self._pool.handle_async_request(req)
File "/usr/local/lib/python3.9/contextlib.py", line 137, in __exit__
self.gen.throw(typ, value, traceback)
File "/usr/local/lib/python3.9/site-packages/httpx/_transports/default.py", line 77, in map_httpcore_exceptions
raise mapped_exc(message) from exc
httpx.ConnectTimeout
This is broken since 2021.12 I think. At least, I am getting the same error in the stable version. I don't run the dev build. Hope it can be resolved soon 👍.
I had the same issue since 2021.12. After deleting and re-adding the integration it seems to be solved.
I had the same issue since 2021.12. After deleting and re-adding the integration it seems to be solved.
That does not seem to work for me unfortunately. I'm getting the same error when re-adding the integration.
running dev 2022.2.0.dev20220106 things have improved ?
currently I only see:
2022-01-06 20:36:26 WARNING (MainThread) [homeassistant.config_entries] Config entry 'Roosendaal' for luftdaten integration not ready yet; Retrying in background
2022-01-06 20:36:26 WARNING (MainThread) [homeassistant.config_entries] Config entry 'Tilburg' for luftdaten integration not ready yet; Retrying in background
2022-01-06 20:36:26 WARNING (MainThread) [homeassistant.config_entries] Config entry 'Tilburg' for luftdaten integration not ready yet; Retrying in background
2022-01-06 20:36:26 WARNING (MainThread) [homeassistant.config_entries] Config entry 'Rotterdam' for luftdaten integration not ready yet; Retrying in background
2022-01-06 20:36:26 WARNING (MainThread) [homeassistant.config_entries] Config entry 'Rotterdam' for luftdaten integration not ready yet; Retrying in background
during startup, and almost none of the sensors are available.
but the httpx.ConnectTimeout error has not been back ;-)
Same for me. Reconfigured the Luftdaten entries on my config but still timeout issues remaining:
Logger: homeassistant.config_entries
Source: components/luftdaten/__init__.py:231
First occurred: 24:56:07 (3 occurrences)
Last logged: 24:56:07
Error setting up entry 4732 for luftdaten
Error setting up entry 46507 for luftdaten
Error setting up entry 29362 for luftdaten
Traceback (most recent call last):
File "/usr/local/lib/python3.9/site-packages/anyio/streams/tls.py", line 108, in _call_sslobject_method
result = func(*args)
File "/usr/local/lib/python3.9/ssl.py", line 888, in read
v = self._sslobj.read(len)
ssl.SSLWantReadError: The operation did not complete (read) (_ssl.c:2633)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/lib/python3.9/site-packages/httpcore/backends/asyncio.py", line 31, in read
return await self._stream.receive(max_bytes=max_bytes)
File "/usr/local/lib/python3.9/site-packages/anyio/streams/tls.py", line 171, in receive
data = await self._call_sslobject_method(self._ssl_object.read, max_bytes)
File "/usr/local/lib/python3.9/site-packages/anyio/streams/tls.py", line 115, in _call_sslobject_method
data = await self.transport_stream.receive()
File "/usr/local/lib/python3.9/site-packages/anyio/_backends/_asyncio.py", line 1105, in receive
await self._protocol.read_event.wait()
File "/usr/local/lib/python3.9/asyncio/locks.py", line 226, in wait
await fut
asyncio.exceptions.CancelledError
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/lib/python3.9/site-packages/httpcore/_exceptions.py", line 8, in map_exceptions
yield
File "/usr/local/lib/python3.9/site-packages/httpcore/backends/asyncio.py", line 33, in read
return b""
File "/usr/local/lib/python3.9/site-packages/anyio/_core/_tasks.py", line 103, in __exit__
raise TimeoutError
TimeoutError
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/lib/python3.9/site-packages/httpx/_transports/default.py", line 60, in map_httpcore_exceptions
yield
File "/usr/local/lib/python3.9/site-packages/httpx/_transports/default.py", line 291, in handle_async_request
resp = await self._pool.handle_async_request(req)
File "/usr/local/lib/python3.9/site-packages/httpcore/_async/connection_pool.py", line 244, in handle_async_request
raise exc
File "/usr/local/lib/python3.9/site-packages/httpcore/_async/connection_pool.py", line 228, in handle_async_request
response = await connection.handle_async_request(request)
File "/usr/local/lib/python3.9/site-packages/httpcore/_async/connection.py", line 90, in handle_async_request
return await self._connection.handle_async_request(request)
File "/usr/local/lib/python3.9/site-packages/httpcore/_async/http11.py", line 102, in handle_async_request
raise exc
File "/usr/local/lib/python3.9/site-packages/httpcore/_async/http11.py", line 81, in handle_async_request
) = await self._receive_response_headers(**kwargs)
File "/usr/local/lib/python3.9/site-packages/httpcore/_async/http11.py", line 143, in _receive_response_headers
event = await self._receive_event(timeout=timeout)
File "/usr/local/lib/python3.9/site-packages/httpcore/_async/http11.py", line 172, in _receive_event
data = await self._network_stream.read(
File "/usr/local/lib/python3.9/site-packages/httpcore/backends/asyncio.py", line 33, in read
return b""
File "/usr/local/lib/python3.9/contextlib.py", line 137, in __exit__
self.gen.throw(typ, value, traceback)
File "/usr/local/lib/python3.9/site-packages/httpcore/_exceptions.py", line 12, in map_exceptions
raise to_exc(exc)
httpcore.ReadTimeout
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/config_entries.py", line 313, in async_setup
result = await component.async_setup_entry(hass, self) # type: ignore
File "/usr/src/homeassistant/homeassistant/components/luftdaten/__init__.py", line 184, in async_setup_entry
await luftdaten.async_update()
File "/usr/src/homeassistant/homeassistant/components/luftdaten/__init__.py", line 231, in async_update
await self.client.get_data()
File "/usr/local/lib/python3.9/site-packages/luftdaten/__init__.py", line 29, in get_data
response = await client.get(str(url))
File "/usr/local/lib/python3.9/site-packages/httpx/_client.py", line 1736, in get
return await self.request(
File "/usr/local/lib/python3.9/site-packages/httpx/_client.py", line 1513, in request
return await self.send(request, auth=auth, follow_redirects=follow_redirects)
File "/usr/local/lib/python3.9/site-packages/httpx/_client.py", line 1600, in send
response = await self._send_handling_auth(
File "/usr/local/lib/python3.9/site-packages/httpx/_client.py", line 1628, in _send_handling_auth
response = await self._send_handling_redirects(
File "/usr/local/lib/python3.9/site-packages/httpx/_client.py", line 1665, in _send_handling_redirects
response = await self._send_single_request(request)
File "/usr/local/lib/python3.9/site-packages/httpx/_client.py", line 1702, in _send_single_request
response = await transport.handle_async_request(request)
File "/usr/local/lib/python3.9/site-packages/httpx/_transports/default.py", line 291, in handle_async_request
resp = await self._pool.handle_async_request(req)
File "/usr/local/lib/python3.9/contextlib.py", line 137, in __exit__
self.gen.throw(typ, value, traceback)
File "/usr/local/lib/python3.9/site-packages/httpx/_transports/default.py", line 77, in map_httpcore_exceptions
raise mapped_exc(message) from exc
httpx.ReadTimeout
Same issue here
I do also confirm that the issue started with 2021.12 and since last subversion it is still present. Are there any news when it will be fixed, in 2022.01?
2022.01
There is no 2022.1.
This issue is currently open, if there was news, you would have read it here.
I cannot even add a sensor (Sensor not available or invalid) - it produces this very error in the logs. Is it correct that that's down to this issue or am I doing it wrong?
It's been 4 months since the integration stopped working. I think it should be stated on the HA integration page that the integration of Luftdaten sensors is currently not supported since 2021.12. This is misleading.
FWIW, I set up a curl | jq | mosquitto_pub
incantation on a systemd timer to work around the issue until a fix is available. I can polish it a bit and share if there's interest.
It's been 4 months since the integration stopped working. I think it should be stated on the HA integration page that the integration of Luftdaten sensors is currently not supported since 2021.12. This is misleading.
I agree. It was a very nice integration, but since its current condition it is better to be flagged as not supported.
FWIW, I set up a
curl | jq | mosquitto_pub
incantation on a systemd timer to work around the issue until a fix is available. I can polish it a bit and share if there's interest.
Could you please give me some more information on how to apply your fix? I am using Raspberry Pi for HA.
Unfortunately I did buy the hardware and set up my own luftdaten sensor before checking whether the integration works and whilst I could push my own sensor data directly to my own influx and go from there I would've preferred to go with the integration - also to subscribe to other sensors in the vicinity.
Given that I cannot even add any sensor - is there a way to get things up and running from scratch atm, applying some manual config, declaring sensor IDs somewhere on conf file level or something?
Could you please give me some more information on how to apply your fix? I am using Raspberry Pi for HA.
It's not a fix. To be able to get a reading of outside particulate matter, I've set the following script on a schedule (I know it is by far not user friendly, however it's been very stable; prerequisites for running without modification: curl
, jq
, mosquitto_pub
, and having a local mqtt server that does not require authentication for localhost):
/usr/local/bin/poll-sensor-community.sh
:
#!/bin/bash
curl --silent "https://data.sensor.community/airrohr/v1/sensor/$1/" | \
jq -r '
.[0]
| {id: .sensor.id, p1: (.sensordatavalues[] | select(.value_type == "P1")).value, p2: (.sensordatavalues[] | select(.value_type == "P2")).value}
| (["-t", (["sensors", "luftdaten", .id, "p1"] | join("/")), "-m", .p1] | join(" "))
, (["-t", (["sensors", "luftdaten", .id, "p2"] | join("/")), "-m", .p2] | join(" "))
' | xargs -L1 mosquitto_pub
/etc/systemd/system/poll-sensor-community@.service
:
[Service]
Type=oneshot
ExecStart=/usr/local/bin/poll-sensor-community.sh %i
/etc/systemd/system/poll-sensor-community@.timer
:
[Timer]
OnBootSec=1min
OnUnitActiveSec=3min
[Install]
WantedBy=timers.target
You enable polling a given sensor by issuing systemctl enable --now poll-sensor-community@<YOUR SENSOR ID>.timer
Then you need to have HASS configured to work with your MQTT server, and define sensors in your HASS configuration.yaml
:
sensor:
- platform: mqtt
state_topic: "sensors/luftdaten/<YOUR SENSOR ID>/p1"
name: "PM₁₀"
unique_id: "sensor.luftdaten.pm10"
unit_of_measurement: "μg/m³"
icon: "mdi:thought-bubble"
- platform: mqtt
state_topic: "sensors/luftdaten/<YOUR SENSOR ID>/p2"
name: "PM₂.₅"
unique_id: "sensor.luftdaten.pm25"
unit_of_measurement: "μg/m³"
icon: "mdi:thought-bubble-outline"
I noticed someone added a World Air Quality Index (WAQI) integration in HACS. This reports the same data I believe, so maybe that will be a good alternative to the luftdaten integration. I haven't tried it yet, but I'll probably do so during the weekend.
Well I tried the WAQI integration, but only some of the reported sensors on the website can be used in the API. (It was stated in the Readme of the integration.) So the luftdaten/sensor.community data can't be read via the WAQI API unfortunately.
I found 2 things that seem worth checking:
https://forum.sensor.community/t/timeouts-to-api-sensor-community-v1-push-sensor-data/519/3 where it's suggested to use http pinstead of https, means editing init.py:
_RESOURCE = "https://data.sensor.community/airrohr/v1"
and there's increasing the httpx timeout in the same file:
response = await client.get(str(url),timeout=10)
Changing just the timeout gave me: 2022-11-06 13:49:25.500 DEBUG (MainThread) [homeassistant.components.luftdaten] Finished fetching luftdaten_56xxx data in 11.378 seconds (success: False) 2022-11-06 13:49:25.500 WARNING (MainThread) [homeassistant.config_entries] Config entry '56xxx' for luftdaten integration not ready yet; Retrying in background
The problem
None of the Luftdaten sensors are initialized
What version of Home Assistant Core has the issue?
Home Assistant 2022.1.0.dev20211213
What was the last working version of Home Assistant Core?
?
What type of installation are you running?
Home Assistant OS
Integration causing the issue
Luftdaten
Link to integration documentation on our website
https://www.home-assistant.io/integrations/luftdaten/
Example YAML snippet
Anything in the logs that might be useful for us?
Additional information
No response