Difference between pages "Push Services" and "Templates"

From meteoplug
(Difference between pages)
Jump to: navigation, search
(Saratoga Template Upload)
 
(Marked this version for translation)
 
Line 2: Line 2:
 
<languages /><translate>
 
<languages /><translate>
 
<!--T:1-->
 
<!--T:1-->
<br />Meteobridge provides some additional "push services", which can distribute weather information to you via email, or to your twitter acoount. When you have email or twitter configured, Meteobridge can send alarms to you when a certain weather condition is met.  
+
<br />Meteobridge provides a very flexible mechanism to smuggle sensor data of different kinds into strings to be used by Meteobrdge push services like Twitter, HTTP GET uploads or MSQL database insert requests.
 +
Simply type in the text you want to upload and represent the pieces of sensor data by so called variables. When data gets uploaded, these variables will be replaced by current sensor data and so a string filled with the data you intended will be uploaded.
  
 
<!--T:2-->
 
<!--T:2-->
When you select "Expert Mode" you will be offered additional upload options like upload to a Web server via HTPP Get or via FTP and even direct connection to a mySQL database. To keep things simple, we recommand to leave "Expert Mode" flag unmarked unless you really need these more sophisticated options.
+
Each variable starts with an opening square bracket "[" and is terminated by a closing square bracket "]". The structure of the variable name between these brackets is as follows: <pre>sensor-selector=converter.decimals:replacement</pre>
 +
"converter", "decimals" and "replacement" can be omitted, "sensor" and "type" are mandatory.
 +
While "sensor" tells what sensor and what piece of information of the sensor to use, "selector" decides data from what time period should be taken into account and "converter" does convert data into measurement units the user likes most. "Decimals" decides about precision the result should be shown in and "replacement" gives the string to be returned when there is no data for defined sensor available.
  
<!--T:3-->
+
==Sensors== <!--T:3-->
The following sections will explain how to setup push services in detail. These options are a bit more for the tech-savvy user, but they are not mandatory for Meteobridge's core task, to feed weather data to weather networks. So you can keep that all switched off, when you don't need it.  
+
These sensors are defined in Meteobridge.
 +
* '''th0temp''': outdoor temperature in degrees Celsius
 +
* '''th0hum''': relative outdoor humidity as percentage
 +
* '''th0dew''': outdoor dew point in degrees Celsius
 +
* '''thb0temp''': indoor temperature in degrees Celsius
 +
* '''thb0hum''': indoor humidity as percentage
 +
* '''thb0dew''': indoor dewpoint in degrees Celsius
 +
* '''thb0press''': station pressure in hPa
 +
* '''thb0seapress''': normalized pressure (computed to sea level) in hPa
 +
* '''wind0wind''': wind speed in m/s
 +
* '''wind0avgwind''': average windspeed in m/s (time used for average depends on station)
 +
* '''wind0dir''': wind direction in degress (0° is North)
 +
* '''wind0chill''': wind chill temperature in degrees Celsius
 +
* '''rain0rate''': rain rate in mm/h
 +
* '''rain0total''': rain fall in mm
 +
* '''uv0index''': uv index
 +
* '''sol0rad''': solar radiation in W/m^2
 +
If a sensor is not there or data of sensor has passed the "tolerated data age" interval, Meteobridge will not provide data for it and will present the value defined as "replacement". If no replacement is given, variable will not be converted into data but will stay as is.
  
==Basic Push Services== <!--T:4-->
+
==Selectors== <!--T:4-->
We 'll start with three basic push services that can send weather data an a regular schedule or triggered by events to your email address or twitter account.
+
Sensors are followed by a selector (syntactically separated by a dash) that specifies what period in time should be used for evaluation. Valid selectors are:
 +
* '''act''': most recent data
 +
* '''hmin''': minimum value of this hour
 +
* '''hmax''': maximum value of this hour
 +
* '''dmin''': minimum value of today
 +
* '''dmax''': maximum value of today
 +
