Wettervorhersage

Ahoi :loveips:

ich habe auf die Schnelle mal ein Skript zusammengepfuscht, mit dem ich mir die stündliche und 10-tägige Vorhersage anzeigen lasse. Alle Daten kommen von der weather.com API und sind zugangsfrei - es braucht noch nicht mal einen Key.

Da ich dieses als Widget auf meinem Dashboard und meinen IP-Telefonen anzeigen lasse, erzeugt es einfach eine png-Datei im media-Order. Das kann man sich dann ja nach Lust&Laune zusammenstellen.

Außerdem ist noch eine Tidenazeige für den aktuellen Tag mit drin - derzeit zeige ich das nur als Linie durch die Wettersymbole an. Die meisten von euch brauchen das wohl weniger - dazu einfach den entsprechenden Block (vom Kommi „Tidenanzeige“ bis zum Kommi „Stündlich“ ) rausschmeißen.

Die Icons aus dem Anhang sind natürlich nur ein Beispiel -sie müssen in den media/weather Ordner (ggf. anlegen)
Das Script selbst braucht einen Timer (z.B. alle 10 Minuten)
Den gewünschten Ort so wie bei weather.com durch den entsprechenden Code auswählen.Siehe dazu auch https://weather.codes/germany/

weather.png


<?
$fontsize="1";$fn="weather.png";

$im = @imagecreatetruecolor(580, 280);

$textcol_white=hexdec("FFFFFF");
$textcol_orange=hexdec("FFBE5A");
$textcol_green=hexdec("7FFF8E");
$textcol_blue=hexdec("9C9CFF");
$textcol_red=hexdec("FF9C00");
$textcol_purple=hexdec("CE9CCE");
$textcol_black=hexdec("000000");

imagefill($im, 0, 0, $textcol_black);

$trans = array(
    'Monday'    => 'Montag',
    'Tuesday'   => 'Dienstag',
    'Wednesday' => 'Mittwoch',
    'Thursday'  => 'Donnerstag',
    'Friday'    => 'Freitag',
    'Saturday'  => 'Samstag',
    'Sunday'    => 'Sonntag',
    'Mon'       => 'Mo',
    'Tue'       => 'Di',
    'Wed'       => 'Mi',
    'Thu'       => 'Do',
    'Fri'       => 'Fr',
    'Sat'       => 'Sa',
    'Sun'       => 'So',
    'January'   => 'Januar',
    'February'  => 'Februar',
    'March'     => 'März',
    'May'       => 'Mai',
    'June'      => 'Juni',
    'July'      => 'Juli',
    'October'   => 'Oktober',
    'December'  => 'Dezember'
);

$url="http://wxdata.weather.com/wxdata/weather/local/GMXX0014?&unit=m&locale=de_de&dayf=11&cc=h&hbhf=24";
//$url="http://desktopfw.weather.com/weather/local/GMXX0014?&unit=m&locale=DE_de&dayf=11&cc=h&hbhf=24";
$xml=simpleXML_load_file($url);

// current conditions
$im_icon=$im_icon=imagecreatefrompng(IPS_GetKernelDir()."media/weather/".$xml->cc->icon.".png");
imagecopyresampled  ( $im,$im_icon, 0, 100,0,0,imagesx($im_icon),imagesy($im_icon),imagesx($im_icon),imagesy($im_icon));

imagestring( $im,  1, 70, 95, utf8_decode($xml->cc->t), $textcol_purple );
imagestring( $im, 14, 70, 110, $xml->cc->tmp." °".$xml->head->ut, $textcol_purple );

imagerightstring( $im, 1, 90,  135, "gefühlt:", $textcol_purple );
imagestring		 ( $im, 1, 95,  135, $xml->cc->flik." °".$xml->head->ut, $textcol_purple );
imagerightstring( $im, 1, 90,  145, "Luftdruck:", $textcol_purple );

switch ($xml->cc->bar->d){
case "steigend":
	ImageFilledPolygon($im, array(140, 151, 148, 151, 144, 146), 3, $textcol_green);
	break;
case "schnell steigend":
	ImageFilledPolygon($im, array(140, 151, 148, 151, 144, 146), 3, $textcol_green);
	ImageFilledPolygon($im, array(152, 151, 160, 151, 156, 146), 3, $textcol_green);
	break;
case "konstant":
	break;
case "fallend":
	ImageFilledPolygon($im, array(140, 146, 148, 146, 144, 151), 3, $textcol_red);
	break;
case "stark fallend":
	ImageFilledPolygon($im, array(140, 146, 148, 146, 144, 151), 3, $textcol_red);
	ImageFilledPolygon($im, array(152, 146, 160, 146, 156, 151), 3, $textcol_red);
	break;
default:
	imagestring		 ( $im, 1, 140,  165, $xml->cc->bar->d, $textcol_purple );
	break;
}
imagestring		 ( $im, 1, 95,  145, round((float)$xml->cc->bar->r,0)." ".$xml->head->up, $textcol_purple );
imagerightstring( $im, 1, 90,  155, "Wind:", $textcol_purple );
imagestring		 ( $im, 1, 95,  155, $xml->cc->wind->s." ".$xml->head->us." (".$xml->cc->wind->t.")", $textcol_purple );
imagerightstring( $im, 1, 90,  165, "Luftfeuchtigkeit:", $textcol_purple );
imagestring		 ( $im, 1, 95,  165, $xml->cc->hmid."%", $textcol_purple );
imagerightstring( $im, 1, 90,  175, "Taupunkt:", $textcol_purple );
imagestring		 ( $im, 1, 95,  175, $xml->cc->dewp."°".$xml->head->ut, $textcol_purple );

imagerightstring( $im, 1, 90,  185, "Sichtweite:", $textcol_purple );
imagestring		 ( $im, 1, 95,  185, $xml->cc->vis." ".$xml->head->ud, $textcol_purple );
imagerightstring( $im, 1, 90,  195, "Wolkenuntergrenze:", $textcol_purple );
imagestring		 ( $im, 1, 95,  195, 400*($xml->cc->tmp-$xml->cc->dewp)." ft", $textcol_purple );
// Tideninformationen

