Hallo Lucky,
hier meine Variante mit Pfadanpassung.
<?
// Hier den Ort angeben
$plz = "97828";
$land = "Germany";
$icons_src = "/";
$sprache = "de";
$ort = "Marktheidenfeld";
$icons_google = "/ig/images/weather/";
if($ort != "")
{
$station = $ort;
}
else
{
$station = $plz."-".$land;
}
$api = simplexml_load_string(utf8_encode(@Sys_GetURLContent("http://www.google.com/ig/api?weather=".$station."&hl=".$sprache)));
//print_r($api);
$wetter = array();
// Aktuelles Wetter
$wetter[0]['zustand'] = $api->weather->current_conditions->condition->attributes()->data;
$wetter[0]['temperatur'] = $api->weather->current_conditions->temp_c->attributes()->data;
$wetter[0]['luftfeuchtigkeit'] = $api->weather->current_conditions->humidity->attributes()->data;
$wetter[0]['wind'] = $api->weather->current_conditions->wind_condition->attributes()->data;
// Wettervorhersage heute, morgen, in zwei und in drei Tagen ($wetter[1] bis $wetter[4])
$i = 1;
foreach($api->weather->forecast_conditions as $weather)
{
$wetter[$i]['wochentag'] = $weather->day_of_week->attributes()->data;
$wetter[$i]['zustand'] = $weather->condition->attributes()->data;
$wetter[$i]['tiefsttemperatur'] = $weather->low->attributes()->data;
$wetter[$i]['hoechsttemperatur'] = $weather->high->attributes()->data;
$i++;
}
// Variablen im Pfad .Wettervorhersage löschen
$Vars = IPS_GetVariableList();
foreach($Vars as $ID)
{
if (strpos( IPS_Getlocation( $ID ), "Wettervorhersage" ) > 0)
{
IPS_DeleteVariable( $ID ) ;
}
}
//Variablen anlegen
//Festlegen wohin die Variable soll
$ID = CreateVariableByName($IPS_SELF, "Heute", 3, "");
SetValueString($ID,umlaute((string)$wetter[1]['zustand']) );
IPS_SetPosition($ID,1);
IPS_SetParent($ID, 43450 /*[Wetter\Wettervorhersage]*/);
$ID = CreateVariableByName($IPS_SELF, "Heute - min -", 2, "~Temperature");
SetValueFloat($ID,(float)$wetter[1]['tiefsttemperatur']);
IPS_SetPosition($ID,2);
IPS_SetParent($ID, 43450 /*[Wetter\Wettervorhersage]*/);
$ID = CreateVariableByName($IPS_SELF, "Heute - max -", 2, "~Temperature");
SetValueFloat($ID,(float)$wetter[1]['hoechsttemperatur']);
IPS_SetPosition($ID,3);
IPS_SetParent($ID, 43450 /*[Wetter\Wettervorhersage]*/);
$ID = CreateVariableByName($IPS_SELF, (string)$wetter[2]['wochentag'], 3, "");
SetValueString($ID,umlaute((string)$wetter[2]['zustand']));
IPS_SetPosition($ID,4);
IPS_SetParent($ID, 43450 /*[Wetter\Wettervorhersage]*/);
$ID = CreateVariableByName($IPS_SELF, (string)$wetter[2]['wochentag']." - min -", 2, "~Temperature");
SetValueFloat($ID,(float)$wetter[2]['tiefsttemperatur']);
IPS_SetPosition($ID,5);
IPS_SetParent($ID, 43450 /*[Wetter\Wettervorhersage]*/);
$ID = CreateVariableByName($IPS_SELF, (string)$wetter[2]['wochentag']." - max -", 2, "~Temperature");
SetValueFloat($ID,(float)$wetter[2]['hoechsttemperatur']);
IPS_SetPosition($ID,6);
IPS_SetParent($ID, 43450 /*[Wetter\Wettervorhersage]*/);
$ID = CreateVariableByName($IPS_SELF, (string)$wetter[3]['wochentag'], 3, "");
SetValueString($ID,umlaute((string)$wetter[3]['zustand']));
IPS_SetPosition($ID,7);
IPS_SetParent($ID, 43450 /*[Wetter\Wettervorhersage]*/);
$ID = CreateVariableByName($IPS_SELF, (string)$wetter[3]['wochentag']." - min -", 2, "~Temperature");
SetValueFloat($ID,(float)$wetter[3]['tiefsttemperatur']);
IPS_SetPosition($ID,8);
IPS_SetParent($ID, 43450 /*[Wetter\Wettervorhersage]*/);
$ID = CreateVariableByName($IPS_SELF, (string)$wetter[3]['wochentag']." - max -", 2, "~Temperature");
SetValueFloat($ID,(float)$wetter[3]['hoechsttemperatur']);
IPS_SetPosition($ID,9);
IPS_SetParent($ID, 43450 /*[Wetter\Wettervorhersage]*/);
$ID = CreateVariableByName($IPS_SELF, (string)$wetter[4]['wochentag'], 3, "");
SetValueString($ID,umlaute((string)$wetter[4]['zustand']));
IPS_SetPosition($ID,10);
IPS_SetParent($ID, 43450 /*[Wetter\Wettervorhersage]*/);
$ID = CreateVariableByName($IPS_SELF, (string)$wetter[4]['wochentag']." - min -", 2, "~Temperature");
SetValueFloat($ID,(float)$wetter[4]['tiefsttemperatur']);
IPS_SetPosition($ID,11);
IPS_SetParent($ID, 43450 /*[Wetter\Wettervorhersage]*/);
$ID = CreateVariableByName($IPS_SELF, (string)$wetter[4]['wochentag']." - max -", 2, "~Temperature");
SetValueFloat($ID,(float)$wetter[4]['hoechsttemperatur']);
IPS_SetPosition($ID,12);
IPS_SetParent($ID, 43450 /*[Wetter\Wettervorhersage]*/);
// Die nächsten Zeilen brauche ich nicht, da ich die Werte aus meiner Wetterstation hole
//preg_match_all("|(\d+){2,}|",$wetter[0]['luftfeuchtigkeit'],$hudimity);
//SetValueInteger(CreateVariableByName($IPS_SELF, "Luftfeuchtigkeit", 1, "~Humidity"),(integer)$hudimity[0][0]);
//SetValueString(CreateVariableByName($IPS_SELF, "Wind", 3, ""),substr((string)$wetter[0]['wind'], 6));
function umlaute( $text )
{
$suchen = array("ö","ü");
$ersetzen = array("ö","ü");
$text = str_replace($suchen, $ersetzen, $text);
return $text;
}
function CreateVariableByName($id, $name, $type, $profile = "")
{
global $IPS_SELF;
$vid = @IPS_GetVariableIDByName($name, $id);
if($vid === false)
{
$vid = IPS_CreateVariable($type);
IPS_SetParent($vid, $id);
IPS_SetName($vid, $name);
IPS_SetInfo($vid, "this variable was created by script #$IPS_SELF");
if($profile !== "") { IPS_SetVariableCustomProfile($vid, $profile); }
}
return $vid;
}
?>
Hab dir meinen Objektbaum als Datei angehängt.
Jürgen