Code Monkey home page Code Monkey logo

python-opensky's Introduction

Python: OpenSky

GitHub Release Python Versions Project Stage Project Maintenance License

Build Status Code Coverage Code Smells

Asynchronous Python client for the OpenSky API.

About

This package allows you to request data about aircraft around the world.

Installation

pip install python-opensky

Usage

import asyncio

from python_opensky import OpenSky, StatesResponse


async def main() -> None:
    """Show example of fetching all flight states."""
    async with OpenSky() as opensky:
        states: StatesResponse = await opensky.get_states()
        print(states)


if __name__ == "__main__":
    asyncio.run(main())

Changelog & Releases

This repository keeps a change log using GitHub's releases functionality. The format of the log is based on Keep a Changelog.

Releases are based on Semantic Versioning, and use the format of MAJOR.MINOR.PATCH. In a nutshell, the version will be incremented based on the following:

  • MAJOR: Incompatible or major changes.
  • MINOR: Backwards-compatible new features and enhancements.
  • PATCH: Backwards-compatible bugfixes and package updates.

Contributing

This is an active open-source project. We are always open to people who want to use the code or contribute to it.

We've set up a separate document for our contribution guidelines.

Thank you for being involved! ๐Ÿ˜

Setting up development environment

This Python project is fully managed using the Poetry dependency manager. But also relies on the use of NodeJS for certain checks during development.

You need at least:

  • Python 3.10+
  • Poetry
  • NodeJS 12+ (including NPM)

To install all packages, including all development requirements:

npm install
poetry install

As this repository uses the pre-commit framework, all changes are linted and tested with each commit. You can run all checks and tests manually, using the following command:

poetry run pre-commit run --all-files

To run just the Python tests:

poetry run pytest

Authors & contributors

The original setup of this repository is heavily inspired by Franck Nijhof.

The content is by Joost Lekkerkerker

For a full list of all authors and contributors, check the contributor's page.

License

MIT License

Copyright (c) 2023 Joost Lekkerkerker

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

python-opensky's People

Contributors

cdce8p avatar dependabot[bot] avatar joostlek avatar ozgav avatar renovate[bot] avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

Forkers

ozgav pem884

python-opensky's Issues

opensky sensor not working

Problem/Motivation

OpenSky sensor not being created

Expected behavior

Opensky sensors to show up in HA

Actual behavior

no sensors in dev>states
logs

Source: components/opensky/sensor.py:163
Integration: Sensor (documentation, issues)
First occurred: 8:57:23 AM (1 occurrences)
Last logged: 8:57:23 AM

opensky: Error on device update!
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 537, in _async_add_entity
    await entity.async_device_update(warning=False)
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 784, in async_device_update
    await self.async_update()
  File "/usr/src/homeassistant/homeassistant/components/opensky/sensor.py", line 163, in async_update
    response = await self._opensky.get_states(bounding_box=self._bounding_box)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/python_opensky/opensky.py", line 148, in get_states
    "states": [self._convert_state(state) for state in data["states"]],
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: 'NoneType' object is not iterable

Change request

First of all, I like to state that I highly respect the time and effort which has flown into this integration.
I personally think it is 100%, very good, and I am aware that this request is pretty cheeky, but never the less I think plenty of people will benefit from the following changes, and as I cannot do them myself, I am asking a lot here. :-(

I am not a Python Developer, but I can read and write code...

When I read your code it states that the refresh interval is 15 Minutes, which is 100% correct for "the blank case",
But looking at the Opensky website: https://openskynetwork.github.io/opensky-api/rest.html#api-credit-usage
It states that for requests under 500km radius, they only charge 1 credit (Interval=216 seconds only).
Could we make the scan interval dependant on the radius, or enter the scan interval as a parameter that can be user defined?

Next thing:
If the user has a name and password with opensky, she or he can get 4000 to 8000 credits.
Could we integrate something, so we are able to pass username and password as a parameter and based on that change the scan interval is recalculated, or as stated above add a paramter scan_interval, so that the admin can define the interval in the HA config?

I am not expecting anything here, I am just asking, if you could look into this?

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Awaiting Schedule

These updates are awaiting their schedule. Click on a checkbox to get an update now.

  • โฌ†๏ธ Lock file maintenance

Detected dependencies

github-actions
.github/workflows/labels.yaml
  • actions/checkout v4.1.7
  • micnncim/action-label-syncer v1.3.0
.github/workflows/linting.yaml
  • actions/checkout v4.1.7
  • actions/setup-python v5.1.1
  • actions/checkout v4.1.7
  • actions/setup-python v5.1.1
  • actions/checkout v4.1.7
  • actions/setup-python v5.1.1
  • actions/checkout v4.1.7
  • actions/setup-python v5.1.1
  • actions/checkout v4.1.7
  • actions/setup-python v5.1.1
  • actions/checkout v4.1.7
  • actions/setup-python v5.1.1
  • actions/setup-node v4@1e60f620b9541d16bece96c5465dc8ee9832be0b
.github/workflows/lock.yaml
  • dessant/lock-threads v5.0.1
.github/workflows/pr-labels.yaml
  • jesusvasquez333/verify-pr-label-action v1.4.0
.github/workflows/release-drafter.yaml
  • release-drafter/release-drafter v6.0.0
.github/workflows/release.yaml
  • actions/checkout v4.1.7
  • actions/setup-python v5.1.1
.github/workflows/stale.yaml
  • actions/stale v9.0.0
.github/workflows/tests.yaml
  • actions/checkout v4.1.7
  • actions/setup-python v5.1.1
  • actions/upload-artifact v4.3.4
  • actions/checkout v4.1.7
  • actions/download-artifact v4.1.8
  • actions/setup-python v5.1.1
  • codecov/codecov-action v4.5.0
  • SonarSource/sonarcloud-github-action v2.3.0
.github/workflows/typing.yaml
  • actions/checkout v4.1.7
  • actions/setup-python v5.1.1
npm
package.json
  • prettier 3.3.3
nvm
.nvmrc
  • node 20.15.1
pep621
pyproject.toml
  • poetry-core >=1.0.0
poetry
pyproject.toml
  • python ^3.11
  • aiohttp >=3.0.0
  • yarl >=1.6.0
  • aresponses 3.0.0
  • codespell 2.3.0
  • covdefaults 2.3.0
  • coverage 7.6.0
  • mypy 1.10.1
  • pre-commit 3.7.1
  • pre-commit-hooks 4.6.0
  • pylint 3.2.5
  • pytest 8.2.2
  • pytest-asyncio 0.23.7
  • pytest-cov 5.0.0
  • ruff 0.5.2
  • safety 3.2.4
  • yamllint 1.35.1
  • syrupy 4.6.1

  • Check this box to trigger a request for Renovate to run again on this repository

Right way of attribution

Hey @frenck,

Since your projects like python-vehicle and python-twente-milieu are so nicely setup, I kinda borrowed it. I gave you attribution in the readme.md, but was wondering if this is enough or that you think more is needed.

Thanks :)

Tags and version

Problem/Motivation

Tags contains no corresponding version entry in pyproject.toml, e.g., for v0.0.9 version = "0.0.0"

Expected behavior

Having a versioned setup when using the GitHub tags/releases.

Actual behavior

see above

Steps to reproduce

Clone the repo, choose a tag and install it.

Proposed changes

Add current version to pyproject.toml. This help users who are going for the GitHub releases and the distributions which needs to package it as it's a Home Assistant dependency.

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.