MeteoTemplate Plugin : TRIGGERS
1-Overview
2-Installation
3-Setup a Cron job
4-Configuration
1 - Overview
The Triggers plugin allows a Meteotemplate site administrator to create a serie of conditions based on variables from the site.
These conditions will be evaluated at regular interval and their status (True or Fase) will be store for later use by other Plugins (like the Notifications section of the App plugin)
2 - Installation
The triggers plugins is installed as any other Meteotemplate plugin:
3 - Setup a Cron job
The page updateTriggers.php must be called at regular interval.
For this, we will use a cron job. You can use the cron functionnality of your site (if it has it) or use an external tool.
The example below is taken from
cron-job.org, the exernal tool I uses for scheduling tasks related to MeteoTemplate
The url pointing to the page should include your update password : https://www.mymeteotemplatepage.com/template/plugins/triggers/updateTriggers.php?password=YourPassword
4
- Configuration
- Go to the "Configure Plugins" section of your Meteotemplate administration panel
- Click on the "Edit Settings" link on the right of the triggers row
- The first part of the setup page displays a list of variables available to be used in the Triggers.
This list will be extended over time to add the datapoint you need or depending on the blocks or plugin you may have installed.
For now, it only displays the content of the meteotemplateLive.txt (and the duration of your configured routes if you have installed the TrafficAlert block)
As an example, you can use %%T for the current temperature or %%H for the current humidity, etc.
- Click on the "Add a Trigger" button. A new trigger will be added to the list :
- Id : Enter a unique identifier. (eg TempHigh)
- Display name : Enter a meaningful name that will be displayed in other plugins (eg High Temperature)
- Enabled/Disable : if disable, the trigger will not be processed by the cron job (and the panel where you enter the condition will be hidden)
- Delete : will delete the trigger. Note that you can only delete the last trigger. ( So if you need to delete the first one, you have to delete them all. Better to just disable it in this case)
- Description : Enter short description that explains the condition (eg Temperature is higher than 30 degrees)
- Condition : Enter a condition that will return true or false. Use the PHP syntaxis (&& for and operator, || for or operator, == for =, >, <, etc)
You can use any variable displayed in the first section of the page to build your condition (remember to put "%%" before the variable, like %%W for wind).
You can keep it simple (like %%T>30 ) or make it more complex (like ((%%T>30) && (%%T<35)) && ((%%RR>10) || (%%R>30)). Your call.
When you are satisfied with your condition, you can test it by Clicking on the "Test Condition" button. The result on the right will then display True or False.
- Click on Save