Difference between revisions of "Templates"

From meteobridge
Jump to: navigation, search
(49 intermediate revisions by the same user not shown)
Line 1: Line 1:
 
__NOTOC__
 
__NOTOC__
<languages /><translate>
 
 
<!--T:1-->
 
<!--T:1-->
<br />Meteobridge provides a very flexible mechanism to smuggle sensor data of different kinds into strings to be used by Meteobridge push services like Twitter, HTTP GET uploads or MySQL database insert requests.
+
Meteobridge provides a very flexible mechanism to put sensor data of different kinds into text strings to be used by Meteobridge push services like Twitter, HTTP GET uploads, FTP uploads or MySQL 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.
 
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-->
 
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>
 
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.
+
"converter", "decimals" and "replacement" can be omitted, "sensor" and "selector" 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.
 
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.
 +
 +
With the support of multiple weather stations in parallel (Meteobridge version 5.0) the concept of logical and physical sensors has been introduced. Physical sensors are directly assigned to a specific weather station, while logical sensors are configurable names connected with a certain physical sensors. When you have two weather stations connected and both report outdoor temperature you have to decide which of those should be regarded the primary outdoor sensor to be used to report outdoor temperature to weather networks. When looking into this on the level of variables you have two "th0temp" variables. To discriminate those the sensor id is prefixed with a station number. As a result the two physical outdoor temperature sensors are named "th0!0temp (primary station) and "th1!0temp" (first additional station). According the mappings you define on the "Station - Mapping" tab, one of these is mapped to the logical sensor "th0temp". Per default sensors of the primary station are mapped to the corresponding logical sensors, unless this mapping is changed manually. When you deal with variables you can decide if you want to use the mapped logical sensor "th0temp" or if you want to address the sensor of a specific station like "th0!0temp" which selects the th0temp sensor of the primary station, independent from what the mapping looks like.
  
 
==Sensors== <!--T:3-->
 
==Sensors== <!--T:3-->
These sensors are defined in Meteobridge.
+
These logical sensors are defined in Meteobridge.
 
* '''th0temp''': outdoor temperature in degrees Celsius
 
* '''th0temp''': outdoor temperature in degrees Celsius
 
* '''th0hum''': relative outdoor humidity as percentage
 
* '''th0hum''': relative outdoor humidity as percentage
 
* '''th0dew''': outdoor dew point in degrees Celsius
 
* '''th0dew''': outdoor dew point in degrees Celsius
 
* '''th0heatindex''': outdoor heat index in degrees Celsius
 
* '''th0heatindex''': outdoor heat index in degrees Celsius
 +
* '''th0wetbulb''': outdoor wet bulb temperature in degrees Celsius
 
* '''thb0temp''': indoor temperature in degrees Celsius
 
* '''thb0temp''': indoor temperature in degrees Celsius
 
* '''thb0hum''': indoor humidity as percentage
 
* '''thb0hum''': indoor humidity as percentage
Line 24: Line 26:
 
* '''wind0avgwind''': average windspeed in m/s (time used for average depends on station)
 
* '''wind0avgwind''': average windspeed in m/s (time used for average depends on station)
 
* '''wind0dir''': wind direction in degress (0° is North)
 
* '''wind0dir''': wind direction in degress (0° is North)
 +
* '''wind0maxdir''': wind direction in degress (0° is North) of maximum wind gust
 
* '''wind0chill''': wind chill temperature in degrees Celsius
 
* '''wind0chill''': wind chill temperature in degrees Celsius
 
* '''rain0rate''': rain rate in mm/h
 
* '''rain0rate''': rain rate in mm/h
Line 31: Line 34:
 
* '''sol0evo''': evapotranspiration in mm (only supported on Davis Vantage stations)
 
* '''sol0evo''': evapotranspiration in mm (only supported on Davis Vantage stations)
 
* '''sun0total''': sunshine duration in hours (only supported on Davis Vantages equipped with a 3rd party sunshine detector)
 
* '''sun0total''': sunshine duration in hours (only supported on Davis Vantages equipped with a 3rd party sunshine detector)
 +
* '''lgt0dist''': Distance to lightning in kilometer
 +
* '''lgt0energy''': Energy of lightning strike (no physical unit)
 +
* '''lgt0total''': Number of lightning strokes
 +
* '''air0pm''': pollution measured in µg per m3
 +
* '''t0temp''': extra temperature sensor, temperature in degrees Celsius
 +
* '''data0num''': extra sensor, delivering not further specified numerical data
 +
 +
Physical sensors look the same but have a station number included, separated by an exclamation mark "!" from the sensor id. Station number is "0" for the primary station, "1" for the first additional station, etc. Examples:
 +
* '''th0!0temp''': outdoor temperature of primary station in degrees Celsius
 +
* '''th1!0hum''': relative outdoor humidity of 1st additional station as percentage
 +
* '''th0!1temp''': temperature of additional temperature-humidity sensor of primary station in degrees Celsius
 +
* '''t1!2temp''': temperature of 2nd additional temperature sensor of first additional station in degrees Celsius
 +
 
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.
 
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.
 
As some weather stations do also report low battery status, there are also sensors '''thb0lowbat''', '''th0lowbat''', etc available. These sensors provide current low bat status (0 = no low battery, 1 = low battery) for each of the base sensors.  
 
As some weather stations do also report low battery status, there are also sensors '''thb0lowbat''', '''th0lowbat''', etc available. These sensors provide current low bat status (0 = no low battery, 1 = low battery) for each of the base sensors.  
 +
 +
<!--T:29-->
 +
Since version 3.6 Meteobridge also supports selection of a sensor which has been defined on "Live Data" tab as primary. When no primary selection has been made all the "0" sensors (like "th0temp", "wind0wind", etc) are primary by default. But when you select "th3temp" as primary sensor and by that its data is reported as your stations outdoor temperature to all the weather networks, then you can now also select the primary sensor in your template definitions by selecting it as the "*" sensor. For example: "th*temp" selects the sensors defined as the primary outdoor temp sensor. When you use "[th*temp-act:--]" you get the current temperature of your primary outdoor temp sensor. This will be a synonym to "[th0temp-act:--] as long as you have not selected another sensor as primary outdoor temp sensor. But when you have selected "th3temp" to be the primary outdoor temp sensor, then "th*temp" will reference to "th3temp" instead of "th0temp". Please be aware that Meteobridge versions before version 3.6 will fail to evaluate "*" sensors. Therefore, it is recommended to provide both notations in a template and to make use of the conditional evaluation as explained in a later chapter. Here is an example that takes "th0temp" as default outdoor sensor on older Meteobridge versions and newer "th*temp" notation on current ones:
 +
<font face="Courier"><span style="background-color:lightgrey;">#if{*[mbsystem-swversion:1.0]>=3.6*}#then#outdoor temp: [th*temp-act:--]°C#else#outdoor temp: [th0temp-act:--]°C#fi#</span></font face>
  
 
<!--T:17-->
 
