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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Auto-level AirVisual API calls #34903

Merged

Conversation

bachya
Copy link
Contributor

@bachya bachya commented Apr 29, 2020

Proposed change

Users were reporting that monitoring multiple geographies with the same API key overran their free API limits. In the past, this was resolved by setting high scan_interval values, but since this was removed in #32072, users had no route forward.

This PR adds "self-leveling" to the API: the more clients that use the same API key, the greater the interval between API calls. The values are selected to leave plenty of buffer for the typical "free tier" use case.

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)
  • Breaking change (fix/feature causing existing functionality to break)
  • Code quality improvements to existing code or addition of tests

Example entry for configuration.yaml:

# Example configuration.yaml

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
  • 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.
  • Untested files have been added to .coveragerc.

The integration reached or maintains the following Integration Quality Scale:

  • No score or internal
  • 馃 Silver
  • 馃 Gold
  • 馃弳 Platinum

@bachya bachya self-assigned this Apr 29, 2020
@project-bot project-bot bot added this to Needs review in Dev Apr 29, 2020
@project-bot project-bot bot moved this from Needs review to By Code Owner in Dev Apr 29, 2020
@bachya bachya changed the title Airvisual leveling api calls Auto-level AirVisual API calls Apr 29, 2020
@BradleyFord
Copy link

I have updated to 110 beta0.
Within 8 hours I have hit my API limited for the day; I assume there must be some problem with the auto levelling?

@frenck
Copy link
Member

frenck commented May 14, 2020

@BradleyFord This is an open PR, which implements auto-leveling. Since it is open, it is not part of 0.110.

Copy link
Member

@MartinHjelmare MartinHjelmare left a comment

Choose a reason for hiding this comment

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

Looks good!

Dev automation moved this from By Code Owner to Reviewer approved May 21, 2020
@MartinHjelmare MartinHjelmare merged commit f5a326c into home-assistant:dev May 21, 2020
Dev automation moved this from Reviewer approved to Done May 21, 2020
@frenck
Copy link
Member

frenck commented May 21, 2020

@bachya @MartinHjelmare Should we add this to a patch release? As I've seen quite a few people running into the limits... ?

@MartinHjelmare
Copy link
Member

Ok with me.

@MartinHjelmare MartinHjelmare added this to the 0.110.2 milestone May 21, 2020
@bachya bachya deleted the airvisual-leveling-api-calls branch May 21, 2020 13:46
frenck pushed a commit that referenced this pull request May 24, 2020
@frenck frenck mentioned this pull request May 24, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Dev
  
Done
Development

Successfully merging this pull request may close these issues.

Airvisual call_per_month_limit_reached
6 participants