Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add authorisation functionality to OpenSky Integration #91162

Closed
wants to merge 6 commits into from

Conversation

OzGav
Copy link
Contributor

@OzGav OzGav commented Apr 10, 2023

Breaking change

Users of the integration must now supply a username and password. Currently anonymous users only get 400API calls per day which equates to one every 3.6 minutes which isn't useful when tracking aircraft. Registered users are allowed 4000 requests per day or one every 21.6 seconds. Therefore, the integration is only useful for registered users and thus there is now a requirement to supply credentials.

Proposed change

The integration currently makes an API call every 12 seconds which will result in the 400 API calls allowed being exhausted after 80 minutes. The integration will then crash when JSON is not returned. This fault has been the subject of numerous issues over the last few years. The most recent is here #45453
This PR adds the ability to enter a username and password into the config and then authorise the session.

Type of change

  • Dependency upgrade
  • Bugfix (non-breaking change which fixes an issue)
  • New integration (thank you!)
  • New feature (which adds functionality to an existing integration)
  • Deprecation (breaking change to happen in the future)
  • Breaking change (fix/feature causing existing functionality to break)
  • Code quality improvements to existing code or addition of tests

Additional information

Checklist

  • The code change is tested and works locally.
  • Local tests pass. Your PR cannot be merged unless tests pass
  • There is no commented out code in this PR.
  • I have followed the development checklist
  • I have followed the perfect PR recommendations
  • The code has been formatted using Black (black --fast homeassistant tests)
  • Tests have been added to verify that the new code works.

If user exposed functionality or configuration variables are added/changed:

If the code communicates with devices, web services, or third-party tools:

  • The manifest file has all fields filled out correctly.
    Updated and included derived files by running: python3 -m script.hassfest.
  • New or updated dependencies have been added to requirements_all.txt.
    Updated by running python3 -m script.gen_requirements_all.
  • For the updated dependencies - a link to the changelog, or at minimum a diff between library versions is added to the PR description.
  • Untested files have been added to .coveragerc.

To help with the load of incoming pull requests:

OzGav added 5 commits April 9, 2023 07:56
Add username and password to allow more requests per day
Changed to require authentication as the API daily limit for non registered accounts had rendered the integration unusable
Removed a logging line. Added OPENSKY_URL
@OzGav
Copy link
Contributor Author

OzGav commented Apr 10, 2023

I'm new at this but this simple change is working well for me

Comment on lines +71 to +72
vol.Required(CONF_USERNAME): cv.string,
vol.Required(CONF_PASSWORD): cv.string,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We no longer allow integrations to add or change a platform YAML configuration.

More information on this can be found in Architecture Decision Record:

Please note that this integration connects to a device or service and another Architecture Decision Record applies that disallows the use of YAML configuration in favor of a configuration flow via the UI:

See our developer documentation on how to get started creating a configuration flow for this integration:

https://developers.home-assistant.io/docs/config_entries_config_flow_handler

As these changes often involve a bit of work and some significant shift in the current code, we will close this PR for now.

We (and our community!) would really appreciate it if you could start on the refactoring of this integration in a new PR.

Thanks already! 👍

@frenck frenck closed this Apr 11, 2023
@OzGav
Copy link
Contributor Author

OzGav commented Apr 11, 2023

Yeah sorry @frenck i don’t think I have the technical skills to do the refactor…..

@github-actions github-actions bot locked and limited conversation to collaborators Apr 12, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants