Einfach in ein Skript kopieren und ausführen. Der Klimafaktor wird immer mit 6 Wochen Verzögerung zur Verfügung gestellt. Man sollte den Wert also immer erst nach dem 15. eines Monats aktualisieren.
<?php
$plz = "23554";
$date_end = strtotime("last day of -2 months");
$date_start = strtotime("first day of -13 months");
//echo date("d.m.Y", $date_start) . " -> " . date("d.m.Y", $date_end);
$file = "KF_" . date("Ymd", $date_start) . "_" . date("Ymd", $date_end) . ".xml";
$url = "https://opendata.dwd.de/climate_environment/CDC/derived_germany/techn/monthly/climate_correction_factor/recent/" . $file;
$data = file_get_contents($url);
$xml = simplexml_load_string($data);
foreach($xml as $node) {
if ($node->KLFK_POLZ == $plz) {
SetValue(CreateVariableByIdent($_IPS['SELF'], "KLIMAFAKTOR", "Klimafaktor", 2), floatval($node->KLIMAFAKTOR));
break;
}
}
function CreateVariableByIdent($id, $ident, $name, $type, $profile = "") {
$vid = @IPS_GetObjectIDByIdent($ident, $id);
if($vid === false) {
$vid = IPS_CreateVariable($type);
IPS_SetParent($vid, $id);
IPS_SetName($vid, $name);
IPS_SetIdent($vid, $ident);
if($profile != "")
IPS_SetVariableCustomProfile($vid, $profile);
}
return $vid;
}