So Leute
Da ich ja aufgrund eines Ausfall meiner SDD so ziemlich jedes Script neu machen muss, hab ich das Script nochmal überarbeitet.
Die Variabeln legen sich nun selbst mit dem richtigem Typ und Profil an,das Logging wird eingeschaltet und ein Timer auf 60sec geschaltet.
Anleiteung:
1 Dummy Instant anlegen
2 Script mit Inhalt unten erstellen
3 die ersten 2 ID’s eintragen.
4 einmal ausführen
Fertig
<?
//Hier die Instanz wo das alles rein soll
$ParentID = 42983 /*[Außen\Wetter\Wetterstation]*/;
// Archiv Handler damit das Logging eingeschaltet werden kann.
$arhid = 34960 /*[Archive Handler]*/;
if($_IPS['SENDER'] != "TimerEvent")
{
IPS_SetScriptTimer($IPS_SELF, 60);
IPS_SetHidden($IPS_SELF,true);
}
$mon_ger = array("Jan" => "Jan", "Feb" => "Feb", "Mar" => "Mrz", "Apr" => "Apr", "May" => "Mai", "Jun" => "Jun", "Jul" => "Jul", "Aug" => "Aug", "Sept" => "Sep", "Oct" => "Okt", "Nov" => "Nov", "Dec" => "Dez");
$filename = "C:/Cumulus/data/".$mon_ger[date("M")].date("y")."log.txt";
echo ($filename."
");
$handle = fopen($filename,"r");
//File nicht gefunden?
if (!$handle) echo ("PCE-FWS20 File not found");
//Gehe alle Datensätze durch
while ($line = fgets($handle))
{
if (strlen($line) > 10)
{
//Datenzeile zerlegen
$parameter = explode(";", $line);
//Zeile enthält Parameter?
if (count($parameter) == 17)
{
// echo ($parameter[0]." ".$parameter[1]."
");
}
}
}
fclose($handle);
echo ($parameter[0]." ".$parameter[1]."
");
vars($arhid,$ParentID,'Temperatur',$parameter[2],2,"~Temperature");
vars($arhid,$ParentID,'Feuchtigkeit',$parameter[3],1,"~Humidity");
vars($arhid,$ParentID,'Taupunkt',$parameter[4],2,"~Temperature");
vars($arhid,$ParentID,'Wind',$parameter[5],2,"~WindSpeed.kmh");
vars($arhid,$ParentID,'Wind_max_10',$parameter[6],2,"");
vars($arhid,$ParentID,'Windrichtung',$parameter[7],2,"~WindDirection");
vars($arhid,$ParentID,'Regen',$parameter[8],2,"~Rainfall");
vars($arhid,$ParentID,'Regen_Tag',$parameter[9],2,"~Rainfall");
vars($arhid,$ParentID,'Luftdruck',$parameter[10],1,"~AirPressure");
vars($arhid,$ParentID,'Innen Temperatur',$parameter[12],2,"~Temperature");
vars($arhid,$ParentID,'Innen Feuchtigkeit',$parameter[13],2,"~Humidity");
vars($arhid,$ParentID,'Wind_max_zuletzt',$parameter[14],2,"~WindSpeed.kmh");
vars($arhid,$ParentID,'Wind_Chill',$parameter[15],2,"~Temperature");
vars($arhid,$ParentID,'Heat_Index',$parameter[16],2,"~Temperature");
$richtung = $parameter[7];
if (($richtung < 22.5) and($richtung >= 0)) $w_text = "N";
if (($richtung < 67.5) and($richtung >= 22.5)) $w_text = "NO";
if (($richtung < 125.5) and($richtung >= 67.5)) $w_text = "O";
if (($richtung < 157.5) and($richtung >= 125.5)) $w_text = "SO";
if (($richtung < 202.5) and($richtung >= 157.5)) $w_text = "S";
if (($richtung < 247.5) and($richtung >= 202.5)) $w_text = "SW";
if (($richtung < 292.5) and($richtung >= 247.5)) $w_text = "W";
if (($richtung < 337.5) and($richtung >= 292.5)) $w_text = "NW";
if (($richtung < 360 ) and($richtung >= 337.5)) $w_text = "N";
vars($arhid,$ParentID,'Windrichtung Text',"$w_text - $richtung °",3,"");
$bft = $parameter[6];
if (($bft < 1) and($bft >= 0)) $bft_text = "0 - Windstille";
if (($bft < 6) and($bft >= 1)) $bft_text = "1 - Leiser Zug";
if (($bft < 13) and($bft >= 6)) $bft_text = "2 - Leichte Brise";
if (($bft < 20) and($bft >= 13)) $bft_text = "3 - schwache Brise";
if (($bft < 29) and($bft >= 20)) $bft_text = "4 - mäßige Brise";
if (($bft < 39) and($bft >= 29)) $bft_text = "5 - frische Brise";
if (($bft < 51) and($bft >= 39)) $bft_text = "6 - starker Wind";
if (($bft < 62) and($bft >= 51)) $bft_text = "7 - steifer Wind";
if (($bft < 75) and($bft >= 62)) $bft_text = "8 - stürmischer Wind";
if (($bft < 89) and($bft >= 75)) $bft_text = "9 - Sturm";
if (($bft < 103) and($bft >= 89)) $bft_text = "10 - schwerer Sturm";
if (($bft < 118) and($bft >= 103)) $bft_text = "11 - orkanartiger Sturm";
if (($bft < 132.9) and($bft >= 118)) $bft_text = "12 - Orkan";
vars($arhid,$ParentID,'Wind Text',$bft_text,3,"");
function vars($arhid,$ParentID, $Variname, $wert, $VariTyp, $VariProfile)
{
$VariID = IPS_GetVariableIDByName($Variname, $ParentID);
if ($VariID == false)
{
$VariID = IPS_CreateVariable ($VariTyp);
IPS_SetVariableCustomProfile($VariID, $VariProfile);
IPS_SetName($VariID,$Variname);
AC_SetLoggingStatus($arhid, $VariID, true);
IPS_SetParent($VariID,$ParentID);
}
SetValue($VariID, $wert);
}
function GetParentID($ID){
$obj = IPS_GetObject($ID);
return $obj['ParentID'];
}
?>