<?php
/*
+---------------------------------------------------------------------+
| |
| SensorAndSwitch Automation Pro |
| PseudoGeräte-Script |
| =============================================================== |
| -> Wetter |
| openweathermap.org |
| Informationen von obiger Homepage für den Ort, der |
| anhand der in den Einstellungen eingelesenen Längen- und |
| Breitengraden ermittelt wurde. |
| |
+---------------------------------------------------------------------+
*/
error_reporting(0);
include "include/includedateien.php";
include "include/includefunctions.php";
include "include/includeconf.php";
include "include/includeconfig.php";
include "include/includedefine.php";
$url="http://api.openweathermap.org/data/2.5/weather?lat=".BREITENGRAD."&lon=".LAENGENGRAD."&mode=xml&units=metric&lang=de";
$ch = curl_init();
$timeout = 5;
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0)");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST,false);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER,false);
curl_setopt($ch, CURLOPT_MAXREDIRS, 10);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
$Status = curl_exec($ch);
curl_close($ch);
if ($Status) {
$Cont=simplexml_load_string($Status);
$Temp=number_format(sprintf('%.2f',$Cont->temperature->attributes()->value),2,",",".");
$Stadt=$Cont->city->attributes()->name;
$Symbol='<img src="http://openweathermap.org/img/w/'.$Cont->weather->attributes()->icon.'.png">';
$Wetter=$Cont->weather->attributes()->value;
echo "T#".sprintf('%.2f',$Cont->temperature->attributes()->value)."#P#".'<div style="font-size:14px;text-align:left;width:310px;position:relative;top:-20px;">'.$Symbol.'</div><div style="font-size:14px;text-align:left;width:310px;position:relative;top:-30px;left:0px;">'.$Wetter.'</div><div style="text-align:right;width:310px;position:relative;top:-65px;">'.'Temperatur: '.$Temp.'°C</div>'."*HTML#";
}
else {
echo "T##P##E##";
}
exit;
?>