Difference between revisions of "Add-On Services/en"

From meteobridge
Jump to: navigation, search
(Importing a new version from external source)
 
(8 intermediate revisions by 2 users not shown)
Line 4: Line 4:
  
 
===Live Data as XML===
 
===Live Data as XML===
By sending the meteobridge a HTTP request like "http://ip-of-meteobridge/cgi-bin/livedataxml.cgi" (where "ip-of-meteobridge" must be replaced by the IP itself) meteobridge returns current weather data in XML notation. Each reply starts witch tag <logger> and ends with </logger> with the sensor data as records with sensor specific tags "THB", "TH", "WIND", "RAIN", "UV", "SOLAR". Example below illustrates the XML format:
+
By sending the meteobridge a HTTP request like "http://ip-of-meteobridge/cgi-bin/livedataxml.cgi" (where "ip-of-meteobridge" must be replaced by the IP itself) meteobridge returns current weather data in XML notation. Each reply starts witch tag <logger> and ends with </logger> with the sensor data as records with sensor specific tags "THB", "TH", "SOIL", "LEAF", "WIND", "RAIN", "UV", "SOLAR". Example below illustrates the XML format:
  
 
<pre><logger>
 
<pre><logger>
Line 18: Line 18:
 
* '''id''': Unique ID of sensor, consists of a sensor type description shortcut followed by a number, which is always "0" in Meteobridge, as additional sensors are not supported
 
* '''id''': Unique ID of sensor, consists of a sensor type description shortcut followed by a number, which is always "0" in Meteobridge, as additional sensors are not supported
 
* '''temp''': temperature in degrees Celsius (with one decimal)
 
* '''temp''': temperature in degrees Celsius (with one decimal)
* '''hum''': relative humidity in percent (no decimals)
+
* '''hum''': relative humidity in percent (no decimals) with humidity sensors. With leaf and soil sensors unit is wetness or centibar.
 
* '''dew''': dew point temperature in degrees Celsius (with one decimal)
 
* '''dew''': dew point temperature in degrees Celsius (with one decimal)
 
* '''press''': station pressure (without altitude correction) in hPa (with one decimal)
 
* '''press''': station pressure (without altitude correction) in hPa (with one decimal)
Line 40: Line 40:
 
20130104142652 wind0 160 2.2 1.8 8.0</pre>
 
20130104142652 wind0 160 2.2 1.8 8.0</pre>
  
===Live-Daten über eine Socket-Verbindung===
+
===Live Data via Socket Connection===
Bei den oben angegebenen Verfahren wird eine HTTP-Authentifizierung wie für das gesammte Meteobridge Web-Interface benötigt. Wenn man sich das Skript "livedataxml.cgi" ansieht, kann man erkennen, dass dieses ledglich Daten vom Port 5557 liest, mit einem HTTP-Header versieht und dann an den anfragenden Browser ausliefert:
+
Methods introduced above do need HTTP authentification like all elements of Meteobridge web interface. A look at the script "livedataxml.cgi" shows that this just reads data from socket 5557, gives it a suitable HTTP header and returns that to the requesting browser:
  
 
<pre>#!/bin/sh
 
<pre>#!/bin/sh
Line 48: Line 48:
 
</pre>
 
</pre>
  
Im Ergebnis entspricht ein Auslesen des Ports 5557 dem Aufruf von "livedataxml.cgi" und eine Abfrage von Port 5556 dem Skript "livedata.cgi".
+
Therefore, reading data from socket 5557 is equivalent to calling "livedataxml.cgi" and socket 5556 reports same data as delivered by "livedata.cgi".
  
===Template-basierende individuelle Daten===
+
===Template-based Individual Data===
Der vorangegangenen Skripte liefern Daten in einem Standardformat aus. Unter Verweundung des Meteobridge-Template-Mechanismus, der auch hier im Wiki beschriebven ist, kann mit dem Skript "template.cgi" eine angepasste Ausgabe von Meteobridge-Variablen in Form eines mit Daten gefüllten Templates erreicht werden.
+
Scripts presented before return data in a standard format. As a variant you can also define a template like explained in Template section of this wiki, hand that over to "template.cgi" script and get a filled template in return.
  