* '''ydmin''': minimum value of yesterday
 +
* '''ydmax''': maximum value of yesterday
 +
* '''mmin''': minimum value of this month
 +
* '''mmax''': maximum value of this month
 +
* '''ymin''': minimum value of this year
 +
* '''ymax''': maximum value of this year
 +
* '''amin''': minimum value of all time
 +
* '''amax''': maximum value of all time
 +
* '''daysum or sumday''', '''monthsum''', '''yearsum''', '''allsum''', '''ydaysum''': selects summerized delta values from today, this month, this year, all time or yesterday: "rain0total-sumday" is todays rain fall.
  
 +
<!--T:13-->
 +
When you are interested in timestamps of min/max values, you can make use of these selectors:
 +
* '''hmintime''': timestamp of minimum value of this hour
 +
* '''hmaxtime''': timestamp of maximum value of this hour
 +
* '''dmintime''': timestamp of minimum value of today
 +
* '''dmaxtime''': timestamp of maximum value of today
 +
* '''ydmintime''': timestamp of minimum value of yesterday
 +
* '''ydmaxtime''': timestamp of maximum value of yesterday
 +
* '''mmintime''': timestamp of minimum value of this month
 +
* '''mmaxtime''': timestamp of maximum value of this month
 +
* '''ymintime''': timestamp of minimum value of this year
 +
* '''ymaxtime''': timestamp of maximum value of this year
 +
* '''amintime''': timestamp of minimum value of all time
 +
* '''amaxtime''': timestamp of maximum value of all time
 +
* '''starttime''': timestamp of first recorded value
 +
Timestamps are strings of format "YYYYMMDDhhmmss". Year "YYYY" is reported in 4 digits, all other values (month "MM", day "DD", hour "hh", minute "mm", second "ss") come with 2 digits, leading zeros are not supressed.
  
 
<!--T:5-->
 
<!--T:5-->
[[File:page6.png]]
+
Apart from selectors that use absolute, predefined time slots there are also selectors that look for a certain amount of time into the past.
 
+
* '''val2''', '''val5''', '''val10''', '''val15''', '''val30''', '''val60''': selects the value the sensor has shown 2, 5, 10, 15, 30 or 60 minutes ago
 
+
* '''max2''', '''max5''', '''max10''', '''max15''', '''max30''', '''max60''': selects the maximum value from the last 2, 5, 10, 15, 30 or 60 minutes
===Twitter Upload=== <!--T:6-->
+
* '''min2''', '''min5''', '''min10''', '''min15''', '''min30''', '''min60''': selects the minimum value from the last 2, 5, 10, 15, 30 or 60 minutes
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 6 steps.
+
* '''avg2''', '''avg5''', '''avg10''', '''avg15''', '''avg30''', '''avg60''': selects average value from the last 2, 5, 10, 15, 30 or 60 minutes
 
