Push Services
Meteobridge provides some additional "push services", which can distribute weather information to you via email, twitter, HTTP requests, FTP uploads, mysql queries or by invoking a user defined script. All these services can be triggered by certain alarm conditions, at a certain time of the day or in periodic intervalls ranging from a few seconds, minutes or hours.
Configuring push services is done in two steps.
- When you want to use a email, twitter, mysql or FTP you have to configure the basic authentification for these services fist.
- Having gone the service configuration you can then define a specific event that makes use of one of the services.
When you first enter this tab has no events defined and looks like this:
Configuration Of Services
The services types twitter, email, mysql and FTP need some configuration before you can make use of it.
Twitter Upload
Meteobridge allows you to send weather data snippets to your twitter account. As twitter requires a bit complicated authentication you will have to run through 5 steps.
Now twitter is ready to be used by events you will define later on.
Sending E-mails
Meteobridge can largely customizable e-mails. To get this service initialized you have to work through the following settings:
- Authentication: This drop-down box allows you to define the authentication mode used with the SMTP server. You can choose between:
- none: This setting does not send any authentication information to the SMTP server. Only servers in closed LANs will provide that (if at all).
- basic: Old-fashioned user name and password authentication, without SSL encryption
- tls: authentication with SSL encryption (a variant not used very often)
- starttls: standard authentication with SSL encryption (most often used)
- SMTP Host: specifies the IP or name of the SMTP server to use.
- Port: port number where SMTP server listens for mails (standard ports are 25 for non-SSL and 587 for SSL communication)
- User: user name to be used for authentication
- Password: password to be used
- To-Addr.: E-mail address of the recipient
- From-Addr.: E-mail address of the sender (many SMTP servers only accept mails with a sender address being in the same domain as the SMTP server itself)
Pressing the "Test" button sends an e-mail with subject "Meteobridge Test" to the given address. If sending the mail does not work, an error message will pop-up, trying to explain what went wrong.
MYSQL Uploads
When you prefer to store your weather station's data in your own MYSQL database, Meteobridge can feed sensor data to it in a very easy way. In order to support MYSQL queries some genric data must be specified.
- Host: server name or IP of server (when DNS can't resolve the name)
- Port: port number where to reach MYSQL database on your server
- Database: name of database to feed
- User: name of database user to use for data upload
- Password: password for user name.
When mysql service is not defined and not used bx events, Meteobridge removes the storage intensive mysql libs during boot. This is indicated by the orange "inactive" sticker. You can still define the mysql server credentials, but it will need an event definition making use of mysql saved and then the Meteobridge rebooted to get the mysql libs ready for operation.
FTP Uploads
Meteobridge allows you define a FTP server that can be bu used for uploading files. Meteobridge can just handle one FTP server, but you can define distinct directories and file names for each upload event later on. Setup of generic FTP upload credentials is done as follows:
- FTP Host: server name or IP of server (when DNS can't resolve the name)
- Port: port number where to reach MYSQL database on your server
- FTP User: user name to be used for FTP upload
- FTP Password: password to be used for FTP upload
In order to check if FTP credentials do work, you can press "Test Upload" button. Meteobridge will upload a file named "test-upload" with current time stamp as content to your FTP server. File will be located at directory that is default when doing FTP login. When you want to test upload to different directories you can specify an path in "Test Path" field. This path is used for test uploads only.
Definition Of Events
Meteobridge allows you to define up to 20 events that make use of push services. You see the list of defined events on the top of this tab.
Adding an event is extremely easy. Just pull down the "Select Service" selector and choose the service type you want to use.
Next choose the type of event you want to define and press "Add Service Event" button.
Having done that a new service event will be added to the list of events and you can specify details of this specific event. Each event definition consist of section where the trigger conditions are specified and a section that defines the payload the event is expected to transport via the service underneath.
Event Types
There are three event types to choose from that can be applied to all push services Meteobridge provides.
Periodical
This allows you to define the interval the event will be triggered. For some services it goes down to every 5 seconds and for the rest it is in the range of minutes up to hours. You simply select the repeating interval by a drop-down list.
Specific Time
Here you can define the time of day when the event has to be triggered. Time can be selected from a drop-down list in 15 minute steps.
Alarm Conditions
This allows you to specify the alarm trigger mode and conditions used for raising and clearing the alarm.
You can choose between "One-Time Alarms" which are triggered once and need to be cleared before they can be fired again, and "Incremental Alarms" which allow a retriggering of a non-cleared alarm, when the triggering event matches "raise condition" by a larger magnitude than the last trigger event.
- Raise Condition: defines the condition to be met in order to fire an alarm. Once an alarm is fired, it will not be fired again until the alarm is cleared again. When you have selected incremental alarms, an alarm can be fired again under certain circumstances. Details on condition statements are explained in "conditions" subsection below.
- Clear Condition: defines condition to be met to clear a fired alarm. Details on condition statements are explained in "Alarm Conditions" subsection below.
There are two type of conditions that are formulated exactly the same way, but have different meaning. If a "raise condition" is satisfied, an alarm will be triggered and sent via e-mail or twitter. To send out the next email, it needs the "clear condition" to be satisfied first. The idea behind that is to suppress a large amount of follow-up messages on an event already given attention. For example, when raise condition is set to "outdoor temp at least 35°C" and clear condition is set to "outdoor temp below 30 °C" and resolution used for comparison is integer level (zero decimals) you will get a message once the temperature reaches 35° but will not get additional messages on that until the temperature has dropped below 30°C again. When you have selected "incremental alarms" and temperature raises from 34°C up to 37.2°C you will get one messages about reaching 35°C, one about reaching 36° and one about reaching 37°C threshold. This gives you the chance to get informed how much the given threshold was passed.
There are two types of condition expressions. The simple one is just comparing two numbers, the complex variant allows for full arithmetic expressions.
Simple Condition Expression
In this case the expression consists of three parts separated by blanks.
- First part is the variable. Variables in conditions are exactly the same as in Meteobridge Templates, so you don't have to learn a new syntax here. While variables in templates are embedded into a pair of square brackets, variables in condition statements don't have that brackets. The raise condition in the example above has varibale definition wind0wind-act=kmh.1:0, which stands for actual non averaged wind speed, converted to km/h with no decimals and when there is no sensor data there, then 0 is taken as speed.
- Second part is a comparison operator. Defined operators are
- = equal, != non equal
- < less than, <= less than or equal
- > greater than, >= greater than or equal
- Third part is a numerical value, which can be integer or float.
Examples:
- wind0wind-act=kmh.1:0 > 10 triggers when current, non-averaged wind speed exceeds 10 km/h
- th0temp-act=c.1:0 < 0 triggers when outdoor temp goes below 0°C
Complex Condition Expression
Complex expressions can make use multiple operators and parantheses. Weather data can be used in terms of Meteobridge variables as exlained in Templates section. Variables need to be in full template-like notation, including the surrounding square brackets. Defined operators are:
Operator | Description |
---|---|
&&, || | logical "and", "or" operators working on value range: 1=true, 0=false |
==, !=, >, >=, <, <= | comparison operations working on value range: 1=true, 0=false |
+, - | arithmetic operators "plus" and "minus" |
*, / | arithmetic operators "multiply" and "divide" |
^ | arithmetic operator "power" |
Result of the expression is interpreted as a boolean. Values above zero are regarded "true", values below or equal zero are regarded "false". When "incremental alarm" is specified, Meteobridge compares new value with former value and does trigger an alarm, when new value is bigger then the one that has triggered an alarm before.
Examples:
- [rain0total-sumday=mm:0] - 10
triggers an alarm when todays rain exceeds 10mm. When alarm mode is set to "incremental alarm", every time rain increases above 10mm, a new alarm will be triggered. This happens because the expression does not return a boolean, but a value that regarded "true" when result is above zero (here, 10mm rain fall). Further increases will keep the condition "true" but will also increment the number and therefore, will fire additional alarms. - [wind0wind-act=kmh.1:0] > 20 && ([wind0dir-act:180] >= 315 || [wind0dir-act:180] <= 45)
triggers an alarm when non-averaged wind speed is more than 20 km/h and wind direction is mainly North (NW-NNW-N-NNE-NE).
Event Deletion
Getting rid of a defined event definition is simply done by pulling down the select box in front of the event definition and to press "save" after that.
Twitter Event
When you define a twitter event you just have to fill the "text message" with the message to be posted. Text message can make full use of Meteobridge template variables. The example below sends out a twitter message every day at noon that contains outdoor temperature in degrees Celsius.
Email Event
When you define an email event to fill the email body text field is mandatory. If the optional "Addr.-To" field is left blank, then the email address from the email service definition at the bottom of the tab is used as default.
In the example above every hour an email is sent out with subject like "weather at 11:23" and a body text like shown below. Please notice that the "#" symbol devides subject from body text.temp 12.3°C gust 6.7kmh
FTP Event
Data to be uploaded via FTP cannot be stored on the Meteobridge as it does not provide the necessary persistent storage capacity. Therefore the templates to be filled with weather data have to reside on a server where Meteobridge can request it from by an URL. When the template URL is specified you have to press "Reload Template" to store the current version of the template into the RAM of the Meteobridge for further use. Beside the URL to the template you also have to define a path that defines to which folder of the FTP server the filled template should be uploaded to.
Example above makes use of a pre-defined dashboard html file and fills it every 10 minutes with recent weather data and uploads it as filename "/public_html/dashboard.html" to the specified FTP server.
FTP Camera Event
If Meteobridge drags pictures from a web cam or an Ubiwuiti AirCam these pictures can also be uploaded via FTP. Here you just have to define the target path and filename, which can include date and time variables as specified by "strftime" GNU C function.
Example above stores a web cam picture every ten minutes and gives it a file name reflecting date and time like "2014-06-23_12:34_weathercam.jpg". Details about "strftime" syntax can be found here.
Advanced Push Services
When you select "Expert Mode" you have additional options to send weather data to. All these services need a server somewhere which can take data from your Meteobridge client. Supported protocols are HTTP-GET, mySQL and FTP.
Individual HTTP Upload
Data will be sent as HTTP GET requests with URL parmeters you can define to your liking. Parameters of a URL consist of name-value pairs seperated by '&'. You can define names yourself and can use a certain set of variables provided by Meteobridge to be used as values. Variable names will be automatically replaced by their current values, each time a HTTP request is sent. Please have a look at the example below.
Upload schedule is defined to every 10 seconds. URL specifies server address, where to deliver data ("http://myserver.com/upload.php" in the example above). "Success Condition" allows to specify a matching string which is compared to to the return message from the server to decide if upload was successful or not.
Weather data is transported to the server by means of URL parameters. Meteobridge provides a large set of variables that can be used to feed URL parameters with current sensor data. Section Templates will explain how to use these variables to fill URL parameters with recent sensor data.
Individual MYSQL Uploads
When you prefre to store your weather station's data in your own MYSQL database, Meteobridge can feed sensor data to it in a very easy way. Just state
- Host: server name or IP of server (when DNS can't resolve the name)
- Port: port number where to reach MYSQL database on your server
- Database: name of database to feed
- User: name of database user to use for data upload
- Password: password for user name.
- Query: payload that should be sent to the database. Query usually contains a MSQL insert statement followed by a table name and a list of column names and values. The query ist subject to template replacement, so you can use Meteobridge variables to upload weather data to your database.
Query insert upload (temp, wind) values ([th0temp-act.1:-9999], [wind0wind-act=kmh.1:-9999]) in example above stores actual outdoor temperature to field "temp" of table "upload" of database "test". Field "wind" is filled with current non averaged wind speed in km/h. When temperature or wind data is not there a value of -9999 is stored.
Details of using variables in templates are explained in Templates section.
In oder to define the payload Meteobridge should upload in regular intervals you have 4 lines to select content. Each line specifies an upload schema determined by three input fields.
- Upload Interval: can have values from "no upload", "once per minute" up to "every hour".
- Template file: this specifies an URL where to find the template in the Internet that Meteobridge should download, fill in weather data and upload to FTP server.
- Path: defines the path where to store the data on the FTP server. Path includes directory and file name in Linux style (separated by "/"). Filename of the template is not used as default, you always have to specify a complete target file name.
To minimize traffic, Meteobridge does not download the referenced template files each time it does prepare a FTP upload. Templates are downloaded once during startup of Meteobridge and stay untouched until you press "Reload Templates" button. When you are working on the design of new templates, don't forget to press the reload button to make template changes effective to Meteobridge.
When you have a Ubiquiti AirCam connected, you can upload weather cam images to your server. In that case no template file needs to be specified, just path for destination on FTP server is needed.
Example above defines an upload schema to FTP server "ftp.myserver.com" for user "myself". Template templates.meteobridge.com/simpledash.html has been loaded on start up of Meteobridge and will be updated with recent data every minute and then uploaded to FTP server as file "mydash.html". When you view "mydash.html" with your browser it looks like this:
Details of using variables in templates are explained in Templates section.
To illustrate that using these varibales is quite easy the HTML body part (omitting the CSS styles for formating it nicely) of the template of above's example is attached below:
<body> <table id="table-2"> <thead><tr><th>Sensor</th> <th>Current</th> <th>Today (min)</th> <th>Today (max)</th></tr></thead> <tbody> <tr><td>Outdoor Temperature</td> <td>[th0temp-act.1:--]° C</td> <td>[th0temp-dmin.1:--]° C</td> <td>[th0temp-dmax.1:--]° C</td></tr> <tr><td>Outdoor Humidity</td> <td>[th0hum-act.0:--] %</td> <td>[th0hum-dmin.0:--] %</td> <td>[th0hum-dmax.0:--] %</td></tr> <tr><td>Outdoor Dew Point</td> <td>[th0dew-act.1:--]° C</td> <td>[th0dew-dmin.1:--]° C</td> <td>[th0dew-dmax.1:--]° C</td></tr> <tr><td>Wind Chill Temperature</td> <td>[wind0chill-act.1:--]° C</td> <td>[wind0chill-dmin.1:--]° C</td> <td>[wind0chill-dmax.1:--]° C</td></tr> <tr><td>Air Pressure</td> <td>[thb0seapress-act.1:--] hPa</td> <td>[thb0seapress-dmin.1:--] hPa</td> <td>[thb0seapress-dmax.1:--] hPa</td></tr> <tr><td>Wind Direction</td> <td>[wind0dir-act.0:--]°</td> <td></td><td></td></tr> <tr><td>Wind Speed (averaged)</td> <td>[wind0avgwind-act.1:--] m/s</td> <td>[wind0avgwind-dmin.1:--] m/s</td> <td>[wind0avgwind-dmax.1:--] m/s</td></tr> <tr><td>Gust Speed</td> <td>[wind0wind-max5.1:--] m/s</td> <td>[wind0wind-dmin.1:--] m/s</td> <td>[wind0wind-dmax.1:--] m/s</td></tr> <tr><td>Rain</td> <td>rate: [rain0rate-act.1:--] mm/h</td> <td>sum [rain0total-sumday.1:--] mm</td> <td></td></tr> <tr><td>Solar Radiation</td> <td>[sol0rad-act.0:--] W/qm</td> <td>[sol0rad-dmin.0:--] W/qm</td> <td>[sol0rad-dmax.0:--] W/qm</td></tr> <tr><td>UV Index</td> <td>[uv0index-act.1:--] uvi</td> <td>[uv0index-dmin.1:--] uvi</td> <td>[uv0index-dmax.1:--] uvi</td></tr> </tbody> </table> </body>
Saratoga Template Upload
Meteobridge is supported by the well-known Saratoga templates, which allow you to easily build your own powerfull weather homepage. Procedure how to install the php scripts an how to configure Meteobridge's FTP upload is described in detail here.
When having done the well explained and easy to do setup, your website will look like this:
Individual Script Invocation
Meteobridge allows to execute user-defined bash scripts. The script has to be available on a web server. Meteobridge downloads the script via a given URL. Each time the trigger interval is fired, weather variables inside the script are replaced by current values and the script is executed. A parameter line can be used to hand over user-defined parameters to the script. This kind of script invocation allows Meteobridge not only fire user-defined actions on the Meteobridge itself but the even more interesting thing is, that by have "wgets" placed in the script this can also initiate actions in the Internet. This does give additional freedom to let your Meteobridge act on weather conditions and to trigger events outside Meteobridge as well. "Reload" button does load script from Internet and "Test" button does a test invocation to check if the script runs fine or thows some errors.
Settings above define to trigger script stored at "http://templates.meteobridge.com/reboot.sh" every day at 23:20. There are no paramters to be handed over to the script. The script provides a one-line documentation, which is marked in the script by three leading '#'. As you can see the script below does mainly issue a "reboot" of the Meteobridge.
#!/bin/sh # ### reboot Meteobridge; no parms reboot exit 0