Das Skript wird mit der URL "http://ip-of-meteobridge/cgi-bin/template.cgi" aufgerufen. Dabei ist das zu füllendenTemplate als Parameter in der Form "template=DEIN_TEMPLATE_TEXT" mitzugeben. Als optionaler Parameter kann der in der HTTP-Antwort zu verwendende Content-Type mitgegeben über "contenttype=CONTENT_TYPE" mitgegeben werden. Beide Parameter müssen URL-encoded übergeben werden, wobei Sonderzeichen als "%XX" (XX ist der zweistellige Hexadezimalkode) und Leerzeichen als "+" zu spezifizieren sind.
+
URL to call is "http://ip-of-meteobridge/cgi-bin/template.cgi" with mandatory parameter "template=YOUR_TEMPLATE_TEXT" and optional paramater "contenttype=CONTENT_TYPE". Both parameters have to be URL-encoded with special characters represented as "%XX" (where XX is a two digit hex code) and spaces are represented by "+".
  
Beispiel: Um die aktuelle Außentemperatur und Feuchte zu erhalten, liefert die URL <pre>http://ip-of-meteobridge/cgi-bin/template.cgi?template=[DD].[MM].[YY]+[HH]:[mm][APM]%0D[th0temp-act]%BAC%0d[th0hum-act]%25&contenttype=text/plain;charset=iso-8859-1</pre>
+
Example: In oder to get current outdoor temp and humidity this URL<pre>http://ip-of-meteobridge/cgi-bin/template.cgi?template=[DD].[MM].[YY]+[HH]:[mm][APM]%0D[th0temp-act]%BAC%0d[th0hum-act]%25&contenttype=text/plain;charset=iso-8859-1</pre>
die folgende Ausgabe <pre>01.06.13 04:55PM
+
returns <pre>01.06.13 04:55PM
 
23.2ºC
 
23.2ºC
 
61.0%</pre>
 
61.0%</pre>
 +
 +
==Additional Features of Meteobridge PRO==
 +
Meteobridge PRO allows to store templates in the PC network share "/data/templates/". By calling "http://ip-of-meteobridge/cgi-bin/template.cgi?templatefile=mydata.http" the file "mydata.http" from share "/data/templates" is filled with data and returned to the requestor.
 +
 +
Example: There is a template file "mydata.http" defined in the templates folder:
 +
<pre>[DD].[MM].[YY] [HH]:[mm][APM]
 +
[th0temp-act]°C
 +
[th0hum-act]%</pre>
 +
Request "http://ip-of-meteobridge/cgi-bin/template.cgi?templatefile=mydata.http&contenttype=text/plain;charset=utf-8" returns this:
 +
<pre>08.01.16 11:00AM
 +
3.5°C
 +
94.0%</pre>

Latest revision as of 14:20, 5 March 2016

<languages />
Web server of Meteobridge client, which presents web interface for adminstration to you, can also deliver weather data. There are three URLs defined that can be polled to get most recent sensor data in a standard XML or plain text format or in user-defined format. Although we don't recommend this for security reasons, you can make that URLs accessible from the Internet by configuring your router appropriately. However, when you want to bring sensor data to one of your own servers in the Internet we recommend to make use of Meteobridge's Push Services, which will not need you to open up your firewall. Remark: In order to reach these HTTP services you need to handle basic authentification by adding "<username>:<password>@" in front of the URL.

Live Data as XML

By sending the meteobridge a HTTP request like "http://ip-of-meteobridge/cgi-bin/livedataxml.cgi" (where "ip-of-meteobridge" must be replaced by the IP itself) meteobridge returns current weather data in XML notation. Each reply starts witch tag <logger> and ends with </logger> with the sensor data as records with sensor specific tags "THB", "TH", "SOIL", "LEAF", "WIND", "RAIN", "UV", "SOLAR". Example below illustrates the XML format:

<logger>
  <THB date="20121227224318" id="thb0" temp="26.0" hum="37" dew="10.2" 
       press="1008.8" seapress="1010.1" fc="2"/>
  <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>

Each sensor data record has a mandatory "date" and "id" parameter. The other parameters are sensor specific. Meaning of parameters is:

  • date: UTC timestamp of reception of sensor data in format "YYYYMMDDhhmmss"
  • id: Unique ID of sensor, consists of a sensor type description shortcut followed by a number, which is always "0" in Meteobridge, as additional sensors are not supported
  • temp: temperature in degrees Celsius (with one decimal)
  • hum: relative humidity in percent (no decimals) with humidity sensors. With leaf and soil sensors unit is wetness or centibar.
  • dew: dew point temperature in degrees Celsius (with one decimal)
  • press: station pressure (without altitude correction) in hPa (with one decimal)
  • seapress: normalized pressure with altitude correction (also called sea level pressure) in hPa (with one decimal)
  • fc: stations forecast code, if provided. As this has low evidence and also largely varies between stations, meteobridge does not recommend to make use of this data.
  • rate: measured rain rate in mm per hour (with one decimal).
  • total: current value of rain bucket counter, converted to mm (with one decimal).
  • delta: additional rain fall in mm since previous readout of this data (with one decimal).
  • wind: current average wind speed im m/s (with one decimal).
  • gust: curent not avergaed wind speed in m/s (with one decimal).
  • dir: wind direction in degrees (0-359, no decimals).
  • chill: wind chill temperature in degrees Celsius (with one decimal).
  • more to come...

Live Data as Plain Text

By sending the meteobridge a HTTP request like "http://ip-of-meteobridge/cgi-bin/livedata.cgi" (where "ip-of-meteobridge" must be replaced by the IP itself) meteobridge returns current weather data as plain text. Each reply consists of a series of lines, where each line represnets a sensor. Lines do start with a time stamp and a unique sensor id followed by sensor specific parameters. Example below illustrates the format:

20130104142614 thb0 26.9 38 11.4 1020.4 1021.7 2
20130104142610 rain0 0.0 3.0 0.0
20130104142636 th0 9.1 95 8.3
20130104142652 wind0 160 2.2 1.8 8.0

Live Data via Socket Connection

Methods introduced above do need HTTP authentification like all elements of Meteobridge web interface. A look at the script "livedataxml.cgi" shows that this just reads data from socket 5557, gives it a suitable HTTP header and returns that to the requesting browser:

#!/bin/sh
echo -ne "Content-type: text/xml; charset=UTF-8\n\n"
nc 127.0.0.1 5557 2>/dev/null

Therefore, reading data from socket 5557 is equivalent to calling "livedataxml.cgi" and socket 5556 reports same data as delivered by "livedata.cgi".

Template-based Individual Data

Scripts presented before return data in a standard format. As a variant you can also define a template like explained in Template section of this wiki, hand that over to "template.cgi" script and get a filled template in return.

URL to call is "http://ip-of-meteobridge/cgi-bin/template.cgi" with mandatory parameter "template=YOUR_TEMPLATE_TEXT" and optional paramater "contenttype=CONTENT_TYPE". Both parameters have to be URL-encoded with special characters represented as "%XX" (where XX is a two digit hex code) and spaces are represented by "+".

Example: In oder to get current outdoor temp and humidity this URL
http://ip-of-meteobridge/cgi-bin/template.cgi?template=[DD].[MM].[YY]+[HH]:[mm][APM]%0D[th0temp-act]%BAC%0d[th0hum-act]%25&contenttype=text/plain;charset=iso-8859-1
returns
01.06.13 04:55PM
23.2ºC
61.0%

Additional Features of Meteobridge PRO

Meteobridge PRO allows to store templates in the PC network share "/data/templates/". By calling "http://ip-of-meteobridge/cgi-bin/template.cgi?templatefile=mydata.http" the file "mydata.http" from share "/data/templates" is filled with data and returned to the requestor.

Example: There is a template file "mydata.http" defined in the templates folder:

[DD].[MM].[YY] [HH]:[mm][APM]
[th0temp-act]°C
[th0hum-act]%

Request "http://ip-of-meteobridge/cgi-bin/template.cgi?templatefile=mydata.http&contenttype=text/plain;charset=utf-8" returns this:

08.01.16 11:00AM
3.5°C
94.0%