$from['year']=date("Y",strtotime($xml->hbhf->lsup)-1800);
$from['month']=date("m",strtotime($xml->hbhf->lsup)-1800);
$from['day']=date("d",strtotime($xml->hbhf->lsup)-1800);
$from['hour']=date("H",strtotime($xml->hbhf->lsup)-1800);
$from['minute']=date("i",strtotime($xml->hbhf->lsup)-1800);

$url="http://tbone.biol.sc.edu/tide/tideshow.cgi?tplotdir=vert;gx=160;gy=80;caltype=text;type=mrare;interval=00%3A01;glen=1;fontsize=%2B0;units=default;killsun=1;year=".$from['year'].";month=".$from['month'].";day=".$from['day'].";hour=".$from['hour'].";min=".$from['minute'].";tzone=local;d_year=;d_month=00;d_day=01;d_hour=00;d_min=00;ampm24=24;nodlines=1;notimes=1;colortext=black;colordatum=white;colormsl=yellow;colortics=red;colorday=skyblue;colornight=deep-%3Cbr%20%2F%3Eskyblue;colorebb=seagreen;colorflood=blue;site=Bremen%2C%20Oslebshausen%2C%20Germany";
$raw=Sys_GetURLContent($url);
foreach(preg_split("/((\r?
)|(
?))/", $raw) as $line){
	if (preg_match("#(?<y>[0-9]{4})-(?<m>[0-9]{2})(.*)-(?<d>[0-9]{2}) *(?<h>[0-9]{2}):(?<i>[0-9]{2}) *CEST *(?<v>.*)#",$line,$treffer)){
		$ts=mktime($treffer['h'],$treffer['i'],0,$treffer['m'],$treffer['d'],$treffer['y']);
		$weser[$ts]=array('datum'=>date("d.m.y H:i",$ts),'wert'=>(float)$treffer['v']);
	}
}
$url="http://tbone.biol.sc.edu/tide/tideshow.cgi?tplotdir=vert;gx=160;gy=80;caltype=text;type=mrare;interval=00%3A01;glen=1;fontsize=%2B0;units=default;killsun=1;year=".$from['year'].";month=".$from['month'].";day=".$from['day'].";hour=".$from['hour'].";min=".$from['minute'].";tzone=local;d_year=;d_month=00;d_day=01;d_hour=00;d_min=00;ampm24=24;nodlines=1;notimes=1;colortext=black;colordatum=white;colormsl=yellow;colortics=red;colorday=skyblue;colornight=deep-%3Cbr%20%2F%3Eskyblue;colorebb=seagreen;colorflood=blue;site=Brake%2C+Germany";
$raw=Sys_GetURLContent($url);
foreach(preg_split("/((\r?
)|(
?))/", $raw) as $line){
	if (preg_match("#(?<y>[0-9]{4})-(?<m>[0-9]{2})(.*)-(?<d>[0-9]{2}) *(?<h>[0-9]{2}):(?<i>[0-9]{2}) *CEST *(?<v>.*)#",$line,$treffer)){
		$ts=mktime($treffer['h'],$treffer['i'],0,$treffer['m'],$treffer['d'],$treffer['y']);
		$weser_vs[$ts]=array('datum'=>date("d.m.y H:i",$ts),'wert'=>(float)$treffer['v']);
	}
}
$url="http://tbone.biol.sc.edu/tide/tideshow.cgi?tplotdir=vert;gx=160;gy=80;caltype=text;type=mrare;interval=00%3A01;glen=1;fontsize=%2B0;units=default;killsun=1;year=".$from['year'].";month=".$from['month'].";day=".$from['day'].";hour=".$from['hour'].";min=".$from['minute'].";tzone=local;d_year=;d_month=00;d_day=01;d_hour=00;d_min=00;ampm24=24;nodlines=1;notimes=1;colortext=black;colordatum=white;colormsl=yellow;colortics=red;colorday=skyblue;colornight=deep-%3Cbr%20%2F%3Eskyblue;colorebb=seagreen;colorflood=blue;site=Bremerhaven%2C+Alter+Leuchtturm%2C+Germany";
$raw=Sys_GetURLContent($url);
foreach(preg_split("/((\r?
)|(
?))/", $raw) as $line){
	if (preg_match("#(?<y>[0-9]{4})-(?<m>[0-9]{2})(.*)-(?<d>[0-9]{2}) *(?<h>[0-9]{2}):(?<i>[0-9]{2}) *CEST *(?<v>.*)#",$line,$treffer)){
		$ts=mktime($treffer['h'],$treffer['i'],0,$treffer['m'],$treffer['d'],$treffer['y']);
		$weser_bhv[$ts]=array('datum'=>date("d.m.y H:i",$ts),'wert'=>(float)$treffer['v']);
	}
}

// Stündlich
$i=0;$w=40;$x0=0;$icon_w=30;unset($xmin);unset($xmax);
$hours=array(0,1,2,3,4,6,8,10,12,14,16,18,20,22);
foreach ($xml->hbhf->hour as $xml_h){
	if (in_array($i,$hours)){
		imagecenteredstring ( $im, 1, 		$x0,$x0+$w,  0,$xml_h->attributes()['c'].":00 ",$textcol_purple);
		if (!(@$im_icon=imagecreatefrompng(IPS_GetKernelDir()."media/weather/".$xml_h->{'icon'}.".png"))){
			$im_icon=imagecreatefrompng(IPS_GetKernelDir()."media/weather/25.png");
		}
		imagecopyresampled  ( $im,$im_icon, $x0+5, 			 		 8,0,0,$icon_w,$icon_w,imagesx($im_icon),imagesy($im_icon));
		imagecenteredstring ( $im, 1, 		$x0,$x0+$w, 40,$xml_h->tmp."°",$textcol_purple);
//		imagecenteredstring ( $im, 1, 		$x0,$x0+$w, 50,$xml_h->wind->s." ".$xml_h->wind->t,windfarbe((float)$xml_h->wind->s));

		imagefilledellipse($im,$x0+$w/2,65,12,12,windfarbe((float)$xml_h->wind->s));
		imagesetthickness($im, 1);$r=15;$deg=deg2rad(22.5*(round((int)$xml_h->wind->d/22.5,0)));
		arrow               ( $im, $x0+$w/2,65, $x0+$w/2-$r*sin($deg) ,65+$r*cos($deg),4,4,windfarbe((float)$xml_h->wind->s));
		imageline           ( $im, $x0+$w/2,65, $x0+$w/2-$r*sin($deg) ,65+$r*cos($deg),	 windfarbe((float)$xml_h->wind->s));
		imagecenteredstring ( $im, 1, 		$x0,$x0+$w, 61,$xml_h->wind->s,$textcol_black);

		imagecenteredstring ( $im, 1, 		$x0,$x0+$w, 80,((int)$xml_h->ppcp==0?"-":(int)$xml_h->ppcp." %"),$textcol_purple);
		if (!isset($xmin)) $xmin=$xml_h->attributes()['c'];
		$xmax=$i;
		if ($diff2=next($hours)) $diff=$diff2-$i;
		$tsmin=strtotime($xml->hbhf->lsup)+$i*3600-$diff*3600/2;
		$tsmax=strtotime($xml->hbhf->lsup)+$i*3600+$diff*3600/2;
		$wert_min=0;$wert_max=5;$ymin=40;$ymax=5;
		for ($j=$x0;$j<$x0+$w;$j++){
		   $ts=($tsmin+($j-$x0)*($tsmax-$tsmin)/$w);$wert['hb']=getClosest($ts,$weser)['wert'];$wert['vs']=getClosest($ts,$weser_vs)['wert'];$wert['bhv']=getClosest($ts,$weser_bhv)['wert'];
			imagefilledellipse($im,$j,round($ymin+$wert['bhv']*($ymax-$ymin)/($wert_max-$wert_min),0),1,2,$textcol_blue);
			imagefilledellipse($im,$j,round($ymin+$wert['vs']*($ymax-$ymin)/($wert_max-$wert_min),0),1,2,$textcol_green);
			imagefilledellipse($im,$j,round($ymin+$wert['hb']*($ymax-$ymin)/($wert_max-$wert_min),0),1,2,$textcol_orange);
		}
		$x0+=$w;
	}
	$i++;
}

// Täglich
$i=0;$w=40;$x0=120;$y0=100;$icon_w=30;
foreach ($xml->dayf->day as $xml_d){
	if (($i>0) && (preg_match("#(?<m>[a-zA-Z].*) (?<d>[0-9].*)#",$xml_d->attributes()['dt'],$treffer))){
		imagecenteredstring ( $im, 1, 		$x0+$w*$i,$x0+$w*$i+$w,  $y0+0,substr($trans[(string)$xml_d->attributes()['t']],0,2)." ".$treffer['d'],$textcol_purple);
		if (!(@$im_icon=imagecreatefrompng(IPS_GetKernelDir()."media/weather/".$xml_d->part[0]->icon.".png"))){
			$im_icon=imagecreatefrompng(IPS_GetKernelDir()."media/weather/25.png");
		}
		imagecopyresampled  ( $im,$im_icon, $x0+$w*$i+5, 			 	$y0+ 8,0,0,$icon_w,$icon_w,imagesx($im_icon),imagesy($im_icon));
		imagecenteredstring ( $im, 1, 		$x0+$w*$i,$x0+$w*$i+$w, $y0+40,$xml_d->low."°-".$xml_d->hi."°",$textcol_purple);
//		imagecenteredstring ( $im, 1, 		$x0+$w*$i,$x0+$w*$i+$w, $y0+50,$xml_d->part[0]->wind->s." ".$xml_d->part[0]->wind->t,windfarbe((float)$xml_d->part[0]->wind->s));

		imagefilledellipse($im,$x0+$w*$i+$w/2,$y0+65,12,12,windfarbe((float)$xml_d->part[0]->wind->s));
		imagesetthickness($im, 1);$r=15;$deg=deg2rad(22.5*(round((int)$xml_d->part[0]->wind->d/22.5,0)));
		arrow               ( $im, $x0+$w*$i+$w/2,$y0+65, $x0+$w*$i+$w/2-$r*sin($deg) ,$y0+65+$r*cos($deg),4,4,windfarbe((float)$xml_d->part[0]->wind->s));
		imageline           ( $im, $x0+$w*$i+$w/2,$y0+65, $x0+$w*$i+$w/2-$r*sin($deg) ,$y0+65+$r*cos($deg),	 windfarbe((float)$xml_d->part[0]->wind->s));
		imagecenteredstring ( $im, 1, 		$x0+$w*$i,$x0+$w*$i+$w, $y0+61,$xml_d->part[0]->wind->s,$textcol_black);

		imagecenteredstring ( $im, 1, 		$x0+$w*$i,$x0+$w*$i+$w, $y0+80,((int)$xml_d->part[0]->ppcp==0?"-":(int)$xml_d->part[0]->ppcp." %"),$textcol_purple);
//		imagecenteredstring ( $im, 1, 		$x0+$w*$i,$x0+$w*$i+$w, $y0+90,utf8_decode($xml_d->part[1]->t),$textcol_purple);
		$words=explode("|",wordwrap(utf8_decode($xml_d->part[1]->t), 8, "|"));
		for($j=0; $j<count($words); $j++){
		   imagecenteredstring ( $im, 1, 		$x0+$w*$i,$x0+$w*$i+$w, $y0+90+10*$j,$words[$j],$textcol_purple);
		}

		if (!(@$im_icon=imagecreatefrompng(IPS_GetKernelDir()."media/weather/".$xml_d->part[1]->icon.".png"))){
			$im_icon=imagecreatefrompng(IPS_GetKernelDir()."media/weather/25.png");
		}
		imagecopyresampled  ( $im,$im_icon, $x0+$w*$i+5, 			 	$y0+123,0,0,$icon_w,$icon_w,imagesx($im_icon),imagesy($im_icon));
//		imagecenteredstring ( $im, 1, 		$x0+$w*$i,$x0+$w*$i+$w, $y0+145,$xml_d->low."°",$textcol_purple);
//		imagecenteredstring ( $im, 1, 		$x0+$w*$i,$x0+$w*$i+$w, $y0+120,$xml_d->part[1]->wind->s." ".$xml_d->part[1]->wind->t,windfarbe((float)$xml_d->part[1]->wind->s));

//		imagefilledellipse($im,$x0+$w*$i+$w/2,$y0+155,12,12,windfarbe((float)$xml_d->part[1]->wind->s));
//		imagesetthickness($im, 1);$r=15;$deg=deg2rad(22.5*(round((int)$xml_d->part[1]->wind->d/22.5,0)));
//		arrow               ( $im, $x0+$w*$i+$w/2,$y0+155, $x0+$w*$i+$w/2-$r*sin($deg) ,$y0+155+$r*cos($deg),4,4,windfarbe((float)$xml_d->part[1]->wind->s));
//		imageline           ( $im, $x0+$w*$i+$w/2,$y0+155, $x0+$w*$i+$w/2-$r*sin($deg) ,$y0+155+$r*cos($deg),	 windfarbe((float)$xml_d->part[1]->wind->s));
//		imagecenteredstring ( $im, 1, 		$x0+$w*$i,$x0+$w*$i+$w, $y0+151,$xml_d->part[1]->wind->s,$textcol_black);

//		imagecenteredstring ( $im, 1, 		$x0+$w*$i,$x0+$w*$i+$w, $y0+170,((int)$xml_d->part[1]->ppcp==0?"-":(int)$xml_d->part[1]->ppcp." %"),$textcol_purple);
	}
	$i++;
}