+
* '''sum2''', '''sum5''', '''sum10''', '''sum15''', '''sum30''', '''sum60''': selects summerized delta values from the last 2, 5, 10, 15, 30 or 60 minutes, which is useful to get amount of total rain in a certain time frame: "rain0total-sum60" is rainfall im mm of last 60 minutes.
<!--T:7-->
+
<gallery perrow=1 widths=500 heigths=350>
+
File:twitter0.png|1. Press "Request PIN" button.
+
File:twitter2.png|2. An additional window will pop-up (please make sure your browser's pop-up blocker does not block it!) where twitter asks you to log-in to your twitter account.
+
File:twitter2b.png|3. Please log-in and copy the pin that twitter does present to you.
+
File:twitter4.png|4. Switch back to Meteobridge page and Insert pin into input field next to "Activate PIN" button and press this button.
+
File:twitter3.png|5. Finally, insert message text that Meteobridge should tweet and set upload interval and retry count and press save to make these settings permanent. If Authentification with twitter does fail, you can start process with pressing "Request new PIN" from the start.
+
File:twitter5.png|6. To fill message text with weather data and/or a timestamp, you can make use of Meteobridge variables as explained in [[Templates]] section. Example above is a result of this message text: <font face="Courier"><span style="background-color:lightgrey;">[hh]:[mm]h Outdoor temp: [th0temp-act=F.1:--]°F </span></font face>
+
</gallery>
+
 
+
 
+
===Individual E-mail Service=== <!--T:8-->
+
Meteobridge can send you customizable e-mails at certain time intervals. To get this service started you have to work through the following settings:
+
* '''Send Interval''': defines how often the e-mail should be sent. If you don't want to send weather data on regular schedule but want to send e-mails just on alarm conditions, set this to "on alarm only". Drop-down box next to this on the right allows you to choose how many e-mail send retries should be done in case e-mail sending does fail. Next drop-down box allows you to defne how authorization of the SMTP server that transports the e-mail into the Internet should be done. You 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)
+
* '''Body''': This contains the text to be sent via email. You can use a '#' sign to separate subject from the body of the mail. This string is subject to template replacement and does allow you to use Meteobridge variables inside your e-mail.
+
 
+
<!--T:9-->
+
The test button in the "SMTP Host" line does send an e-mail with subject "Meteobridge Test" to the given address. If sendig the mail does not work, an error message will pop-up, explaining what went wrong.
+
 
+
 
+
<!--T:10-->
+
[[File:email0.png]]
+
 
+
 
+
<!--T:11-->
+
Body <font face="Courier"><span style="background-color:lightgrey;">weather conditions#temp [th0temp-act.1:--]°C\n[wind0wind-max60=kmh.1:--]km/h</span></font face> in example above generates an e-mail with subject "weather conditions" and a body containing two lines (separated by a line feed character "\n"). First line will report current outdoor temperature like "13.4°C" and second line will report max gust speed during last hour, like "34.7km/h". Details of using variables in templates are explained in [[Templates]] section.
+
 
+
===Alarm Service=== <!--T:12-->
+
Meteobridge can send you an e-mail or twitter message when a certain sensor condition is met. To have this feature activated, as least on of the services "e-mail " or "twitter" must be configured correctly. Alarm services makes use of the e-mail and twitter settings and does not provide seperate credentials for these services.
+
The fields in the screen dump below have this meaning:
+
* '''Alarm Mode''': can be "disabled", "send e-mail" or "send twitter". In addition 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 "conditions" subsection below.
+
* '''Message''': defines the email or twitter text to send. This text is subject to Meteobridge's template replacement mechanism and is handled as already lined out for e-mail and twitter services.
+
 
+
<!--T:13-->
+
[[File:alarm0.png]]
+
  
 +
==Converters== <!--T:6-->
 +
Sensor data is reported in ISO units (°C, hPa, mm, m/s) by default, but can be converted into non-ISO units (imperial) by adding a conversion token. Defined tokens are:
 +
* '''F''' converts temperature from Celsius to Fahrenheit.
 +
* '''psi''' converts pressure from hPa (equivalent to mbar) to psi.
 +
* '''mmHg''' converts pressure from hPa to millimeters of mercury.
 +
* '''inHg''' converts pressure from hPa to inches of mercury.
 +
* '''kmh''' converts wind speed from meters per second to kilometers per hour.
 +
* '''mph''' converts wind speed from meters per second to miles per hour.
 +
* '''kn''' converts wind speed from meters per second to knots.
 +
* '''bft''' converts wind speed from meters per second to Beaufort scale.
 +
* '''in''' converts millimeters to inches.
 +
* '''ft''' converts meters to feet.
 +
If an unknown conversion string is used, no conversion will take place, no error message will appear.
  
 
<!--T:14-->
 
<!--T:14-->
Body <font face="Courier"><span style="background-color:lightgrey;">Gust Warning#Gust speed of [wind0wind-act=kmh.1:--]km/h</span></font face> in example above generates an e-mail with subject "Gust Warning" and a body containing a line like "Gust speed of 65.2km/h", when raise condition in example of gust speeds greater 50 km/h is met.
+
When variable returns a timestamp, then this converter can be applied:
 +
* '''utc''' reports timestamp in UTC instead of localtime, which is default.
  
====Conditions==== <!--T:15-->
+
==System Variables== <!--T:16-->
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 habe 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.  
+
Meteobridge provides some additional variables that tell details not directly related to weather conditions. Sensor name is "mbsystem", defined selectors are:
 +
* '''swversion''': Meteobridge version string (example: "1.1")
 +
* '''buildnum''': build number as integer (example: 1673)
 +
* '''platform''': string that specifies hw platform (example: "TL-MR3020")
 +
* '''language''': language used on Meteobridge's web interface (example: "English")
 +
* '''timezone''': defined timezone (example: "Europe/Berlin")
 +
* '''latitude''': latitude as float (example: 53.875120)
 +
* '''longitude''': longitude as float (example: 9.885357)
 +
* '''lunarage''': days passes since new moon as integer (example: 28)
 +
* '''lunarpercent''': lunarphase given as percentage from 0% (new moon) to 100% (full moon)
 +
* '''lunarsegment''': lunarpahse segment as integer (expample: 0)
 +
* '''daylength''': length of day (example: "11:28")
 +
* '''civildaylength''': alternative method for daylength computation (example: "12:38")
 +
* '''nauticaldaylength''': alternative method for daylength computation (example: "14:00")
 +
* '''sunrise''': time of sunrise in local time. Can be converterd to UTC by applying "=utc" to the variable (example: "06:47", resp. "05:47")
 +
* '''sunset'''. time of sunset in local time. Can be converterd to UTC by applying "=utc" to the variable (example: "18:15", resp. "17:15")
 +
* '''civilsunrise''', '''civilsunset''', '''nauticalsunrise''', '''nauticalsunset''': alternative computations for sunset and sunrise.
 +
* '''daynightflag''': returns "D" when there is daylight, otherwise "N".
 +
* '''moonrise''': time of moonrise in local time. Can be converterd to UTC by applying "=utc" to the variable. Please notice that not every day has a moonrise time, therefore, variable can be non-existent on certain days (example: "05:46", resp. "04:46")
 +
* '''moonset''': time of moonset in local time. Can be converterd to UTC by applying "=utc" to the variable. Please notice that not every day has a moonset time, therefore, variable can be non-existent on certain days (example: "17:00", resp. "16:00")
  
<!--T:16-->
+
==Time/Date Variables== <!--T:7-->
Condition statements consist of three parts separated by blanks.
+
Variables representing current date/time don't come as "sensor-selector=converter" chains but have a distinct meaning by themselves.
  
<!--T:17-->
+
<!--T:8-->
* 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 <font face="Courier"><span style="background-color:lightgrey;">wind0wind-act=kmh.1:0</span></font face>, 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.
+
Date und time variables are defined as follows:
 +
* '''YYYY''': year as four digit number
 +
* '''YY''': year as two digit number
 +
* '''MM''': month as two digit number, if only one digit neede a zero will be used as first digit
 +
* '''M''': month as one or two digit number, no leading zeros
 +
* '''DD''': day of month as two digit number, if only one digit neede a zero will be used as first digit
 +
* '''D''': day of month as one or two digit number, no leading zeros
 +
* '''hh''': hour as two digit number, if only one digit neede a zero will be used as first digit
 +
* '''h''': hour as one or two digit number, no leading zeros
 +
* '''mm''': minute as two digit number, if only one digit neede a zero will be used as first digit
 +
* '''m''': minute as one or two digit number, no leading zeros
 +
* '''ss''': seconds as two digit number, if only one digit neede a zero will be used as first digit
 +
* '''s''': seconds as one or two digit number, no leading zeros
 +
When a capital "U" preceeds a date/time variable name, UTC is used instead of local time ("[Uhh]:[Umm]:[Uss] UTC" is evaluated to a string like "16:03:33 UTC")
  
<!--T:18-->
+
==Decimals== <!--T:9-->
* Second part is a '''comparison operator'''. Defined operators are
+
Unless otherwise defined numbers are reported with one decimal. By specifying a value for "decimals" you can determine resolution of presented values.
** '''=''' equal, '''!=''' non equal
+
** '''<''' less than, '''<=''' less than or equal
+
** '''>''' greater than, '''>=''' greater than or equal
+
  
<!--T:19-->
+
<!--T:15-->
* Third part is a '''numerical value''', which can be integer or float.
+
When variable returns a string instead of a number (in case of a timestamp for example), "decimal" specification does have a different format and meaning, which allows to select a substring. Specification of the substring consists of two lower-case letters. The first one specifies start point of the substring, second leter the position of last character of the string to be reported. For example, when string is timestamp "20130303121055" a specification of ".ad" selects a substring from first character (position code "a") until fourth character (position code "d"). When you want to grab the time for lowest outdoor temperature of today the template for that will be <font face="Courier"><span style="background-color:lightgrey;">[th0temp-dmintime.ij:--]:[th0temp-dmintime.kl:--]</span></font face>. "ij" selects the hour part at position 9-10 and "kl" selects minute part at position 11-12 of the timestamp.
  
==Advanced Push Services== <!--T:20-->
+
==Replacement== <!--T:10-->
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.  
+
When a variable is not defined or there is no data for a specified sensor, information specified as "replacement" string will be represented instead.
  
 +
==Examples== <!--T:11-->
 +
Having a look at examples usually helps to understand how easy that is.
  
<!--T:21-->
+
<!--T:12-->
[[File:page6b.png]]
+
# Template <font face="Courier"><span style="background-color:lightgrey;">Outdoor temperature is [th0temp-act=F.1:--]°F</span></font face> will be converted into <font face="Courier"><span style="background-color:lightgrey;">Outdoor temperature is 3.4°F</span></font face> when there is outdoor temp data and into <font face="Courier"><span style="background-color:lightgrey;">Outdoor temperature is --°F</span></font face> if outdoor temp sensor does not provide recent data.
 
+
# Template <font face="Courier"><span style="background-color:lightgrey;">Local time is [hh]:[mm]</span></font face> will be converted into <font face="Courier"><span style="background-color:lightgrey;">Local time is 09:27</span></font face>.
 
+
# Template <font face="Courier"><span style="background-color:lightgrey;">Max gust in last 10 minutes was: [wind0wind-max10.1:--]m/s, [wind0wind-max10=mph.1:--]mph, [wind0wind-max10=kn.0:--]kn</span></font face> will be converted into <font face="Courier"><span style="background-color:lightgrey;">Max gust in last 10 minutes was: 10.5m/s, 23.5mph, 20kn</span></font face>.
===Individual HTTP Upload=== <!--T:22-->
+
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.
+
 
+
 
+
<!--T:23-->
+
[[file:http-upload.png]]
+
 
+
 
+
<!--T:24-->
+
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.
+
 
+
<!--T:25-->
+
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=== <!--T:26-->
+
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.
+
 
+
 
+
<!--T:27-->
+
[[File:mysql.png]]
+
 
+
 
+
<!--T:28-->
+
Query <font face="Courier"><span style="background-color:lightgrey;">insert upload (temp, wind) values ([th0temp-act.1:-9999], [wind0wind-act=kmh.1:-9999])</span></font face> 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.
+
 
+
<!--T:29-->
+
Details of using variables in templates are explained in [[Templates]] section.
+
 
+
===Individual FTP Uploads=== <!--T:30-->
+
Meteobridge allows you define a FTP server where it can upload up to 4 different files. FIles to be uploaded have to be accessable in the Internet via HTTP. Meteobridge downloads the files pointed to, replaces Meteobridge variables inside the downloaded file by current weather data and uploads resulting file to the specified directory. Meteobridge can just handle one FTP server, but distinct directories and file names for each of the four uploads. Setup of 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
+
 
+
<!--T:31-->
+
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.
+
 
+
<!--T:32-->
+
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.
+
 
+
<!--T:33-->
+
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.
+
 
+
 
+
<!--T:34-->
+
[[File:ftp.png]]
+
 
+
 
+
<!--T:35-->
+
Example above defines an upload schema to FTP server "ftp.myfamousserver.com" for user "myself". Template [http://templates.meteobridge.com/simpledash.html 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:
+
 
+
 
+
<!--T:36-->
+
[[File:mydash.png]]
+
 
+
 
+
<!--T:37-->
+
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:
+
<pre>
+
<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:--]&deg; C</td>
+
          <td>[th0temp-dmin.1:--]&deg; C</td>
+
          <td>[th0temp-dmax.1:--]&deg; 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:--]&deg; C</td>
