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

Use SCAN_INTERVAL instead of Throttle for google travel time #31420

Merged
merged 1 commit into from
Mar 5, 2020

Conversation

shidarin
Copy link

@shidarin shidarin commented Feb 2, 2020

Proposed change

The documentation for google_travel_time was at odds with the implementation. The documentation stated a default scan time of 5 minutes, but the implementation was using Throttle which resulted in the sensor updating at a maximum rate of one API call every 5 minutes. This was especially at odds with a given example at the end of the documentation, which showed updating the sensor every 2 minutes during commute times.

This change brings the implementation in line with the docs by adopting the SCAN_INTERVAL constant set to the stated default of 5 minutes and removing the Throttle.

This PR maintains the current default of 5 minutes, but fixes the bug where lower scan_intervals would not be respected.

In fixing this issue I also looked at #31167 which adds scan_interval support for the NUT integration. I'm unclear if this, or that approach is the preferred implementation method.

Also of note is that I've completely removed the Throttle here. Given that this uses a Google Cloud platform API which could result in user charges, I considered keeping a Throttle set to 15 seconds or so to limit potential damage. This can be easily added if requested.

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:

This code snippet will now work- updating once a minute.

sensor:
  - platform: google_travel_time
    name: Home to Work
    api_key: #big secret
    origin: Address
    destination: Another address
    scan_interval: 60

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.

No tests exist for this integration.

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

As this PR brings the code up to matching the documentation, docs did not need updating.

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

…t#31384)

The documentation for google_travel_time was at odds with the
implementation. The documentation stated a default scan time of
5 minutes, but the implementation was using Throttle which resulted
in the sensor updating at a maximum rate of one API call every
5 minutes. This was especially at odds with a given example at
the end of the documentation, which showed updating the sensor
every 2 minutes during commute times.

This change brings the implementation in line with the docs by
adopting the `SCAN_INTERVAL` constant set to the stated default
of 5 minutes and removing the Throttle.
@probot-home-assistant
Copy link

Hey there @robbiet480, mind taking a look at this pull request as its been labeled with a integration (google_travel_time) you are listed as a codeowner for? Thanks!

@MartinHjelmare MartinHjelmare changed the title google_travel_time - SCAN_INTERVAL instead of Throttle (#31384) Use SCAN_INTERVAL instead of Throttle for google travel time Feb 2, 2020
Copy link
Contributor

@elupus elupus left a comment

Choose a reason for hiding this comment

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

Non-maintainer ok.

@balloob balloob merged commit 2d3b117 into home-assistant:dev Mar 5, 2020
@lock lock bot locked and limited conversation to collaborators Mar 10, 2020
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.

google_travel_time implementation at odds with documentation
5 participants