Use SCAN_INTERVAL instead of Throttle for google travel time #31420
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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_interval
s 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
Example entry for
configuration.yaml
:This code snippet will now work- updating once a minute.
Additional information
Checklist
black --fast homeassistant tests
)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:
Updated and included derived files by running:
python3 -m script.hassfest
.requirements_all.txt
.Updated by running
python3 -m script.gen_requirements_all
..coveragerc
.The integration reached or maintains the following Integration Quality Scale: