Hi everybody,
As one of you asked about the trafficAlert Block and the app notifications, I thought I should give a
small update on the topic.
CACHE
First of all, those interested should download and install the latest version of the trafficAlert block :
https://www.elspinars.es/dev/trafficAlert.zip (you will keep your settings)
Since the previous publication, one significant element that happened is that Google started to ask for a Billing account to provide services, even if you were using only the free services (
check this post ).
As the trafficAlert block relies on the Google Directions API, I had no choice but to surrender and give Google my credit card number. But I worried about what would happen if too many visitors refresh my page to see the traffic block. Each refresh is at least one call to Google Directions (7 in my case) and so far, I have a quota of 2500 requests daily (it is not clear what happens if I go over quota. Before, it just returned an error. Now, it may digg a big hole in my bank account).
So I finally implemented a cache for this block.
For each route you define, you can decide how long the data will be considered valid before asking again to Google for fresh data.
This is defined in the field Cache delay next to the route name :

In the example above, any visitor requesting my page will be served cached data if this data was created less than 9 minutes ago.
Each route can have a different cache delay.
Note that to use the trafficAlert block, you need to have a valid Google Maps Key (referrer restricted) assigned to your site in the install folder of meteotemplate, file googleMapsKey.txt (Usually, everybody does create one whn installing MT for the first time. If you don't, go to
https://console.developers.google.com and create one ).
TRIGGERS & TRAFFIC ALERT
The triggers plugin is one essential component to be able to send notifications through the
Android App
The latest version is available here :
https://www.elspinars.es/dev/triggers.zip
The triggers plugin will aggregate a list of variables from your site and make these variable available to create conditions, that will be tested at regular interval.
To get the variables. in addition to the common data points from meteotemplateLive file like temp, rain, etc, the triggers plugin will scan the blocks and plugins to check if they are compatible and retrieve the corresponding variables.
At that point in time, only the trafficAlert block is compatible
The trafficAlert block will provide two variables per route : the duration of the route in current traffic, in seconds, and the same duration formatted in hours,min,sec.
To be able to provide this data, the block relies once again on Google Directions, with one big difference : it is now calling the service from your server and not from the visitors web browser. To allow calls from your server, Google will request that you have an IP Restricted Key (remember that the one you already created was restricted on the referrer, usually your domain name, not the IP of your server).
So for trafficAlert to work with triggers, you must once again log into Google Developer Console, create a new API Key and restrict it to your server IP address.
When you have your newly created IP Restricted key, copy paste it in a file called googleMapsIPRestrictedKey.txt and place it in the install folder of your meteotemplate site.
Now that you have your API key, every time the cron you have set up for triggers is executed, the variables related to trafficAlert are refreshed (except if they are still valid in the cache, see above) :

For each route, you get two variables, both starting by the prefix %%Traffic followed by the route name.
%%TrafficRouteName is returning the duration of the route in seconds, %%TrafficRouteNameText is returning the same data formatted in hrs,min,sec
You can now use these variables to create your own triggers that you will later use to send notifications to your users through the app :
APP & TRAFFIC ALERT
You have your trafficAlert block installed, your triggers are working, now you want to send alerts to your users through the app.
First, check that you have downloaded and installed the latest version of the app plugin :
https://www.elspinars.es/dev/appPlugin.zip
Also
contact me to add your site to the list of sites proposed in the beta version
Second : download the latest beta version of the app :
https://play.google.com/apps/testing/co ... eotemplate
Third : invite your visitors to test the app by installing this simple small block on your homepage :
https://www.elspinars.es/dev/appBlock.zip
Now you can access the app plugin setup (through the Configure Plugins menu, as for any other plugin) and you can start configuring your notifications :

In the message of your notification, you can include variables that are available through the trigger plugin.
Note that in the message, the variables must be enclosed by %% both at the beginning and att the end (like %%TrafficVarianteText%% in the example above. This differs from the way the variable are used in the triggers plugin (where you only prefix the variable with %%, like %%TrafficVariante )
Next to the action filed (which you will probably set to trafficAlert), there is a new field called parameters.
This allows to send parameters to the block that will be displayed in the app. (so far, only trafficAlert block isusing this

)
In our case, we can put the name of the route as parameters (in the example above, my route is called Variante).
This way, when the block is called with the route parameter, only this route will be displayed in the block (independently of how many routes you have configured and set visible in the trafficAlert block setup)
Note that you can use as a parameter a route that is not set to visible in the normal block.
Sorry that it is such a long post, it is the price to pay for the lack of documentation (I will try to improve in that area. I started in the triggers plugin, click on the question mark icon in the header...)
These days, most of the free time I can set apart for this hobby is dedicated to improve the beta version of the app and its corresponding plugin but if there are people interested in the trafficAlert block that want to provide feedback, please do so.
Cheers,
Pol-Brieuc
PS : Keep visiting the
post on the Android App to get the latest news about this experimental side project