WARNING: Users who have this template already installed for versions of OH 5.1 and before, after removing the old template and installing this new one, open your rule(s), click on the code tab, and change the ruleTemplate property to ohrt-driveTime before regenerating the rule.
This rule template uses the Waze RoutingManager API to query for and calculate the time and distance to drive between two points. My original idea for this template was to get an alert in the mornings so we know when to leave early because there’s yet another accident on the interstate.
The template has four properties:
- starting coordinates in “lat,lon” format
- ending coordinates in “lat,lon” format
Number:TimeItem that will be updated with the current driving timeNumber:LengthItem that will be updated with the current driving distance
This rule template does not have any triggers or conditions. To avoid hammering the Waze servers this rule remains inert until you further add your own triggers and conditions. I recommend a polling period in minutes at the most and adding conditions so the rule does not run at times when it’s not needed.
If more than one route is desired, create multiple rules using this template, one for each route.
When regenerating your rule from the template, don’t forget to restore your trigger. Alternatively you can create a separate rule that calls this rule and implement the trigger there.
Language: JS Scripting
Dependencies:
- JS Scripting add-on installed: Version: 5.18.2+
- Future versions may depend on OHRT
Changelog
Version 1.0
- migrated to the YAML file format for OH 5.2
- use the wrapper
- standardize the logger names
Version 0.4
- the region property had two options with the same mapping which caused problems, those two options were merged to avoid the problem
Version 0.3
- changed to use Waze’s new URLs
- minor changes to make URL generation based on region easier
- moved code to github
Version 0.2
- added property to choose region to avoid Internal Error problems for users outside the US
- changed the logger name and added more logging at the debug and trace levels
- added better error checking and reporting
Version 0.1
- initial release