<!--T:17-->
 
Some stations do support additional temp/hum sensors. These will be enumerated as "th1temp", "th1hum", "th1dew", and so on. "Live Data" tab will illustrate what sensor number matches what current data. When you have a fully equipped Davis Vantage you might also have soil and leaf sensors. These are also reported as temp/hum sensors, but there is no dewpoint data computed for these types of sensors. soil sensors are enumerated as "th10temp", "th10hum", ..., "th13temp", "th13hum" and leaf sensors are listed as "th15temp", "th15hum", ..., "th18temp", "th18hum". "hum" values do not represent relative humidity in that case but data in units "cbar" and "wet". However, Meteobridge does not invent new unit selectors for it, so you have to use "hum" as a generic selector to get "cbar" and wetness data from the soil/leaf sensors.
 
Some stations do support additional temp/hum sensors. These will be enumerated as "th1temp", "th1hum", "th1dew", and so on. "Live Data" tab will illustrate what sensor number matches what current data. When you have a fully equipped Davis Vantage you might also have soil and leaf sensors. These are also reported as temp/hum sensors, but there is no dewpoint data computed for these types of sensors. soil sensors are enumerated as "th10temp", "th10hum", ..., "th13temp", "th13hum" and leaf sensors are listed as "th15temp", "th15hum", ..., "th18temp", "th18hum". "hum" values do not represent relative humidity in that case but data in units "cbar" and "wet". However, Meteobridge does not invent new unit selectors for it, so you have to use "hum" as a generic selector to get "cbar" and wetness data from the soil/leaf sensors.
  
When using Meteobridge PRO another set of variable holding data about the system status will be available:
+
<!--T:27-->
 +
When using Meteobridge PRO an additional set of variables holding data about the system status will be available:
 
* '''data10num''': cpu load in percent
 
* '''data10num''': cpu load in percent
 
* '''data11num''': uptime in hours
 
* '''data11num''': uptime in hours
Line 48: Line 69:
 
* '''data18num''': current consumption in Ampere
 
* '''data18num''': current consumption in Ampere
 
* '''data19num''': kilobytes of data sent (including web interface traffic)  
 
* '''data19num''': kilobytes of data sent (including web interface traffic)  
* '''data20num''': kilobytes of data received (including web interface traffic)  
+
* '''data20num''': kilobytes of data received (including web interface traffic)
  
 
==Selectors== <!--T:4-->
 
==Selectors== <!--T:4-->
 
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:
 
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
 
* '''act''': most recent data
 +
* '''lastval''': same as "act" but does not switch to "invalid" when hold time has passed.
 +
* '''prev''': data just reported before current data
 
* '''hmin''': minimum value of this hour
 
* '''hmin''': minimum value of this hour
 
* '''hmax''': maximum value of this hour
 
* '''hmax''': maximum value of this hour
 +
* '''havg''': average value of this hour
 
* '''dmin''': minimum value of today
 
* '''dmin''': minimum value of today
 
* '''dmax''': maximum value of today
 
* '''dmax''': maximum value of today
 +
* '''davg''': average value of today
 
* '''ydmin''': minimum value of yesterday
 
* '''ydmin''': minimum value of yesterday
 
* '''ydmax''': maximum value of yesterday
 
* '''ydmax''': maximum value of yesterday
 +
* '''ydavg''': average value of yesterday
 
* '''mmin''': minimum value of this month
 
* '''mmin''': minimum value of this month
 
* '''mmax''': maximum value of this month
 
* '''mmax''': maximum value of this month
 +
* '''mavg''': average value of this month
 
* '''ymin''': minimum value of this year
 
* '''ymin''': minimum value of this year
 
* '''ymax''': maximum value of this year
 
* '''ymax''': maximum value of this year
 +
* '''yavg''': average value of this year
 
* '''amin''': minimum value of all time
 
* '''amin''': minimum value of all time
 
* '''amax''': maximum value of all time
 
* '''amax''': maximum value of all time
 +
* '''aavg''': average value of all time
 
Sensors that deliver cumulated data like "rain0total", "sol0evo" and "sun0total" should be used with the following selectors only:
 
Sensors that deliver cumulated data like "rain0total", "sol0evo" and "sun0total" should be used with the following selectors only:
 
* '''hoursum''', '''daysum or sumday''', '''monthsum''', '''yearsum''', '''allsum''', '''ydaysum''': selects summarized delta values from today, this month, this year, all time or yesterday. Example: "rain0total-sumday" is todays rain fall.
 
* '''hoursum''', '''daysum or sumday''', '''monthsum''', '''yearsum''', '''allsum''', '''ydaysum''': selects summarized delta values from today, this month, this year, all time or yesterday. Example: "rain0total-sumday" is todays rain fall.
 +
Sensor '''wind0maxdir''' does only support '''hmax''', '''dmax''', '''ydaymax''', '''mmax''', '''ymax''', '''amax'''. All other selectors do not report useful data.
  
 
<!--T:13-->
 
<!--T:13-->
Line 83: Line 113:
 
* '''amaxtime''': timestamp of maximum value of all time
 
* '''amaxtime''': timestamp of maximum value of all time
 
* '''starttime''': timestamp of first recorded value
 
* '''starttime''': timestamp of first recorded value
 +
* '''lasttime''': timestamp of last occurrence of sensor data
 
* '''nonzerotime''': timestamp of last occurrence of a nonzero value
 
* '''nonzerotime''': timestamp of last occurrence of a nonzero 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 suppressed.  
 
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 suppressed.  
 
* '''age''': reports seconds elapsed since last reception of data for that particular sensor.
 
* '''age''': reports seconds elapsed since last reception of data for that particular sensor.
 
* '''hold''': reports seconds elapsed since last reception of data for that particular sensor, but returns invalid value when age is beyond data hold period of 300 seconds. This allows to return invalid status instead large number of seconds for sensors having dropped off long time ago.
 
* '''hold''': reports seconds elapsed since last reception of data for that particular sensor, but returns invalid value when age is beyond data hold period of 300 seconds. This allows to return invalid status instead large number of seconds for sensors having dropped off long time ago.
 
+
* '''prevtime1''', '''prevtime2''' ...: selects the timestamp of the sensor data 1, 2, ... iterations in the past. Looking into the past is not done in term of a time frame, but occurrences of data records for this sensor is counted back.
  
 
<!--T:5-->
 
<!--T:5-->
Line 98: Line 129:
 
* '''sum1''', '''sum2''', '''sum3''', ..., '''sum60''', '''sum1h''', '''sum2h''', '''sum3h''', ..., '''sum24h''': selects summarized delta values from the last one to 60 minutes or one to 24 hours. This is useful to get amount of total rain in a certain time frame: "rain0total-sum60" is rainfall in mm of last 60 minutes.
 