+
          <td>[th0dew-dmin.1:--]&deg; C</td>
+
          <td>[th0dew-dmax.1:--]&deg; C</td></tr>
+
      <tr><td>Wind Chill Temperature</td>
+
          <td>[wind0chill-act.1:--]&deg; C</td>
+
          <td>[wind0chill-dmin.1:--]&deg; C</td>
+
          <td>[wind0chill-dmax.1:--]&deg; 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:--]&deg;</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>
+
</pre>
+
 
</translate>
 
</translate>
 
====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 [http://saratoga-weather.org/wxtemplates/install.php here].
 
 
When having done the well explained and easy to do setup, your website will look like this:
 
 
[[File:saratoga.png]]
 

Revision as of 14:37, 10 March 2013

Other languages:
Deutsch • ‎English

Meteobridge provides a very flexible mechanism to smuggle sensor data of different kinds into strings to be used by Meteobrdge push services like Twitter, HTTP GET uploads or MSQL database insert requests.

Simply type in the text you want to upload and represent the pieces of sensor data by so called variables. When data gets uploaded, these variables will be replaced by current sensor data and so a string filled with the data you intended will be uploaded.

Each variable starts with an opening square bracket "[" and is terminated by a closing square bracket "]". The structure of the variable name between these brackets is as follows:
sensor-selector=converter.decimals:replacement

"converter", "decimals" and "replacement" can be omitted, "sensor" and "type" are mandatory. While "sensor" tells what sensor and what piece of information of the sensor to use, "selector" decides data from what time period should be taken into account and "converter" does convert data into measurement units the user likes most. "Decimals" decides about precision the result should be shown in and "replacement" gives the string to be returned when there is no data for defined sensor available.

Sensors

These sensors are defined in Meteobridge.

  • th0temp: outdoor temperature in degrees Celsius
  • th0hum: relative outdoor humidity as percentage
  • th0dew: outdoor dew point in degrees Celsius
  • thb0temp: indoor temperature in degrees Celsius
  • thb0hum: indoor humidity as percentage
  • thb0dew: indoor dewpoint in degrees Celsius
  • thb0press: station pressure in hPa
  • thb0seapress: normalized pressure (computed to sea level) in hPa
  • wind0wind: wind speed in m/s
  • wind0avgwind: average windspeed in m/s (time used for average depends on station)
  • wind0dir: wind direction in degress (0° is North)
  • wind0chill: wind chill temperature in degrees Celsius
  • rain0rate: rain rate in mm/h
  • rain0total: rain fall in mm
  • uv0index: uv index
  • sol0rad: solar radiation in W/m^2

If a sensor is not there or data of sensor has passed the "tolerated data age" interval, Meteobridge will not provide data for it and will present the value defined as "replacement". If no replacement is given, variable will not be converted into data but will stay as is.

Selectors

Sensors are followed by a selector (syntactically separated by a dash) that specifies what period in time should be used for evaluation. Valid selectors are:

  • act: most recent data
  • hmin: minimum value of this hour
  • hmax: maximum value of this hour
  • dmin: minimum value of today
  • dmax: maximum value of today
  • ydmin: minimum value of yesterday
  • ydmax: maximum value of yesterday
  • mmin: minimum value of this month
  • mmax: maximum value of this month
  • ymin: minimum value of this year
  • ymax: maximum value of this year
  • amin: minimum value of all time
  • amax: maximum value of all time
  • daysum or sumday, monthsum, yearsum, allsum, ydaysum: selects summerized delta values from today, this month, this year, all time or yesterday: "rain0total-sumday" is todays rain fall.

When you are interested in timestamps of min/max values, you can make use of these selectors:

  • hmintime: timestamp of minimum value of this hour
  • hmaxtime: timestamp of maximum value of this hour
  • dmintime: timestamp of minimum value of today
  • dmaxtime: timestamp of maximum value of today
  • ydmintime: timestamp of minimum value of yesterday
  • ydmaxtime: timestamp of maximum value of yesterday
  • mmintime: timestamp of minimum value of this month
  • mmaxtime: timestamp of maximum value of this month
  • ymintime: timestamp of minimum value of this year
  • ymaxtime: timestamp of maximum value of this year
  • amintime: timestamp of minimum value of all time
  • amaxtime: timestamp of maximum value of all time
  • starttime: timestamp of first recorded value

Timestamps are strings of format "YYYYMMDDhhmmss". Year "YYYY" is reported in 4 digits, all other values (month "MM", day "DD", hour "hh", minute "mm", second "ss") come with 2 digits, leading zeros are not supressed.

Apart from selectors that use absolute, predefined time slots there are also selectors that look for a certain amount of time into the past.

  • val2, val5, val10, val15, val30, val60: selects the value the sensor has shown 2, 5, 10, 15, 30 or 60 minutes ago
  • max2, max5, max10, max15, max30, max60: selects the maximum value from the last 2, 5, 10, 15, 30 or 60 minutes
  • min2, min5, min10, min15, min30, min60: selects the minimum value from the last 2, 5, 10, 15, 30 or 60 minutes
  • avg2, avg5, avg10, avg15, avg30, avg60: selects average value from the last 2, 5, 10, 15, 30 or 60 minutes
  • sum2, sum5, sum10, sum15, sum30, sum60: selects summerized delta values from the last 2, 5, 10, 15, 30 or 60 minutes, which is useful to get amount of total rain in a certain time frame: "rain0total-sum60" is rainfall im mm of last 60 minutes.

Converters

Sensor data is reported in ISO units (°C, hPa, mm, m/s) by default, but can be converted into non-ISO units (imperial) by adding a conversion token. Defined tokens are:

  • F converts temperature from Celsius to Fahrenheit.
  • psi converts pressure from hPa (equivalent to mbar) to psi.
  • mmHg converts pressure from hPa to millimeters of mercury.
  • inHg converts pressure from hPa to inches of mercury.
  • kmh converts wind speed from meters per second to kilometers per hour.
  • mph converts wind speed from meters per second to miles per hour.
  • kn converts wind speed from meters per second to knots.
  • bft converts wind speed from meters per second to Beaufort scale.
  • in converts millimeters to inches.
  • ft converts meters to feet.

If an unknown conversion string is used, no conversion will take place, no error message will appear.

When variable returns a timestamp, then this converter can be applied:

  • utc reports timestamp in UTC instead of localtime, which is default.

System Variables

Meteobridge provides some additional variables that tell details not directly related to weather conditions. Sensor name is "mbsystem", defined selectors are:

  • swversion: Meteobridge version string (example: "1.1")
  • buildnum: build number as integer (example: 1673)
  • platform: string that specifies hw platform (example: "TL-MR3020")
  • language: language used on Meteobridge's web interface (example: "English")
  • timezone: defined timezone (example: "Europe/Berlin")
  • latitude: latitude as float (example: 53.875120)
  • longitude: longitude as float (example: 9.885357)
  • lunarage: days passes since new moon as integer (example: 28)
  • lunarpercent: lunarphase given as percentage from 0% (new moon) to 100% (full moon)
  • lunarsegment: lunarpahse segment as integer (expample: 0)
  • daylength: length of day (example: "11:28")
  • civildaylength: alternative method for daylength computation (example: "12:38")
  • nauticaldaylength: alternative method for daylength computation (example: "14:00")
  • sunrise: time of sunrise in local time. Can be converterd to UTC by applying "=utc" to the variable (example: "06:47", resp. "05:47")
  • sunset. time of sunset in local time. Can be converterd to UTC by applying "=utc" to the variable (example: "18:15", resp. "17:15")
  • civilsunrise, civilsunset, nauticalsunrise, nauticalsunset: alternative computations for sunset and sunrise.
  • daynightflag: returns "D" when there is daylight, otherwise "N".
  • moonrise: time of moonrise in local time. Can be converterd to UTC by applying "=utc" to the variable. Please notice that not every day has a moonrise time, therefore, variable can be non-existent on certain days (example: "05:46", resp. "04:46")
  • moonset: time of moonset in local time. Can be converterd to UTC by applying "=utc" to the variable. Please notice that not every day has a moonset time, therefore, variable can be non-existent on certain days (example: "17:00", resp. "16:00")

Time/Date Variables

Variables representing current date/time don't come as "sensor-selector=converter" chains but have a distinct meaning by themselves.

Date und time variables are defined as follows:

  • YYYY: year as four digit number
  • YY: year as two digit number
  • MM: month as two digit number, if only one digit neede a zero will be used as first digit
  • M: month as one or two digit number, no leading zeros
  • DD: day of month as two digit number, if only one digit neede a zero will be used as first digit
  • D: day of month as one or two digit number, no leading zeros
  • hh: hour as two digit number, if only one digit neede a zero will be used as first digit
  • h: hour as one or two digit number, no leading zeros
  • mm: minute as two digit number, if only one digit neede a zero will be used as first digit
  • m: minute as one or two digit number, no leading zeros
  • ss: seconds as two digit number, if only one digit neede a zero will be used as first digit
  • s: seconds as one or two digit number, no leading zeros

When a capital "U" preceeds a date/time variable name, UTC is used instead of local time ("[Uhh]:[Umm]:[Uss] UTC" is evaluated to a string like "16:03:33 UTC")

Decimals

Unless otherwise defined numbers are reported with one decimal. By specifying a value for "decimals" you can determine resolution of presented values.

When variable returns a string instead of a number (in case of a timestamp for example), "decimal" specification does have a different format and meaning, which allows to select a substring. Specification of the substring consists of two lower-case letters. The first one specifies start point of the substring, second leter the position of last character of the string to be reported. For example, when string is timestamp "20130303121055" a specification of ".ad" selects a substring from first character (position code "a") until fourth character (position code "d"). When you want to grab the time for lowest outdoor temperature of today the template for that will be [th0temp-dmintime.ij:--]:[th0temp-dmintime.kl:--]. "ij" selects the hour part at position 9-10 and "kl" selects minute part at position 11-12 of the timestamp.

Replacement

When a variable is not defined or there is no data for a specified sensor, information specified as "replacement" string will be represented instead.

Examples

Having a look at examples usually helps to understand how easy that is.

  1. Template Outdoor temperature is [th0temp-act=F.1:--]°F will be converted into Outdoor temperature is 3.4°F when there is outdoor temp data and into Outdoor temperature is --°F if outdoor temp sensor does not provide recent data.
  2. Template Local time is [hh]:[mm] will be converted into Local time is 09:27.
  3. Template Max gust in last 10 minutes was: [wind0wind-max10.1:--]m/s, [wind0wind-max10=mph.1:--]mph, [wind0wind-max10=kn.0:--]kn will be converted into Max gust in last 10 minutes was: 10.5m/s, 23.5mph, 20kn.