Difference between pages "Add-On Services/de" and "Templates"

From meteoplug
(Difference between pages)
Jump to: navigation, search
 
 
Line 1: Line 1:
 
__NOTOC__
 
__NOTOC__
<languages /><br />Der in Meteobridge enthaltene Web-Server kann neben der Realisierung des Administrationsinterfaces auch Anfragen zu den aktuell vorliegenden Wetterdaten beantworten. Es sind zwei URLs definiert, unter denen man diese Daten abrufen kann, entweder als Textdatei oder als XML-Datenstrom. Auch wenn es aus Sicherheitsgründen nicht empfehlenswert ist, diesen Zugang für einen Zugriff von außerhalb des LANs zu öffnen, könnte man beim Aufschalten der Firewall des LANs diese Art der Abfragemöglichkeit für Anfragen von Außen zugänglich machen. Für die Anlieferung von Daten ins Internet empfehlen sich die die unter [[Push_Services/de|Sendedienste]] aufgeführten Methoden.
+
<languages /><translate>
+
<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.
===Live-Daten als XML===
+
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.
Mit dem Meteobridge HTTP-Request wie "http://ip-of-meteobridge/cgi-bin/livedataxml.cgi", wobei "ip-of-meteobridge" durch die korrekte IP der Meteobridge ersetzt werden muss, liefert Meteobridge Wetterdaten in XML-Notation aus. Die von Meteobridge erzeugte Ausgabe beginnt mit "<logger>" und endet mit "</logger>". Die Werte der Sensoren werden mit den sensorspezifischen Tags "THB", "TH", "WIND", "RAIN", "UV", "SOLAR" berichtet. Das anhängende Beispiel illustriert das XML-Format:
+
  
<pre><logger>
+
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>
  <THB date="20121227224318" id="thb0" temp="26.0" hum="37" dew="10.2"
+
"converter", "decimals" and "replacement" can be omitted, "sensor" and "type" are mandatory.
      press="1008.8" seapress="1010.1" fc="2"/>
+
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.
  <TH date="20130104141909" id="th0" temp="9.1" hum="95" dew="8.3"/>
+
  <RAIN date="20130104141856" id="rain0" rate="0.0" total="3.0" delta="0.0"/>
+
  <WIND date="20130104141916" id="wind0" dir="109" gust="0.9" wind="2.2" chill="9.1"/>
+
</logger></pre>
+
  
Jedes Sensordatenpaket enthält immer die Felder "date" und "id". Die anderen Parameter sind sensorspezifisch. Die Bedeutung der Parameter ist wie folgt:
+
==Sensors==
* '''date''': UTC Zeitstempel der Sensordaten im Format "JJJJMMTThhmmss"
+
These sensors are defined in Meteobridge.
* '''id''': ID des Sensors, die aus einem Sensorkurzbezeichnung gefolgt von einer Zahl ("0") besteht.
+
* '''th0temp''': outdoor temperature in degrees Celsius
* '''temp''': Temperatur in Grad Celsius (mit einer Nachkommastelle)
+
* '''th0hum''': relative outdoor humidity as percentage
* '''hum''': Relative Luftfeuchte in Prozent (keine Nachkommastellen)
+
* '''th0dew''': outdoor dew point in degrees Celsius
* '''dew''': Taupunkttemperatur in Grad Celsius (mit einer Nachkommastelle)
+
* '''thb0temp''': indoor temperature in degrees Celsius
* '''press''': Luftdruck auf Stationshöhe ohne Höhenkorrektur in hPa (mit einer Nachkommastelle)
+
* '''thb0hum''': indoor humidity as percentage
* '''seapress''': Luftdruck auf Meeresspiegelhöhe zurückgerechnet in hPa (mit einer Nachkommastelle)
+
* '''thb0dew''': indoor dewpoint in degrees Celsius
* '''fc''': Vorhersage, sofern von der Wetterstation bereitgestellt. Da dieser Wert wenig zuverlässig ist, raten wir davon ab, diesen zu verwenden.
+
* '''thb0press''': station pressure in hPa
* '''rate''': Regenrate in mm pro Stunde (mit einer Nachkommastelle).
+
* '''thb0seapress''': normalized pressure (computed to sea level) in hPa
* '''total''': Aktueller Wert des Regenwippenzählers umgerechnet auf mm (mit einer Nachkommastelle).
+
* '''wind0wind''': wind speed in m/s
* '''delta''': Hinzugekommene Regenmenge in mm seit dem letzten Auslesen (mit einer Nachkommastelle).
+
* '''wind0avgwind''': average windspeed in m/s (time used for average depends on station)
* '''wind''': Aktuelle gemittelte Windgeschwindigkeit im m/s (mit einer Nachkommastelle).
+
* '''wind0dir''': wind direction in degress (0° is North)
* '''gust''': Aktuelle, nicht gemittelte Windgeschwindigkeit in m/s (mit einer Nachkommastelle).
+
* '''wind0chill''': wind chill temperature in degrees Celsius
* '''dir''': Windrichtung in Grad (0-359, keine Nachkommastellen).
+
* '''rain0rate''': rain rate in mm/h
* '''chill''': Windchill-Temperatur in Grad Celsius (mit einer Nachkommastelle).
+
* '''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.
  
===Live-Daten als Textdatei===
+
==Selectors==
Mit dem HTTP-Request "http://ip-of-meteobridge/cgi-bin/livedata.cgi", wobei "ip-of-meteobridge" durch die IP der Meteobridge zu ersetzen ist, gibt Meteobridge die aktuellen Sensorwerte als Textdatei aus. Das Ergebnis besteht aus einer Reiehe von Zeilen, die jeweils einen Sensor mit seinen Werten repräsentieren. Die Struktur ist gleich der XML-Daten im vorangegangenen Abschnitt, jedoch ohne die umgebende XML-Struktur:
+
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
 +
* '''hmin''': minimum value of this year
 +
* '''hmax''': maximum value of this year
 +
* '''hmin''': minimum value of all time
 +
* '''hmax''': maximum value of all time
 +
* '''daysum''', '''monthsum''', '''yearsum''', '''allsum''', '''ydaysum''': selects summerized delta values from today, this month, this year, all time or yesterday: "rain0total-sumday" is todays rain fall.
  
<pre>20130104142614 thb0 26.9 38 11.4 1020.4 1021.7 2
+
Apart from selectors that use absolute, predefined time slots there are also selectors that look for a certain amount of time into the past.
20130104142610 rain0 0.0 3.0 0.0
+
* '''max2''', '''max5''', '''max10''', '''max15''', '''max30''', '''max60''': selects the maximum value from the last 2, 5, 10, 15, 30 or 60 minutes
20130104142636 th0 9.1 95 8.3
+
* '''min2''', '''min5''', '''min10''', '''min15''', '''min30''', '''min60''': selects the minimum value from the last 2, 5, 10, 15, 30 or 60 minutes
20130104142652 wind0 160 2.2 1.8 8.0</pre>
+
* '''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.
 +
If an unknown conversion string is used, no conversion will take place, no error message will appear.
 +
 
 +
==Special Variables==
 +
There are a couple of variables that 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.
 +
 
 +
==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.
 +
 
 +
# 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;">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>.
 +
</translate>

Revision as of 23:33, 25 February 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
  • hmin: minimum value of this year
  • hmax: maximum value of this year
  • hmin: minimum value of all time
  • hmax: maximum value of all time
  • daysum, monthsum, yearsum, allsum, ydaysum: selects summerized delta values from today, this month, this year, all time or yesterday: "rain0total-sumday" is todays rain fall.

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

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

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

Special Variables

There are a couple of variables that 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.

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