* '''sum1''', '''sum2''', '''sum3''', ..., '''sum60''', '''sum1h''', '''sum2h''', '''sum3h''', ..., '''sum24h''': selects summarized delta values from the last one to 60 minutes or one to 24 hours. This is useful to get amount of total rain in a certain time frame: "rain0total-sum60" is rainfall in mm of last 60 minutes.
 
* '''delta1''', '''delta2''', '''delta3''', ..., '''delta60''', '''delta1h''', '''delta2h''', '''delta3h''', ..., '''delta24h''': selects difference between current value and value from one to 60 minutes or one to 24 hours ago. A positive number shows that value has increased, a negative number indicates the value has decreased. This is useful to do trend analysis over various time spans.
 
* '''delta1''', '''delta2''', '''delta3''', ..., '''delta60''', '''delta1h''', '''delta2h''', '''delta3h''', ..., '''delta24h''': selects difference between current value and value from one to 60 minutes or one to 24 hours ago. A positive number shows that value has increased, a negative number indicates the value has decreased. This is useful to do trend analysis over various time spans.
 +
* '''prev1''', '''prev2''', ...: selects the value of the sensor data 1, 2, ... iterations in the past. Looking into the past is not done in terms of a time frame, but occurrences of data records for this sensor are counted back.
  
===Meteobridge PRO Additions=== <!--T:21-->
+
===Meteobridge PRO Additions (available on PRO, PRO2, NANO SD, RPI)=== <!--T:21-->
Selectors '''val''', '''min''', '''max''', '''avg''', '''sum''', '''mintime''', '''maxtime''' can be combined with a "@YYYYMMDDhh" specifier, which determines the point in time where the data should be taken from. This specifier also defines if data should be used on a per hour, per day, per month or per year resolution. To get data in a per hour resolution the specifier needs to define the point in time down to the hour. Example: "min@2015121909" selects minimum data from December 19, 2015 09:00 until 9:59 (on a per hour base). This is how the specifier works:
+
Selectors '''val''', '''min''', '''max''', '''avg''', '''sum''', '''count''', '''mintime''', '''maxtime''' can be combined with a "@YYYYMMDDhh" specifier, which determines the point in time where the data should be taken from. This specifier also defines if data should be used on a per hour, per day, per month or per year resolution. To get data in a per hour resolution the specifier needs to define the point in time down to the hour. Example: "min@2015121909" selects minimum data from December 19, 2015 09:00 until 9:59 (on a per hour base). This is how the specifier works:
 
* '''@YYYY''' selects data for the specified year. Example: Using "[th0temp-min@2015]" in a template will report minimum outdoor temperature of 2015. When "YYYY" is not defining a valid year but is in the range of "0000" to "0010" then "0000" is interpreted as the current year, "0001" as the previous year and so on. In that situation the 4 digit number expresses how many years to skip into the past. These skips need to be in 4-digit style, leading zeros are not allowed to be omitted.
 
* '''@YYYY''' selects data for the specified year. Example: Using "[th0temp-min@2015]" in a template will report minimum outdoor temperature of 2015. When "YYYY" is not defining a valid year but is in the range of "0000" to "0010" then "0000" is interpreted as the current year, "0001" as the previous year and so on. In that situation the 4 digit number expresses how many years to skip into the past. These skips need to be in 4-digit style, leading zeros are not allowed to be omitted.
 
* '''@YYYYMM''' selects data for the specified month. Example: Using "[wind0wind-max@201509]" in a template will report maximum wind speed (gust) of September 2015.
 
* '''@YYYYMM''' selects data for the specified month. Example: Using "[wind0wind-max@201509]" in a template will report maximum wind speed (gust) of September 2015.
 
* '''@YYYYMMDD''' selects data for the specified day. Example: Using "[rain0total-sum@20151031]" in a template will report total rainfall on October 31, 2015.
 
* '''@YYYYMMDD''' selects data for the specified day. Example: Using "[rain0total-sum@20151031]" in a template will report total rainfall on October 31, 2015.
 
* '''@YYYYMMDDhh''' selects data for the specified hour. Example: Using "[uv0index-avg@2015110316]" in a template will report average UV index on November 3, 2015 between 16:00 and 16:59.
 
* '''@YYYYMMDDhh''' selects data for the specified hour. Example: Using "[uv0index-avg@2015110316]" in a template will report average UV index on November 3, 2015 between 16:00 and 16:59.
 +
Please be aware that these requests are directly requesting data from the persistent database only. Therefore, when requesting data from periods of time that are not yet complete, data from the started but not finished hour will not be reported.
  
 
<!--T:22-->
 
<!--T:22-->
Line 112: Line 145:
 
* '''@D'''n addresses daily data n days in the past. Example: "[th0temp-min@D7]" will return minimum outdoor temperature of the current day, one week in the past.
 
* '''@D'''n addresses daily data n days in the past. Example: "[th0temp-min@D7]" will return minimum outdoor temperature of the current day, one week in the past.
 
* '''@h'''n addresses hourly data n hours in the past.
 
* '''@h'''n addresses hourly data n hours in the past.
 +
Limitations on not yet completed time periods apply as with the '''@YYYYMMDDhh''' format.
  
 
<!--T:23-->
 
<!--T:23-->
Line 118: Line 152:
 
<!--T:24-->
 
<!--T:24-->
 
'''mintime''' and '''maxtime''' report time stamp down to the second when minimum/maximum value of defined time frame has occurred.
 
'''mintime''' and '''maxtime''' report time stamp down to the second when minimum/maximum value of defined time frame has occurred.
 +
 +
'''mcount''', '''ycount''' and '''acount''' are selectors defined for rainXtotal sensors and report the number of days with rainfall within the current month (mcount), year (ycount) and total observation time (acount). Example: [rain0total-mcount:--] reports number of days with rain in current month. rain day counts can be used with selector "count" in combination with point in time notations. Example: [rain0total-count@202312:--] reports number of days with rain in December 2023.
  
 
==Converters== <!--T:6-->
 
==Converters== <!--T:6-->
Line 129: Line 165:
 
* '''kn''' converts wind speed from meters per second to knots.
 
* '''kn''' converts wind speed from meters per second to knots.
 
* '''bft''' converts wind speed from meters per second to Beaufort scale.
 
