home-assistant-ecosystem / python-luftdaten

Python API for interacting with luftdaten.info
MIT License
5 stars 9 forks source link

Error python script #9

Closed Blackbox2018 closed 4 years ago

Blackbox2018 commented 4 years ago

Good morning Until two week ago my script python worked and I received the data from my sensor. But now I receive only error

Can not load data from luftdaten.info
Traceback (most recent call last):
  File "/home/pi/.local/lib/python3.7/site-packages/aiohttp/connector.py", line 967, in _create_direct_connection
    traces=traces), loop=self._loop)
  File "/home/pi/.local/lib/python3.7/site-packages/aiohttp/connector.py", line 830, in _resolve_host
    self._resolver.resolve(host, port, family=self._family)
  File "/home/pi/.local/lib/python3.7/site-packages/aiohttp/resolver.py", line 30, in resolve
    host, port, type=socket.SOCK_STREAM, family=family)
  File "/usr/lib/python3.7/asyncio/base_events.py", line 789, in getaddrinfo
    None, getaddr_func, host, port, family, type, proto, flags)
  File "/usr/lib/python3.7/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/lib/python3.7/socket.py", line 748, in getaddrinfo
    for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
socket.gaierror: [Errno -3] Temporary failure in name resolution

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/pi/.local/lib/python3.7/site-packages/luftdaten/__init__.py", line 34, in get_data
    response = await self._session.get(url)
  File "/home/pi/.local/lib/python3.7/site-packages/aiohttp/client.py", line 483, in _request
    timeout=real_timeout
  File "/home/pi/.local/lib/python3.7/site-packages/aiohttp/connector.py", line 523, in connect
    proto = await self._create_connection(req, traces, timeout)
  File "/home/pi/.local/lib/python3.7/site-packages/aiohttp/connector.py", line 859, in _create_connection
    req, traces, timeout)
  File "/home/pi/.local/lib/python3.7/site-packages/aiohttp/connector.py", line 971, in _create_direct_connection
    raise ClientConnectorError(req.connection_key, exc) from exc
aiohttp.client_exceptions.ClientConnectorError: Cannot connect to host data.sensor.community:443 ssl:default [Temporary failure in name resolution]

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/pi/luftdaten2Aiq.py", line 75, in <module>
    loop.run_until_complete(main())
  File "/usr/lib/python3.7/asyncio/base_events.py", line 584, in run_until_complete
    return future.result()
  File "/home/pi/luftdaten2Aiq.py", line 20, in main
    await dataPm.get_data()
  File "/home/pi/.local/lib/python3.7/site-packages/luftdaten/__init__.py", line 42, in get_data
    raise exceptions.LuftdatenConnectionError()
 @luftdaten.exceptions.LuftdatenConnectionError

I don't know if luftdaten have changed the address. Could you help me?

Schluggi commented 4 years ago

Yes. The api url has changed with 6b44b2ced5eca9d29540c1f6a618d19c3f9ba2bb but i don't think that's your problem. It looks like a typical dns configuration error.

Blackbox2018 commented 4 years ago

Thank you're right! I make a big mess with DNS and IP static, now work perfectly Good job!