Add instructions for updating Google Travel Sensor using service call (#6474)

* Added instructions for updating using automation

* Minor fixes

* ✏️ Spelling/Grammar
This commit is contained in:
Alok Saboo 2018-10-04 08:49:31 -04:00 committed by GitHub
parent fc085b9e93
commit 16edea8fb2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -19,7 +19,7 @@ The `google_travel_time` sensor provides travel time from the [Google Distance M
You need to register for an API key by following the instructions [here](https://github.com/googlemaps/google-maps-services-python#api-keys). You only need to turn on the Distance Matrix API.
[Google now require billing](https://mapsplatform.googleblog.com/2018/05/introducing-google-maps-platform.html) to be enabled (and a valid credit card loaded) to access Google Maps APIs. The Distance Matrix API is billed at US$10 per 1000 requests, however a US$200 per month credit is applied (20,000 requests). By default, the sensor will update the travel time every 5 minutes, making approximately 288 calls per day. Note that at this rate, more than 2 sensors will likely exceed the free credit amount. If you need to run more than 2 sensors, consider changing the [scan interval](/docs/configuration/platform_options/#scan-interval) to something longer than 5 minutes to stay within the free credit limit.
[Google now requires billing](https://mapsplatform.googleblog.com/2018/05/introducing-google-maps-platform.html) to be enabled (and a valid credit card loaded) to access Google Maps APIs. The Distance Matrix API is billed at US$10 per 1000 requests, however, a US$200 per month credit is applied (20,000 requests). By default, the sensor will update the travel time every 5 minutes, making approximately 288 calls per day. Note that at this rate, more than 2 sensors will likely exceed the free credit amount. If you need to run more than 2 sensors, consider changing the [scan interval](/docs/configuration/platform_options/#scan-interval) to something longer than 5 minutes to stay within the free credit limit or update the sensors on-demand using an automation (see example below).
A quota can be set against the API to avoid exceeding the free credit amount. Set the 'Elements per day' to a limit of 645 or less. Details on how to configure a quota can be found [here](https://developers.google.com/maps/documentation/distance-matrix/usage-and-billing#set-caps)
@ -87,5 +87,33 @@ sensor:
- Can also be referenced by just the zone's friendly name found in the attributes.
- **sensor**
- If state is a zone or zone friendly name then will use the zone location
- All other states will be passed directly into the google API
- All other states will be passed directly into the Google API
- This includes all valid locations listed in the *Configuration Variables*
## {% linkable_title Updating sensors on-demand using Automation %}
You can also use the `sensor.google_travel_sensor_update` service to update the sensor on-demand. For example, if you want to update `sensor.morning_commute` every 2 minutes on weekday mornings, you can use the following automation:
```yaml
- id: update_morning_commute_sensor
alias: "Commute - Update morning commute sensor"
initial_state: 'on'
trigger:
- platform: time
minutes: '/2'
seconds: 00
condition:
- condition: time
after: '08:00:00'
before: '11:00:00'
- condition: time
weekday:
- mon
- tue
- wed
- thu
- fri
action:
- service: sensor.google_travel_sensor_update
entity_id: sensor.morning_commute
```