* '''bft''' converts wind speed from meters per second to Beaufort scale.
* '''in''' converts millimeters to inches.
+
* '''in''' or '''inch''' converts millimeters to inches.
* '''ft''' converts meters to feet.
+
* '''ft''' or '''feets'' converts meters to feet.
 +
* '''mls''' converts kilometers to miles.
 
* '''endir''' converts a wind direction into one of 16 English direction texts.
 
* '''endir''' converts a wind direction into one of 16 English direction texts.
 
* '''nldir''' converts a wind direction into one of 16 Dutch direction texts.
 
* '''nldir''' converts a wind direction into one of 16 Dutch direction texts.
Line 141: Line 178:
 
** '''+2''': +2 hPa <= delta
 
** '''+2''': +2 hPa <= delta
 
* '''enbarotrend''' reports trend as strings '''FF''', '''FS''', '''ST''', '''RS''', '''RF'''
 
* '''enbarotrend''' reports trend as strings '''FF''', '''FS''', '''ST''', '''RS''', '''RF'''
Converters "F", "psi", "mmHg", "inHg", "kmh", "mph", "kn", "bft", "in", "ft" can be followed by a multiplier. For example: Converter "F10" tells that temp data of sensor will be converted to degrees of Fahrenheit and multiplied by 10 or to say it the other way round the data will be represented in 1/10 degrees of Fahrenheit. As a special case a converter can also just be a multiplier. In that case the multiplier is applied without conversion of units.  
+
Converters "F", "psi", "mmHg", "inHg", "kmh", "mph", "kn", "bft", "in", "ft" can be followed by a multiplier. For example: Converter "F10" tells that temp data of sensor will be converted to degrees of Fahrenheit and multiplied by 10 or to say it the other way round the data will be represented in 1/10 degrees of Fahrenheit. As a special case a converter can also just be a multiplier. In that case the multiplier is applied without conversion of units. Multipliers with decimals like "1.5" need to be represented as "1,5" as the dot will be interpreted as the start of the "decimal" section of the variable. Beside multipliers you can also specify offsets, which have to be positioned after the multiplier and start with a "+" or "-". Example: "inhg-0,3-2,3" will convert data from hPa to inHg, will multiply the result with -0.3 and will subtract 2.3 after that.   
  
 
<!--T:14-->
 
<!--T:14-->
Line 157: Line 194:
 
*'''textit''': reports in Italian
 
*'''textit''': reports in Italian
 
*'''textnl''': reports in Dutch
 
*'''textnl''': reports in Dutch
*'''textest''': reports in Estonian
+
*'''textest''': reports in Estonian (UTF-8 coded)
*'''texthr''': reports in Hungarian
+
*'''texthr''': reports in Hungarian (HTML coded)
*'''textcz''': reports in Czech
+
*'''textcz''': reports in Czech (UTF-8 coded)
 +
*'''textfr''': reports in French (UTF-8 coded)
 +
*'''texteshtml''': reports in Spanish (HTML coded)
 
When converter "us" is added, all blanks are replaced by underscores.
 
When converter "us" is added, all blanks are replaced by underscores.
  
Line 172: Line 211:
 
* '''language''': language used on Meteobridge's web interface (example: "English")
 
* '''language''': language used on Meteobridge's web interface (example: "English")
 
* '''timezone''': defined timezone (example: "Europe/Berlin")
 
* '''timezone''': defined timezone (example: "Europe/Berlin")
 +
* '''altitude''': defined station altitude in meters
 
* '''latitude''': latitude as float (example: 53.875120)
 
* '''latitude''': latitude as float (example: 53.875120)
 
* '''longitude''': longitude as float (example: 9.885357)
 
* '''longitude''': longitude as float (example: 9.885357)
Line 210: Line 250:
 
* '''graphG''': returns URL of the user's Meteoplug chart "*iphone-pr-2d"
 
* '''graphG''': returns URL of the user's Meteoplug chart "*iphone-pr-2d"
 
* '''graphH''': returns URL of the user's Meteoplug chart "*iphone-pr-2d-imp"
 
* '''graphH''': returns URL of the user's Meteoplug chart "*iphone-pr-2d-imp"
 +
* '''primarysensors''': sets template evaluation to use sensors marked as primary on "Live Data" tab as the "0" ones (thb0, th0, wind0, rain0, etc...)
 +
* '''noprimarysensors''': sets template evaluation to use sensors as literally named
 +
* '''totalstorage''': reports total storage in MB (only valid for PRO, PRO2, NANO SD, RPI)
 +
* '''freestorage''': reports free storage in MB (only valid for PRO, PRO2, NANO SD, RPI)
 +
* '''usedstorage''': reports used storage in MB (only valid for PRO, PRO2, NANO SD, RPI)
  
===Converters for System Variables===
+
 
 +
===Converters for System Variables=== <!--T:28-->
 
Meteobridge supports converters to be applied to day length computations. Normally day length values are reported in a "HH:MM" fashion. This can be altered in the following ways:
 
Meteobridge supports converters to be applied to day length computations. Normally day length values are reported in a "HH:MM" fashion. This can be altered in the following ways:
 
* '''secs''' converter returns day length information as number of seconds  
 
* '''secs''' converter returns day length information as number of seconds  
Line 218: Line 264:
 
Timestamps can also be converted in various ways. Normal output is 24h notation "HH:MM" in local time. These converters can be applied:
 
Timestamps can also be converted in various ways. Normal output is 24h notation "HH:MM" in local time. These converters can be applied:
 
* '''utc''' reports timestamp in UTC instead of local time
 
* '''utc''' reports timestamp in UTC instead of local time
* '''apm''' reports timestamp in American AM/PM style.
+
* '''apm''' reports timestamp in American AM/PM style
 +
* '''epoch''' reports timestamp as Linux epoch time (seconds since Jan 1, 1970)
  
 
==Time/Date Variables== <!--T:7-->
 
==Time/Date Variables== <!--T:7-->
Line 228: Line 275:
 
* '''YY''': year as two digit number
 
* '''YY''': year as two digit number
 
* '''MMM''': month as three character English abbreviation ("Jan", Feb", ...)
 
* '''MMM''': month as three character English abbreviation ("Jan", Feb", ...)
 +
* '''mmm''': month as three character English abbreviation in lower case ("jan", feb", ...)
 
* '''MM''': month as two digit number, if only one digit needed a zero will be used as first digit
 
* '''MM''': month as two digit number, if only one digit needed a zero will be used as first digit
* '''M''': month as one or two digit number, no leading zeros
+
* '''M''': month as one or two digit number, no leading zeros, January is 1.
 +
* '''M0''': month as one or two digit number, no leading zeros, January is 0.
 
* '''DD''': day of month as two digit number, if only one digit needed a zero will be used as first digit
 
* '''DD''': day of month as two digit number, if only one digit needed a zero will be used as first digit
* '''D''': day of month as one or two digit number, no leading zeros
+
* '''D''': day of month as one or two digit number, no leading zeros, first day of month is 1
 +
* '''D0''': day of month as one or two digit number, no leading zeros, first day of month is 0
 +
* '''DDD''': day of week as three character English abbreviation ("Sun", "Mon", ...)
 +
* '''ddd''': day of week as three character English abbreviation in lower case ("Sun", "Mon", ...)
 
* '''hh''': hour in 24h notation as two digit number, if only one digit needed a zero will be used as first digit
 
* '''hh''': hour in 24h notation as two digit number, if only one digit needed a zero will be used as first digit
 
* '''h''': hour in 24h notation as one or two digit number, no leading zeros
 
* '''h''': hour in 24h notation as one or two digit number, no leading zeros
Line 250: Line 302:
 
<!--T:15-->
 
<!--T:15-->
 
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 letter 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.
 
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 letter 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.
 +
 +
When a number is given instead of a substring qualifier, then the number defines the number of characters the resulting string is padded to. When the number is smaller than the string length, then only rightmost characters remain, otherwise the string is added with leading blanks to make it's size fit. When the number is negative, then string is cut on the right side resp. trailing blanks are added. Example: Assume that wind direction is "ENE" then
 +
<font face="Courier"><span style="background-color:lightgrey;">:[wind0dir-act=endir.5]:[wind0dir-act=endir.-5]:</span></font face>
 +
will result into
 +
<font face="Courier"><span style="background-color:lightgrey;">:  ENE:ENE  :</span></font face>
  
 
==Replacement== <!--T:10-->
 
==Replacement== <!--T:10-->
Line 278: Line 335:
 
|'''^'''
 
|'''^'''
 
|arithmetic operator "power"
 
|arithmetic operator "power"
 +
|-
 +
|'''max''', '''min'''
 +
|selection operators "max", "min" which select left or right operand by comparison
 
|-
 
|-
 
|'''sqrt()''', '''log()''', '''exp()''', '''sin()''', '''asin()''', '''cos()''', '''acos()''', '''tan()''', '''atan()''', '''atan2()''', '''abs()''', '''fabs()''', '''floor()''', '''ceil()''', '''round()'''
 
|'''sqrt()''', '''log()''', '''exp()''', '''sin()''', '''asin()''', '''cos()''', '''acos()''', '''tan()''', '''atan()''', '''atan2()''', '''abs()''', '''fabs()''', '''floor()''', '''ceil()''', '''round()'''
|arithmetic functions: square root, logarithm, logarithmic exponent, sinus, arcus sinus, cosinus, arcus cosinus, tangens, arcus tangens, arcus tangens2, absolute, floating point absolute, lower integer, upper integer, rounded integer
+
|arithmetic functions: square root, logarithm, logarithmic exponent, sinus, arcus sinus, cosinus, arcus cosinus, tangens, arcus tangens, arcus tangens2, absolute, floating point absolute, lower integer, upper integer, rounded integer. Please remind that there must not be a space between function name and the parameter brackets, otherwise computation will fail. "sqrt(...)" is fine, "sqrt (...)" will fail.
 
|}
 
|}
  

Revision as of 17:26, 6 March 2024

Meteobridge provides a very flexible mechanism to put sensor data of different kinds into text strings to be used by Meteobridge push services like Twitter, HTTP GET uploads, FTP uploads or MySQL 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 "selector" 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.

With the support of multiple weather stations in parallel (Meteobridge version 5.0) the concept of logical and physical sensors has been introduced. Physical sensors are directly assigned to a specific weather station, while logical sensors are configurable names connected with a certain physical sensors. When you have two weather stations connected and both report outdoor temperature you have to decide which of those should be regarded the primary outdoor sensor to be used to report outdoor temperature to weather networks. When looking into this on the level of variables you have two "th0temp" variables. To discriminate those the sensor id is prefixed with a station number. As a result the two physical outdoor temperature sensors are named "th0!0temp (primary station) and "th1!0temp" (first additional station). According the mappings you define on the "Station - Mapping" tab, one of these is mapped to the logical sensor "th0temp". Per default sensors of the primary station are mapped to the corresponding logical sensors, unless this mapping is changed manually. When you deal with variables you can decide if you want to use the mapped logical sensor "th0temp" or if you want to address the sensor of a specific station like "th0!0temp" which selects the th0temp sensor of the primary station, independent from what the mapping looks like.

Sensors

These logical sensors are defined in Meteobridge.

  • th0temp: outdoor temperature in degrees Celsius
  • th0hum: relative outdoor humidity as percentage
  • th0dew: outdoor dew point in degrees Celsius
  • th0heatindex: outdoor heat index in degrees Celsius
  • th0wetbulb: outdoor wet bulb temperature 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)
  • wind0maxdir: wind direction in degress (0° is North) of maximum wind gust
  • 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
  • sol0evo: evapotranspiration in mm (only supported on Davis Vantage stations)
  • sun0total: sunshine duration in hours (only supported on Davis Vantages equipped with a 3rd party sunshine detector)
  • lgt0dist: Distance to lightning in kilometer
  • lgt0energy: Energy of lightning strike (no physical unit)
  • lgt0total: Number of lightning strokes
  • air0pm: pollution measured in µg per m3
  • t0temp: extra temperature sensor, temperature in degrees Celsius
  • data0num: extra sensor, delivering not further specified numerical data

Physical sensors look the same but have a station number included, separated by an exclamation mark "!" from the sensor id. Station number is "0" for the primary station, "1" for the first additional station, etc. Examples:

  • th0!0temp: outdoor temperature of primary station in degrees Celsius
  • th1!0hum: relative outdoor humidity of 1st additional station as percentage
  • th0!1temp: temperature of additional temperature-humidity sensor of primary station in degrees Celsius
  • t1!2temp: temperature of 2nd additional temperature sensor of first additional station in degrees Celsius

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. As some weather stations do also report low battery status, there are also sensors thb0lowbat, th0lowbat, etc available. These sensors provide current low bat status (0 = no low battery, 1 = low battery) for each of the base sensors.

Since version 3.6 Meteobridge also supports selection of a sensor which has been defined on "Live Data" tab as primary. When no primary selection has been made all the "0" sensors (like "th0temp", "wind0wind", etc) are primary by default. But when you select "th3temp" as primary sensor and by that its data is reported as your stations outdoor temperature to all the weather networks, then you can now also select the primary sensor in your template definitions by selecting it as the "*" sensor. For example: "th*temp" selects the sensors defined as the primary outdoor temp sensor. When you use "[th*temp-act:--]" you get the current temperature of your primary outdoor temp sensor. This will be a synonym to "[th0temp-act:--] as long as you have not selected another sensor as primary outdoor temp sensor. But when you have selected "th3temp" to be the primary outdoor temp sensor, then "th*temp" will reference to "th3temp" instead of "th0temp". Please be aware that Meteobridge versions before version 3.6 will fail to evaluate "*" sensors. Therefore, it is recommended to provide both notations in a template and to make use of the conditional evaluation as explained in a later chapter. Here is an example that takes "th0temp" as default outdoor sensor on older Meteobridge versions and newer "th*temp" notation on current ones: #if{*[mbsystem-swversion:1.0]>=3.6*}#then#outdoor temp: [th*temp-act:--]°C#else#outdoor temp: [th0temp-act:--]°C#fi#

Some stations do support additional temp/hum sensors. These will be enumerated as "th1temp", "th1hum", "th1dew", and so on. "Live Data" tab will illustrate what sensor number matches what current data. When you have a fully equipped Davis Vantage you might also have soil and leaf sensors. These are also reported as temp/hum sensors, but there is no dewpoint data computed for these types of sensors. soil sensors are enumerated as "th10temp", "th10hum", ..., "th13temp", "th13hum" and leaf sensors are listed as "th15temp", "th15hum", ..., "th18temp", "th18hum". "hum" values do not represent relative humidity in that case but data in units "cbar" and "wet". However, Meteobridge does not invent new unit selectors for it, so you have to use "hum" as a generic selector to get "cbar" and wetness data from the soil/leaf sensors.

When using Meteobridge PRO an additional set of variables holding data about the system status will be available:

  • data10num: cpu load in percent
  • data11num: uptime in hours
  • data12num: usage of data partition in percent
  • data13num: usage of RAM in percent
  • data14num: power consumption in Watts
  • data15num: number of processes
  • data16num: age of data (all sensors) in seconds
  • data17num: voltage in Volts
  • data18num: current consumption in Ampere
  • data19num: kilobytes of data sent (including web interface traffic)
  • data20num: kilobytes of data received (including web interface traffic)

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
  • lastval: same as "act" but does not switch to "invalid" when hold time has passed.
  • prev: data just reported before current data
  • hmin: minimum value of this hour
  • hmax: maximum value of this hour
  • havg: average value of this hour
  • dmin: minimum value of today
  • dmax: maximum value of today
  • davg: average value of today
  • ydmin: minimum value of yesterday
  • ydmax: maximum value of yesterday
  • ydavg: average value of yesterday
  • mmin: minimum value of this month
  • mmax: maximum value of this month
  • mavg: average value of this month
  • ymin: minimum value of this year
  • ymax: maximum value of this year
  • yavg: average value of this year
  • amin: minimum value of all time
  • amax: maximum value of all time
  • aavg: average value of all time

Sensors that deliver cumulated data like "rain0total", "sol0evo" and "sun0total" should be used with the following selectors only:

  • hoursum, daysum or sumday, monthsum, yearsum, allsum, ydaysum: selects summarized delta values from today, this month, this year, all time or yesterday. Example: "rain0total-sumday" is todays rain fall.

Sensor wind0maxdir does only support hmax, dmax, ydaymax, mmax, ymax, amax. All other selectors do not report useful data.

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
  • lasttime: timestamp of last occurrence of sensor data
  • nonzerotime: timestamp of last occurrence of a nonzero 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 suppressed.

  • age: reports seconds elapsed since last reception of data for that particular sensor.
  • hold: reports seconds elapsed since last reception of data for that particular sensor, but returns invalid value when age is beyond data hold period of 300 seconds. This allows to return invalid status instead large number of seconds for sensors having dropped off long time ago.
  • prevtime1, prevtime2 ...: selects the timestamp of the sensor data 1, 2, ... iterations in the past. Looking into the past is not done in term of a time frame, but occurrences of data records for this sensor is counted back.

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

  • val1, val1, val3, ..., val60: selects the value the sensor has shown one to 60 minutes ago (This is only available for sensors with ID 0 and 1, like "th0temp" or "th1temp", unless you have a Meteobridge PRO).
  • max1, max2, max3, ..., max60: selects the maximum value from the last one to 60 minutes
  • min1, min2, min3, ..., min60: selects the minimum value from the last one to 60 minutes
  • avg1, avg2, avg3, ..., avg60: selects average value from the last one to 60 minutes

For sensors delivering cumulated values like "rain0total" and "sol0evo" the following selectors are defined:

  • sum1, sum2, sum3, ..., sum60, sum1h, sum2h, sum3h, ..., sum24h: selects summarized delta values from the last one to 60 minutes or one to 24 hours. This is useful to get amount of total rain in a certain time frame: "rain0total-sum60" is rainfall in mm of last 60 minutes.
  • delta1, delta2, delta3, ..., delta60, delta1h, delta2h, delta3h, ..., delta24h: selects difference between current value and value from one to 60 minutes or one to 24 hours ago. A positive number shows that value has increased, a negative number indicates the value has decreased. This is useful to do trend analysis over various time spans.
  • prev1, prev2, ...: selects the value of the sensor data 1, 2, ... iterations in the past. Looking into the past is not done in terms of a time frame, but occurrences of data records for this sensor are counted back.

Meteobridge PRO Additions (available on PRO, PRO2, NANO SD, RPI)

Selectors val, min, max, avg, sum, count, mintime, maxtime can be combined with a "@YYYYMMDDhh" specifier, which determines the point in time where the data should be taken from. This specifier also defines if data should be used on a per hour, per day, per month or per year resolution. To get data in a per hour resolution the specifier needs to define the point in time down to the hour. Example: "min@2015121909" selects minimum data from December 19, 2015 09:00 until 9:59 (on a per hour base). This is how the specifier works:

  • @YYYY selects data for the specified year. Example: Using "[th0temp-min@2015]" in a template will report minimum outdoor temperature of 2015. When "YYYY" is not defining a valid year but is in the range of "0000" to "0010" then "0000" is interpreted as the current year, "0001" as the previous year and so on. In that situation the 4 digit number expresses how many years to skip into the past. These skips need to be in 4-digit style, leading zeros are not allowed to be omitted.
  • @YYYYMM selects data for the specified month. Example: Using "[wind0wind-max@201509]" in a template will report maximum wind speed (gust) of September 2015.
  • @YYYYMMDD selects data for the specified day. Example: Using "[rain0total-sum@20151031]" in a template will report total rainfall on October 31, 2015.
  • @YYYYMMDDhh selects data for the specified hour. Example: Using "[uv0index-avg@2015110316]" in a template will report average UV index on November 3, 2015 between 16:00 and 16:59.

Please be aware that these requests are directly requesting data from the persistent database only. Therefore, when requesting data from periods of time that are not yet complete, data from the started but not finished hour will not be reported.

In addition to specify an absolute point in time (as explained above) you can also use points in time relative to now. Relative points in time can be specified in terms of years, months, days, hours and minutes as follows:

  • @Yn addresses yearly data n years in the past. Example: When you are in 2016 and specify "[th0temp-max@Y1]" it will return the maximum outdoor temperature of last year (2015), while "@Y3" will address data from 2013.
  • @Mn addresses monthly data n months in the past. Example: "[wind0wind-max@M0] will return max wind speed of current month, while "[wind0wind-max@M1]" will return max wind speed of previous month.
  • @Dn addresses daily data n days in the past. Example: "[th0temp-min@D7]" will return minimum outdoor temperature of the current day, one week in the past.
  • @hn addresses hourly data n hours in the past.

Limitations on not yet completed time periods apply as with the @YYYYMMDDhh format.

val will give same results as average and only makes sense on a per minute base, where data of that minute is reported. It can also be averaged, when more than one sensor reading has occurred during that minute.

mintime and maxtime report time stamp down to the second when minimum/maximum value of defined time frame has occurred.

mcount, ycount and acount are selectors defined for rainXtotal sensors and report the number of days with rainfall within the current month (mcount), year (ycount) and total observation time (acount). Example: [rain0total-mcount:--] reports number of days with rain in current month. rain day counts can be used with selector "count" in combination with point in time notations. Example: [rain0total-count@202312:--] reports number of days with rain in December 2023.

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 or inch converts millimeters to inches.
  • ft' or feets converts meters to feet.
  • mls converts kilometers to miles.
  • endir converts a wind direction into one of 16 English direction texts.
  • nldir converts a wind direction into one of 16 Dutch direction texts.
  • dedir converts a wind direction into one of 16 German direction texts.
  • barotrend converts a delta measurement (selector delta) into a barometer trend analysis pattern (1 hPa is about 0.03 inHg):
    • -2: delta <= -2 hPa
    • -1: -2 hPa < delta <= -1 hPa
    • 0: -1 hPa < delta < +1 hPa
    • +1: +1 hPa <= delta < +2 hPa
    • +2: +2 hPa <= delta
  • enbarotrend reports trend as strings FF, FS, ST, RS, RF

Converters "F", "psi", "mmHg", "inHg", "kmh", "mph", "kn", "bft", "in", "ft" can be followed by a multiplier. For example: Converter "F10" tells that temp data of sensor will be converted to degrees of Fahrenheit and multiplied by 10 or to say it the other way round the data will be represented in 1/10 degrees of Fahrenheit. As a special case a converter can also just be a multiplier. In that case the multiplier is applied without conversion of units. Multipliers with decimals like "1.5" need to be represented as "1,5" as the dot will be interpreted as the start of the "decimal" section of the variable. Beside multipliers you can also specify offsets, which have to be positioned after the multiplier and start with a "+" or "-". Example: "inhg-0,3-2,3" will convert data from hPa to inHg, will multiply the result with -0.3 and will subtract 2.3 after that.

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

  • utc reports timestamp in UTC instead of localtime, which is default.
  • apm reports timestamp as local time in AM/PM style. Example "201603011123344AM" indicates "2016 March 11, 12:33:44 AM".

Forecast Variables

When you are using a Davis Vantage station, it provides a couple of forecast rules, which Meteobridge can report via template variables. All forcast variables start with sensor name "forecast" followed by one of these selectors:

  • rule: reports Vantage rule number. When no rule present (or not a Vantage this will be a negative number).
  • text: reports forecast text in English
  • textde: reports in German (UTF-8 coded)
  • textdeiso: reports in German (ISO-8859 coded)
  • textdehtml: reports in German (HTML coded)
  • textit: reports in Italian
  • textnl: reports in Dutch
  • textest: reports in Estonian (UTF-8 coded)
  • texthr: reports in Hungarian (HTML coded)
  • textcz: reports in Czech (UTF-8 coded)
  • textfr: reports in French (UTF-8 coded)
  • texteshtml: reports in Spanish (HTML coded)

When converter "us" is added, all blanks are replaced by underscores.

System Variables

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

  • mac: Meteobridge MAC hardware address (example: "40:01:FE:23:12:A8")
  • swversion: Meteobridge version string (example: "1.1")
  • buildnum: build number as integer (example: 1673)
  • platform: string that specifies hw platform (example: "TL-MR3020")
  • station: string that specifies selected weather station (example: "WMR-200")
  • stationnum: integer that specifies selected weather station (example: 49)
  • language: language used on Meteobridge's web interface (example: "English")
  • timezone: defined timezone (example: "Europe/Berlin")
  • altitude: defined station altitude in meters
  • latitude: latitude as float (example: 53.875120)
  • longitude: longitude as float (example: 9.885357)
  • uptime: uptime of Meteobridge in seconds
  • cpuload1m, cpuload5m, cpuload15m shows average cpu load during last 1, 5, 15 minutes
  • ip: IP address
  • lanip: IP address on the LAN port (if connected)
  • wlanip: IP address of the WLAN (if connected)
  • lastdata: seconds passed since last piece of data received from weather station, returns -1 if no data received. Does not distinguish between useful and useless garbage data
  • lastgooddata: seconds passed since last piece of meaningful sensor data recorded, returns -1 if no sensor data recorded so far
  • solarmax: maximum possible solar radiation on that day at that point of the earth. Needs latitude and longitude set and pressure data available.
  • lunarage: days passes since new moon as integer (example: 28)
  • lunarpercent: lunarphase given as percentage from 0% (new moon) to 100% (full moon)
  • lunarsegment: lunarphase segment as integer (0 = new moon, 1-3 = growing moon: quarter, half, three quarters, 4 = full moon, 5-7 = shrinking moon: three quarter, half, quarter)
  • daylength: length of day (example: "11:28")
  • daylengthmin: length of shortest day of the year
  • daylengthmax: length of longest day of the year
  • civildaylength: alternative method for day length computation (example: "12:38")
  • civildaylengthmin: length of shortest day of the year according to civil day length computation
  • civildaylengthmax: length of longest day of the year according to civil day length computation
  • nauticaldaylength: alternative method for day length computation (example: "14:00")
  • nauticaldaylengthmin: length of shortest day of the year according to nautical day length computation
  • nauticaldaylengthmax: length of longest day of the year according to nautical day length computation
  • sunrise: returns time of astronomical sunrise in local time. Can be converted to UTC by applying "=utc" to the variable (example: "06:47", resp. "05:47") or can be converted to 12h time mode by applying "=apm" (example: "8:45AM").
  • sunset: returns time of astronomical sunset in local time. Can be converted to UTC by applying "=utc" to the variable (example: "18:15", resp. "17:15") or can be converted to 12h time mode by applying "=apm" (example: "12:45AM").
  • civilsunrise, civilsunset, nauticalsunrise, nauticalsunset: alternative computations for sunset and sunrise. These can also be converted to UTC ("=utc") or AM/PM ("=apm") as "sunrise and sunset".
  • daynightflag: returns "D" when there is daylight, otherwise "N" (civil sunrise/sunset is used as reference).
  • isday: returns "1" when there is daylight, otherwise "0" (civil sunrise/sunset is used as reference).
  • isnight: returns "0" when there is daylight, otherwise "1" (civil sunrise/sunset is used as reference).
  • moonrise: time of moonrise in local time. Can be converted to UTC or AP/PM notation by applying "=utc" resp. "=apm" 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 converted to UTC or AP/PM notation by applying "=utc" resp. "=apm" 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")
  • graphA: returns URL of the user's Meteoplug chart "*instruments-black"
  • graphB: returns URL of the user's Meteoplug chart "*instruments-black-imp"
  • graphC: returns URL of the user's Meteoplug chart "*iphone-black"
  • graphD: returns URL of the user's Meteoplug chart "*iphone-black-imp"
  • graphE: returns URL of the user's Meteoplug chart "*iphone-tw-2d"
  • graphF: returns URL of the user's Meteoplug chart "*iphone-tw-2d-imp"
  • graphG: returns URL of the user's Meteoplug chart "*iphone-pr-2d"
  • graphH: returns URL of the user's Meteoplug chart "*iphone-pr-2d-imp"
  • primarysensors: sets template evaluation to use sensors marked as primary on "Live Data" tab as the "0" ones (thb0, th0, wind0, rain0, etc...)
  • noprimarysensors: sets template evaluation to use sensors as literally named
  • totalstorage: reports total storage in MB (only valid for PRO, PRO2, NANO SD, RPI)
  • freestorage: reports free storage in MB (only valid for PRO, PRO2, NANO SD, RPI)
  • usedstorage: reports used storage in MB (only valid for PRO, PRO2, NANO SD, RPI)


Converters for System Variables

Meteobridge supports converters to be applied to day length computations. Normally day length values are reported in a "HH:MM" fashion. This can be altered in the following ways:

  • secs converter returns day length information as number of seconds
  • mins converter returns day length information as number of minutes (can have decimals)
  • hours converter returns day length information as number of hours (can have decimals)

Timestamps can also be converted in various ways. Normal output is 24h notation "HH:MM" in local time. These converters can be applied:

  • utc reports timestamp in UTC instead of local time
  • apm reports timestamp in American AM/PM style
  • epoch reports timestamp as Linux epoch time (seconds since Jan 1, 1970)

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
  • MMM: month as three character English abbreviation ("Jan", Feb", ...)
  • mmm: month as three character English abbreviation in lower case ("jan", feb", ...)
  • MM: month as two digit number, if only one digit needed a zero will be used as first digit
  • M: month as one or two digit number, no leading zeros, January is 1.
  • M0: month as one or two digit number, no leading zeros, January is 0.
  • DD: day of month as two digit number, if only one digit needed a zero will be used as first digit
  • D: day of month as one or two digit number, no leading zeros, first day of month is 1
  • D0: day of month as one or two digit number, no leading zeros, first day of month is 0
  • DDD: day of week as three character English abbreviation ("Sun", "Mon", ...)
  • ddd: day of week as three character English abbreviation in lower case ("Sun", "Mon", ...)
  • hh: hour in 24h notation as two digit number, if only one digit needed a zero will be used as first digit
  • h: hour in 24h notation as one or two digit number, no leading zeros
  • HH: hour in 12h notation as two digit number, if only one digit needed a zero will be used as first digit
  • H: hour in 12h notation as one or two digit number, no leading zeros
  • apm: returns "am" or "pm" to be added to 12h time notations
  • APM: returns "AM" or "PM" to be added to 12h time notations
  • mm: minute as two digit number, if only one digit needed 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 needed 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")

  • epoch: epochtime as defined in Unix (seconds since January 1, 1970)

Decimals

Unless otherwise defined numbers are reported with one decimal. By specifying a value for "decimals" you can determine resolution of presented values. When the value consists of zeros only (no decimals required) output will be filled up with leading zeros to match the length of the given pattern. Example: [th0temp-act.000:--] will result to "008" when outdoor temperature is 8.2° Celsius.

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 letter 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.

When a number is given instead of a substring qualifier, then the number defines the number of characters the resulting string is padded to. When the number is smaller than the string length, then only rightmost characters remain, otherwise the string is added with leading blanks to make it's size fit. When the number is negative, then string is cut on the right side resp. trailing blanks are added. Example: Assume that wind direction is "ENE" then :[wind0dir-act=endir.5]:[wind0dir-act=endir.-5]: will result into : ENE:ENE  :

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.

Numerical Expressions

A numerical expression that Meteobridge should evaluate needs to be enclosed by {* and *}. The enclosed expression can also include template variables. This allows to do various computations with numerical data. Resulting value is returned with two decimals. You can define how many digits the return value should have by stating the number of decimals betwenn the * and } when closing the numerical expression. For example, *0} does set number of decimals to 0, which will return a rounded integer value. When you are looking for a non-rounded, truncated integer then *t} will do the job. When you need an output with a certain number of leading zeros, you can specify this the same way as explained in "Decimals" paragraph on this page.

The following operators can be used within numerical expressions:

operators in increasing precedence (from top to bottom)
Operator / Function 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", "divide" and "modulus" (which rounds the operands to integers first)
^ arithmetic operator "power"
max, min selection operators "max", "min" which select left or right operand by comparison
sqrt(), log(), exp(), sin(), asin(), cos(), acos(), tan(), atan(), atan2(), abs(), fabs(), floor(), ceil(), round() arithmetic functions: square root, logarithm, logarithmic exponent, sinus, arcus sinus, cosinus, arcus cosinus, tangens, arcus tangens, arcus tangens2, absolute, floating point absolute, lower integer, upper integer, rounded integer. Please remind that there must not be a space between function name and the parameter brackets, otherwise computation will fail. "sqrt(...)" is fine, "sqrt (...)" will fail.

To override operator precedence, brackets "(" and ")" can be used as usual.

Conditional Expressions

Templates can work with simple conditional expressions. These expressions are not allowed to be used recursive and they must be used on top-level, i.e. not inside numerical expressions. Expressions must be built in a strict #if# ... #then# ... #else# ... #fi# manner.

  • #if# indicates start of the expression.
  • Between #if# and #then# a number is expected. Blanks will be ignored. If number is greater than 0.0 the expression is recognized as true otherwise as false.
  • In case of true expression, characters between #then# and #else# token will be used to replace the whole conditional expression in the template.
  • In case of false expression, characters between #else# and #fi# token will be used to replace the whole conditional expression in the template.

As conditional expressions will be evaluated at the very end, any template replacement operations or numerical computations will be done before.


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.
  4. Template Max gust in last 10 minutes was: [wind0wind-max10.1:0]m/s, {*[wind0wind-max10.1:0] * 3.6 *1}kph will be converted into Max gust in last 10 minutes was: 10.5m/s, 37.8kph.
  5. Template Max gust in last 10 minutes was: #if#{*[wind0wind-age:999]>600*}#then#--#else#[wind0wind-max10.1:0]m/s, {*[wind0wind-max10.1:0] * 3.6 *1}kph#fi# will be converted into Max gust in last 10 minutes was: 10.5m/s, 37.8kph when last wind data is less than 10 minutes old (600 seconds) and will be Max gust in last 10 minutes was: -- otherwise.
  6. Template [th0temp-dmintime=apm.ij]:[th0temp-dmintime=apm.kl][th0temp-dmintime=apm.op] reports the time stamp of lowest outdoor temperature of today in 12 hour AM/PM notation: 12:34AM

</translate>