imagepng($im, IPS_GetKernelDir()."media/".$fn);

//print_r($xml);

function imagecenteredstring ( &$img, $font, $xMin, $xMax, $y, $str, $col ) {
    $textWidth = imagefontwidth( $font ) * strlen( $str );
    $xLoc = ( $xMax - $xMin - $textWidth ) / 2 + $xMin + $font;
    imagestring( $img, $font, $xLoc, $y, $str, $col );
}

function imagerightstring ( &$img, $font, $xMin, $y, $str, $col ) {
    $textWidth = imagefontwidth( $font ) * strlen( $str );
    $xLoc = ( $xMin  - $textWidth );
    imagestring( $img, $font, $xLoc, $y, $str, $col );
}

function windfarbe($val){
//$val*= 0.53995680346039;
$val*=0.5;
	if ($val<2){
		return hexdec("6400FE");
	}
	elseif ($val<4){
		return hexdec("3200FE");
	}
	elseif ($val<6){
		return hexdec("0032FE");
	}
	elseif ($val<8){
		return hexdec("0064FE");
	}
	elseif ($val<10){
		return hexdec("0096FE");
	}
	elseif ($val<12){
		return hexdec("00C8FE");
	}
	elseif ($val<14){
		return hexdec("00E6F0");
	}
	elseif ($val<16){
		return hexdec("00E6A0");
	}
	elseif ($val<18){
		return hexdec("00E678");
	}
	elseif ($val<20){
		return hexdec("00E650");
	}
	elseif ($val<22){
		return hexdec("00F028");
	}
	elseif ($val<24){
		return hexdec("00FA00");
	}
	elseif ($val<26){
		return hexdec("FEFE00");
	}
	elseif ($val<28){
		return hexdec("FEE100");
	}
	elseif ($val<30){
		return hexdec("FEC800");
	}
	elseif ($val<32){
		return hexdec("FEAF00");
	}
	elseif ($val<34){
		return hexdec("FE9600");
	}
	elseif ($val<36){
		return hexdec("E67D00");
	}
	elseif ($val<38){
		return hexdec("E66400");
	}
	elseif ($val<40){
		return hexdec("DC4B1E");
	}
	elseif ($val<42){
		return hexdec("C8321E");
	}
	elseif ($val<44){
		return hexdec("B4191E");
	}
	elseif ($val<46){
		return hexdec("AA001E");
	}
	elseif ($val<48){
		return hexdec("B40032");
	}
	else{
		return hexdec("C80064");
	}
}
function getClosest($search, $arr) {
   $closest = null;
   if (isset($arr[$search])) return $arr[$search];
   foreach ($arr as $key=>$item) {
      if ($closest === null || abs($search - $closest) > abs($key - $search)) {
         $closest = $key;
      }
   }
   return $arr[$closest];
}

function arrow($im, $x1, $y1, $x2, $y2, $alength, $awidth, $color) {

    $distance = sqrt(pow($x1 - $x2, 2) + pow($y1 - $y2, 2));

    $dx = $x2 + ($x1 - $x2) * $alength / $distance;
    $dy = $y2 + ($y1 - $y2) * $alength / $distance;

    $k = $awidth / $alength;

    $x2o = $x2 - $dx;
    $y2o = $dy - $y2;

    $x3 = $y2o * $k + $dx;
    $y3 = $x2o * $k + $dy;

    $x4 = $dx - $y2o * $k;
    $y4 = $dy - $x2o * $k;

    imageline($im, $x1, $y1, $dx, $dy, $color);
//    imageline($im, $x3, $y3, $x4, $y4, $color);
    imageline($im, $x3, $y3, $x2, $y2, $color); // Schenkel
    imageline($im, $x2, $y2, $x4, $y4, $color); // Schenkel

}?>

weather.zip (1.2 MB)

Hi Tom,

wollte gerade den PC abschalten dann hatte ich
deinen Thread gesehen… Rückmeldung vom ersten
Tester :rolleyes:

Stündliche und Tages Vorhersage inkl. Visu mittels
Grafiken was will man mehr ? Das ist doch nicht gepfuscht
Gute Arbeit , Sieht Top aus ! bestimmt ist es noch möglich
das ganze in einer String Variable auszugeben für’s WF
aber da schaue ich später danach !

Grüße Alex

ich habe das mal ausprobiert, alledings finde ich keinen Weg die Datei irgendwie ins WF zu bekommen.
Kann mir da jemand weiterhelfen?
Gruß qinshi

Jetzt weiß ich, was Du meinst. :stuck_out_tongue:

Habs mir simpel gemacht. Bilddatei (weather.png) durch Script erzeugt und dann in Media Dateien über Medien hinzufügen eingefügt.
Dann ist die Datei in der „Mediathek“ und Du kannst einen einfachen Link im WebFront drauflegen.

Gruß an den Erzeuger.
Danke für die Umsetzung.

Prima Danke!
qinshi

Hy!

Genau das habe ich schon lange gesucht!
Schaut sehr gut aus!

Ein problem habe ich gleich am anfang schon!

