Coder Social home page Coder Social logo

python-luftdaten's Introduction

python-luftdaten

Python client for interacting with sensor.community (previously known as luftdaten.info.

This module is not official, developed, supported or endorsed by sensor.community/luftdaten.info.

Installation

The module is available from the Python Package Index.

$ pip3 install luftdaten

On a Fedora-based system or on a CentOS/RHEL machine with has EPEL enabled.

$ sudo dnf -y install python3-luftdaten

For Nix or NixOS is pre-packed module available. The lastest release is usually present in the unstable channel.

$ nix-env -iA nixos.python3Packages.luftdaten

Usage

The file example.py contains an example about how to use this module.

License

python-luftdaten is licensed under MIT, for more details check LICENSE.

python-luftdaten's People

Contributors

cgtobi avatar cougar avatar darashenka avatar dependabot[bot] avatar fabaff avatar jvanderneutstulen avatar mattsches avatar renenulschde avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

python-luftdaten's Issues

Initial Update

The bot created this issue to inform you that pyup.io has been set up on this repo.
Once you have closed it, the bot will open pull requests for updates as soon as they are available.

Many timeout exceptions

I'm using this library via the Home Assistant (2202.8.6) integration, to gather data from multiple sensors.

The Luftdaten API tends to be slow. My logs are spammed with multiple timeout exceptions that are not handled properly, and it also causes the Home Assistant sensors to go offline.

  • Would it be an idea to increase the timeout from 5 seconds (default of httpx) to something higher? Maybe 10 or 15 seconds?
  • Can timeout exceptions be ignored, such that they do not make the sensor go offline?

Access a luftdaten sensor locally

This request might be a bit out of scope, but wanted to hear your opinion on that.
As a user I would like to request sensor information locally from a sensor using the data.json or prometheus endpoint, so I don't have to rely on network connectivity to the outer world.

Use case: Sensor data is consumed and utilized to do home automation (e.g. close windows if values go high). This should not rely on internet connectivity or availability of the luftdaten platform.

Error python script

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?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.