$url=„http://wxdata.weather.com/wxdata/weather/local/GMXX0014?&unit=m&locale=de_de&dayf=11&cc=h&hbhf=24“;
//$url=„http://desktopfw.weather.com/weather/local/GMXX0014?&unit=m&locale=DE_de&dayf=11&cc=h&hbhf=24“;
$xml=simpleXML_load_file($url);

Wie bist du auf die http://wxdata.weather.com/wxdata/weather/local/GMXX0014?&unit=m&locale=de_de&dayf=11&cc=h&hbhf=24 gekommen?

Wenn ich nach dem Code suche bekomme ich: AUXX4205 Loosdorf, Austria

Und bei mir wird ein komisches Ä angezeigt warum???
Mfg
Maxx

weather.png

Ja, da hat sich zwischenzeitlich mal die Codepage geändert - es müssen zumindest auf dem Windows-Host die Textausgaben utf8 kodiert sein.

Also:

<?
IPSUtils_Include ("IPSInstaller.inc.php","IPSLibrary::install::IPSInstaller");

ini_set("max_execution_time", 120);
weather("GMXX0014","Bremen",true,true);

function weather($gmx,$fn,$tide,$store){
	$fontsize="1";

	$im = @imagecreatetruecolor(580, 280);

	$textcol_white=hexdec("FFFFFF");
	$textcol_orange=hexdec("FFBE5A");
	$textcol_green=hexdec("7FFF8E");
	$textcol_blue=hexdec("9C9CFF");
	$textcol_red=hexdec("FF9C00");
	$textcol_purple=hexdec("CE9CCE");
	$textcol_black=hexdec("000000");

	imagefill($im, 0, 0, $textcol_black);

	$trans = array(
	    'Monday'    => 'Montag',
	    'Tuesday'   => 'Dienstag',
	    'Wednesday' => 'Mittwoch',
	    'Thursday'  => 'Donnerstag',
	    'Friday'    => 'Freitag',
	    'Saturday'  => 'Samstag',
	    'Sunday'    => 'Sonntag',
	    'Mon'       => 'Mo',
	    'Tue'       => 'Di',
	    'Wed'       => 'Mi',
	    'Thu'       => 'Do',
	    'Fri'       => 'Fr',
	    'Sat'       => 'Sa',
	    'Sun'       => 'So',
	    'January'   => 'Januar',
	    'February'  => 'Februar',
	    'March'     => 'März',
	    'May'       => 'Mai',
	    'June'      => 'Juni',
	    'July'      => 'Juli',
	    'October'   => 'Oktober',
	    'December'  => 'Dezember'
	);

	$url="http://wxdata.weather.com/wxdata/weather/local/$gmx?&unit=m&locale=de_de&dayf=11&cc=h&hbhf=24";
	//$url="http://desktopfw.weather.com/weather/local/GMXX0014?&unit=m&locale=DE_de&dayf=11&cc=h&hbhf=24";
	$xml=simpleXML_load_file($url);

	if ($store){
		SetValue(CreateVariable($gmx."_temp_max", 2, $_IPS['SELF'], 0,'~Temperature'),(int)($xml->dayf->day[0]->hi));
		SetValue(CreateVariable($gmx."_temp_min", 2, $_IPS['SELF'], 0,'~Temperature'),(int)($xml->dayf->day[0]->low));
	}

	// current conditions
	$im_icon=$im_icon=imagecreatefrompng(IPS_GetKernelDir()."media/weather/".$xml->cc->icon.".png");
	imagecopyresampled  ( $im,$im_icon, 0, 90,0,0,60,60,imagesx($im_icon),imagesy($im_icon));

	imagestring( $im,  1, 70, 95,  utf8_decode($xml->cc->obst), $textcol_purple );
	imagestring( $im,  1, 70, 110, utf8_decode($xml->cc->t), $textcol_purple );
	imagestring( $im, 14, 70, 120, utf8_decode($xml->cc->tmp." °".$xml->head->ut), $textcol_purple );

	imagerightstring( $im, 1, 90,  135, utf8_decode("gefühlt:"), $textcol_purple );
	imagestring		 ( $im, 1, 95,  135, utf8_decode($xml->cc->flik." °".$xml->head->ut), $textcol_purple );
	imagerightstring( $im, 1, 90,  145, "Luftdruck:", $textcol_purple );

	switch ($xml->cc->bar->d){
	case "steigend":
		ImageFilledPolygon($im, array(140, 151, 148, 151, 144, 146), 3, $textcol_green);
		break;
	case "schnell steigend":
		ImageFilledPolygon($im, array(140, 151, 148, 151, 144, 146), 3, $textcol_green);
		ImageFilledPolygon($im, array(152, 151, 160, 151, 156, 146), 3, $textcol_green);
		break;
	case "konstant":
		break;
	case "fallend":
		ImageFilledPolygon($im, array(140, 146, 148, 146, 144, 151), 3, $textcol_red);
		break;
	case "stark fallend":
		ImageFilledPolygon($im, array(140, 146, 148, 146, 144, 151), 3, $textcol_red);
		ImageFilledPolygon($im, array(152, 146, 160, 146, 156, 151), 3, $textcol_red);
		break;
	default:
		imagestring		 ( $im, 1, 140,  165, $xml->cc->bar->d, $textcol_purple );
		break;
	}
	imagestring		 ( $im, 1, 95,  145, round((float)$xml->cc->bar->r,0)." ".$xml->head->up, $textcol_purple );
	imagerightstring( $im, 1, 90,  155, "Wind:", $textcol_purple );
	imagestring		 ( $im, 1, 95,  155, $xml->cc->wind->s." ".$xml->head->us." (".$xml->cc->wind->t.")", $textcol_purple );
	imagerightstring( $im, 1, 90,  165, "Luftfeuchtigkeit:", $textcol_purple );
	imagestring		 ( $im, 1, 95,  165, $xml->cc->hmid."%", $textcol_purple );
	imagerightstring( $im, 1, 90,  175, "Taupunkt:", $textcol_purple );
	imagestring		 ( $im, 1, 95,  175, utf8_decode($xml->cc->dewp."°".$xml->head->ut), $textcol_purple );

	imagerightstring( $im, 1, 90,  185, "Sichtweite:", $textcol_purple );
	imagestring		 ( $im, 1, 95,  185, $xml->cc->vis." ".$xml->head->ud, $textcol_purple );
	imagerightstring( $im, 1, 90,  195, "Wolkenuntergrenze:", $textcol_purple );
	imagestring		 ( $im, 1, 95,  195, 400*($xml->cc->tmp-$xml->cc->dewp)." ft", $textcol_purple );
	// Tideninformationen

	if ($tide){
		$from['year']=date("Y",strtotime($xml->hbhf->lsup)-1800);
		$from['month']=date("m",strtotime($xml->hbhf->lsup)-1800);
		$from['day']=date("d",strtotime($xml->hbhf->lsup)-1800);
		$from['hour']=date("H",strtotime($xml->hbhf->lsup)-1800);
		$from['minute']=date("i",strtotime($xml->hbhf->lsup)-1800);

		$url="http://tbone.biol.sc.edu/tide/tideshow.cgi?tplotdir=vert;gx=160;gy=80;caltype=text;type=mrare;interval=00%3A01;glen=1;fontsize=%2B0;units=default;killsun=1;year=".$from['year'].";month=".$from['month'].";day=".$from['day'].";hour=".$from['hour'].";min=".$from['minute'].";tzone=local;d_year=;d_month=00;d_day=01;d_hour=00;d_min=00;ampm24=24;nodlines=1;notimes=1;colortext=black;colordatum=white;colormsl=yellow;colortics=red;colorday=skyblue;colornight=deep-%3Cbr%20%2F%3Eskyblue;colorebb=seagreen;colorflood=blue;site=Bremen%2C%20Oslebshausen%2C%20Germany";
		$raw=Sys_GetURLContent($url);
		foreach(preg_split("/((\r?
)|(
?))/", $raw) as $line){
			if (preg_match("#(?<y>[0-9]{4})-(?<m>[0-9]{2})(.*)-(?<d>[0-9]{2}) *(?<h>[0-9]{2}):(?<i>[0-9]{2}) *CEST *(?<v>.*)#",$line,$treffer)){
				$ts=mktime($treffer['h'],$treffer['i'],0,$treffer['m'],$treffer['d'],$treffer['y']);
				$weser[$ts]=array('datum'=>date("d.m.y H:i",$ts),'wert'=>(float)$treffer['v']);
			}
		}
		$url="http://tbone.biol.sc.edu/tide/tideshow.cgi?tplotdir=vert;gx=160;gy=80;caltype=text;type=mrare;interval=00%3A01;glen=1;fontsize=%2B0;units=default;killsun=1;year=".$from['year'].";month=".$from['month'].";day=".$from['day'].";hour=".$from['hour'].";min=".$from['minute'].";tzone=local;d_year=;d_month=00;d_day=01;d_hour=00;d_min=00;ampm24=24;nodlines=1;notimes=1;colortext=black;colordatum=white;colormsl=yellow;colortics=red;colorday=skyblue;colornight=deep-%3Cbr%20%2F%3Eskyblue;colorebb=seagreen;colorflood=blue;site=Brake%2C+Germany";
		$raw=Sys_GetURLContent($url);
		foreach(preg_split("/((\r?
)|(
?))/", $raw) as $line){
			if (preg_match("#(?<y>[0-9]{4})-(?<m>[0-9]{2})(.*)-(?<d>[0-9]{2}) *(?<h>[0-9]{2}):(?<i>[0-9]{2}) *CEST *(?<v>.*)#",$line,$treffer)){
				$ts=mktime($treffer['h'],$treffer['i'],0,$treffer['m'],$treffer['d'],$treffer['y']);
				$weser_vs[$ts]=array('datum'=>date("d.m.y H:i",$ts),'wert'=>(float)$treffer['v']);
			}
		}
		$url="http://tbone.biol.sc.edu/tide/tideshow.cgi?tplotdir=vert;gx=160;gy=80;caltype=text;type=mrare;interval=00%3A01;glen=1;fontsize=%2B0;units=default;killsun=1;year=".$from['year'].";month=".$from['month'].";day=".$from['day'].";hour=".$from['hour'].";min=".$from['minute'].";tzone=local;d_year=;d_month=00;d_day=01;d_hour=00;d_min=00;ampm24=24;nodlines=1;notimes=1;colortext=black;colordatum=white;colormsl=yellow;colortics=red;colorday=skyblue;colornight=deep-%3Cbr%20%2F%3Eskyblue;colorebb=seagreen;colorflood=blue;site=Bremerhaven%2C+Alter+Leuchtturm%2C+Germany";
		$raw=Sys_GetURLContent($url);
		foreach(preg_split("/((\r?
)|(
?))/", $raw) as $line){
			if (preg_match("#(?<y>[0-9]{4})-(?<m>[0-9]{2})(.*)-(?<d>[0-9]{2}) *(?<h>[0-9]{2}):(?<i>[0-9]{2}) *CEST *(?<v>.*)#",$line,$treffer)){
				$ts=mktime($treffer['h'],$treffer['i'],0,$treffer['m'],$treffer['d'],$treffer['y']);
				$weser_bhv[$ts]=array('datum'=>date("d.m.y H:i",$ts),'wert'=>(float)$treffer['v']);
			}
		}
	}
	// Stündlich
	$i=0;$w=40;$x0=0;$icon_w=30;unset($xmin);unset($xmax);
	$hours=array(0,1,2,3,4,6,8,10,12,14,16,18,20,22);
	foreach ($xml->hbhf->hour as $xml_h){
		if (in_array($i,$hours)){
			imagecenteredstring ( $im, 1, 		$x0,$x0+$w,  0,$xml_h->attributes()['c'].":00 ",$textcol_purple);
			if (!(@$im_icon=imagecreatefrompng(IPS_GetKernelDir()."media/weather/".$xml_h->{'icon'}.".png"))){
				$im_icon=imagecreatefrompng(IPS_GetKernelDir()."media/weather/25.png");
			}
			imagecopyresampled  ( $im,$im_icon, $x0+5, 			 		 8,0,0,$icon_w,$icon_w,imagesx($im_icon),imagesy($im_icon));
			imagecenteredstring ( $im, 1, 		$x0,$x0+$w, 40,utf8_decode($xml_h->tmp."°"),$textcol_purple);
	//		imagecenteredstring ( $im, 1, 		$x0,$x0+$w, 50,$xml_h->wind->s." ".$xml_h->wind->t,windfarbe((float)$xml_h->wind->s));

			imagefilledellipse($im,$x0+$w/2,65,12,12,windfarbe((float)$xml_h->wind->s));
			imagesetthickness($im, 1);$r=15;$deg=deg2rad(22.5*(round((int)$xml_h->wind->d/22.5,0)));
			arrow               ( $im, $x0+$w/2,65, $x0+$w/2-$r*sin($deg) ,65+$r*cos($deg),4,4,windfarbe((float)$xml_h->wind->s));
			imageline           ( $im, $x0+$w/2,65, $x0+$w/2-$r*sin($deg) ,65+$r*cos($deg),	 windfarbe((float)$xml_h->wind->s));
			imagecenteredstring ( $im, 1, 		$x0,$x0+$w, 61,$xml_h->wind->s,$textcol_black);

			imagecenteredstring ( $im, 1, 		$x0,$x0+$w, 80,((int)$xml_h->ppcp==0?"-":(int)$xml_h->ppcp." %"),$textcol_purple);
			if (!isset($xmin)) $xmin=$xml_h->attributes()['c'];
			$xmax=$i;
			if ($diff2=next($hours)) $diff=$diff2-$i;
			$tsmin=strtotime($xml->hbhf->lsup)+$i*3600-$diff*3600/2;
			$tsmax=strtotime($xml->hbhf->lsup)+$i*3600+$diff*3600/2;
			$wert_min=0;$wert_max=5;$ymin=40;$ymax=5;
			if (($tide) and (isset($weser))){
				for ($j=$x0;$j<$x0+$w;$j++){
				   @$ts=($tsmin+($j-$x0)*($tsmax-$tsmin)/$w);$wert['hb']=getClosest($ts,$weser)['wert'];$wert['vs']=getClosest($ts,$weser_vs)['wert'];$wert['bhv']=getClosest($ts,$weser_bhv)['wert'];
					imagefilledellipse($im,$j,round($ymin+$wert['bhv']*($ymax-$ymin)/($wert_max-$wert_min),0),1,2,$textcol_blue);
					imagefilledellipse($im,$j,round($ymin+$wert['vs']*($ymax-$ymin)/($wert_max-$wert_min),0),1,2,$textcol_green);
					imagefilledellipse($im,$j,round($ymin+$wert['hb']*($ymax-$ymin)/($wert_max-$wert_min),0),1,2,$textcol_orange);
				}
			}
			$x0+=$w;
		}
		$i++;
	}

	// Täglich
	$i=0;$w=40;$x0=120;$y0=100;$icon_w=30;
	foreach ($xml->dayf->day as $xml_d){
		if (($i>0) && (preg_match("#(?<m>[a-zA-Z].*) (?<d>[0-9].*)#",$xml_d->attributes()['dt'],$treffer))){
			imagecenteredstring ( $im, 1, 		$x0+$w*$i,$x0+$w*$i+$w,  $y0+0,substr($trans[(string)$xml_d->attributes()['t']],0,2)." ".$treffer['d'],$textcol_purple);
			if (!(@$im_icon=imagecreatefrompng(IPS_GetKernelDir()."media/weather/".$xml_d->part[0]->icon.".png"))){
				$im_icon=imagecreatefrompng(IPS_GetKernelDir()."media/weather/25.png");
			}
			imagecopyresampled  ( $im,$im_icon, $x0+$w*$i+5, 			 	$y0+ 8,0,0,$icon_w,$icon_w,imagesx($im_icon),imagesy($im_icon));
			imagecenteredstring ( $im, 1, 		$x0+$w*$i,$x0+$w*$i+$w, $y0+40,utf8_decode($xml_d->low."°/".$xml_d->hi."°"),$textcol_purple);
	//		imagecenteredstring ( $im, 1, 		$x0+$w*$i,$x0+$w*$i+$w, $y0+50,$xml_d->part[0]->wind->s." ".$xml_d->part[0]->wind->t,windfarbe((float)$xml_d->part[0]->wind->s));

			imagefilledellipse($im,$x0+$w*$i+$w/2,$y0+65,12,12,windfarbe((float)$xml_d->part[0]->wind->s));
			imagesetthickness($im, 1);$r=15;$deg=deg2rad(22.5*(round((int)$xml_d->part[0]->wind->d/22.5,0)));
			arrow               ( $im, $x0+$w*$i+$w/2,$y0+65, $x0+$w*$i+$w/2-$r*sin($deg) ,$y0+65+$r*cos($deg),4,4,windfarbe((float)$xml_d->part[0]->wind->s));
			imageline           ( $im, $x0+$w*$i+$w/2,$y0+65, $x0+$w*$i+$w/2-$r*sin($deg) ,$y0+65+$r*cos($deg),	 windfarbe((float)$xml_d->part[0]->wind->s));
			imagecenteredstring ( $im, 1, 		$x0+$w*$i,$x0+$w*$i+$w, $y0+61,$xml_d->part[0]->wind->s,$textcol_black);

			imagecenteredstring ( $im, 1, 		$x0+$w*$i,$x0+$w*$i+$w, $y0+80,((int)$xml_d->part[0]->ppcp==0?"-":(int)$xml_d->part[0]->ppcp." %"),$textcol_purple);
	//		imagecenteredstring ( $im, 1, 		$x0+$w*$i,$x0+$w*$i+$w, $y0+90,utf8_decode($xml_d->part[1]->t),$textcol_purple);
			$words=explode("|",wordwrap(utf8_decode($xml_d->part[1]->t), 8, "|"));
			for($j=0; $j<count($words); $j++){
			   imagecenteredstring ( $im, 1, 		$x0+$w*$i,$x0+$w*$i+$w, $y0+90+10*$j,$words[$j],$textcol_purple);
			}

			if (!(@$im_icon=imagecreatefrompng(IPS_GetKernelDir()."media/weather/".$xml_d->part[1]->icon.".png"))){
				$im_icon=imagecreatefrompng(IPS_GetKernelDir()."media/weather/25.png");
			}
			imagecopyresampled  ( $im,$im_icon, $x0+$w*$i+5, 			 	$y0+123,0,0,$icon_w,$icon_w,imagesx($im_icon),imagesy($im_icon));
	//		imagecenteredstring ( $im, 1, 		$x0+$w*$i,$x0+$w*$i+$w, $y0+145,$xml_d->low."°",$textcol_purple);
	//		imagecenteredstring ( $im, 1, 		$x0+$w*$i,$x0+$w*$i+$w, $y0+120,$xml_d->part[1]->wind->s." ".$xml_d->part[1]->wind->t,windfarbe((float)$xml_d->part[1]->wind->s));

	//		imagefilledellipse($im,$x0+$w*$i+$w/2,$y0+155,12,12,windfarbe((float)$xml_d->part[1]->wind->s));
	//		imagesetthickness($im, 1);$r=15;$deg=deg2rad(22.5*(round((int)$xml_d->part[1]->wind->d/22.5,0)));
	//		arrow               ( $im, $x0+$w*$i+$w/2,$y0+155, $x0+$w*$i+$w/2-$r*sin($deg) ,$y0+155+$r*cos($deg),4,4,windfarbe((float)$xml_d->part[1]->wind->s));
	//		imageline           ( $im, $x0+$w*$i+$w/2,$y0+155, $x0+$w*$i+$w/2-$r*sin($deg) ,$y0+155+$r*cos($deg),	 windfarbe((float)$xml_d->part[1]->wind->s));
	//		imagecenteredstring ( $im, 1, 		$x0+$w*$i,$x0+$w*$i+$w, $y0+151,$xml_d->part[1]->wind->s,$textcol_black);

	//		imagecenteredstring ( $im, 1, 		$x0+$w*$i,$x0+$w*$i+$w, $y0+170,((int)$xml_d->part[1]->ppcp==0?"-":(int)$xml_d->part[1]->ppcp." %"),$textcol_purple);
		}
		$i++;
	}

	imagepng($im, IPS_GetKernelDir()."media/weather_".$fn.".png");
	IPS_SendMediaEvent(IPS_GetMediaIDByFile("media/weather_".$fn.".png"));
}
//print_r($xml);

function imagecenteredstring ( &$img, $font, $xMin, $xMax, $y, $str, $col ) {
    $textWidth = imagefontwidth( $font ) * strlen( $str );
    $xLoc = ( $xMax - $xMin - $textWidth ) / 2 + $xMin + $font;
    imagestring( $img, $font, $xLoc, $y, $str, $col );
}

function imagerightstring ( &$img, $font, $xMin, $y, $str, $col ) {
    $textWidth = imagefontwidth( $font ) * strlen( $str );
    $xLoc = ( $xMin  - $textWidth );
    imagestring( $img, $font, $xLoc, $y, $str, $col );
}

function windfarbe($val){
//$val*= 0.53995680346039;
$val*=0.5;
	if ($val<2){
		return hexdec("6400FE");
	}
	elseif ($val<4){
		return hexdec("3200FE");
	}
	elseif ($val<6){
		return hexdec("0032FE");
	}
	elseif ($val<8){
		return hexdec("0064FE");
	}
	elseif ($val<10){
		return hexdec("0096FE");
	}
	elseif ($val<12){
		return hexdec("00C8FE");
	}
	elseif ($val<14){
		return hexdec("00E6F0");
	}
	elseif ($val<16){
		return hexdec("00E6A0");
	}
	elseif ($val<18){
		return hexdec("00E678");
	}
	elseif ($val<20){
		return hexdec("00E650");
	}
	elseif ($val<22){
		return hexdec("00F028");
	}
	elseif ($val<24){
		return hexdec("00FA00");
	}
	elseif ($val<26){
		return hexdec("FEFE00");
	}
	elseif ($val<28){
		return hexdec("FEE100");
	}
	elseif ($val<30){
		return hexdec("FEC800");
	}
	elseif ($val<32){
		return hexdec("FEAF00");
	}
	elseif ($val<34){
		return hexdec("FE9600");
	}
	elseif ($val<36){
		return hexdec("E67D00");
	}
	elseif ($val<38){
		return hexdec("E66400");
	}
	elseif ($val<40){
		return hexdec("DC4B1E");
	}
	elseif ($val<42){
		return hexdec("C8321E");
	}
	elseif ($val<44){
		return hexdec("B4191E");
	}
	elseif ($val<46){
		return hexdec("AA001E");
	}
	elseif ($val<48){
		return hexdec("B40032");
	}
	else{
		return hexdec("C80064");
	}
}
function getClosest($search, $arr) {
   $closest = null;
   if (isset($arr[$search])) return $arr[$search];
   foreach ($arr as $key=>$item) {
      if ($closest === null || abs($search - $closest) > abs($key - $search)) {
         $closest = $key;
      }
   }
   return $arr[$closest];
}

function arrow($im, $x1, $y1, $x2, $y2, $alength, $awidth, $color) {

    $distance = sqrt(pow($x1 - $x2, 2) + pow($y1 - $y2, 2));

    $dx = $x2 + ($x1 - $x2) * $alength / $distance;
    $dy = $y2 + ($y1 - $y2) * $alength / $distance;

    $k = $awidth / $alength;

    $x2o = $x2 - $dx;
    $y2o = $dy - $y2;

    $x3 = $y2o * $k + $dx;
    $y3 = $x2o * $k + $dy;

    $x4 = $dx - $y2o * $k;
    $y4 = $dy - $x2o * $k;

    imageline($im, $x1, $y1, $dx, $dy, $color);
//    imageline($im, $x3, $y3, $x4, $y4, $color);
    imageline($im, $x3, $y3, $x2, $y2, $color); // Schenkel
    imageline($im, $x2, $y2, $x4, $y4, $color); // Schenkel

}?>

Habe jetzt dein neues Skript angelegt, habe alles so gelassen wie es ist auch mit Bremen!
Diese Fehlermeldung bekomme ich!

Warning: Datei media/weather_Bremen.png existiert nicht in C:\IP-Symcon\scripts\58071.ips.php on line 218

Warning: Medium #0 existiert nicht in C:\IP-Symcon\scripts\58071.ips.php on line 218

Vielleicht kannst du nochmals drübersehen!

Mfg
Maxx