Hi 1007,
ich habe Dein Skript angepasst auf meine Umgebung, scheitere aber an einer Stelle:
Warning: Objekt Counter wurde nicht gefunden in C:\IP-Symcon\scripts\21500.ips.php on line 60
Warning: Variable #0 existiert nicht in C:\IP-Symcon\scripts\21500.ips.php on line 62
Warning: Objekt Error wurde nicht gefunden in C:\IP-Symcon\scripts\21500.ips.php on line 66
Warning: Variable #0 existiert nicht in C:\IP-Symcon\scripts\21500.ips.php on line 66
Warning: Variable #0 existiert nicht in C:\IP-Symcon\scripts\21500.ips.php on line 68
Warning: Variable #0 existiert nicht in C:\IP-Symcon\scripts\21500.ips.php on line 69
Klar, wenn er „Counter“ nicht findet sind das Folgefehler. Allerdings habe ich unter jedem Sensor eine Integer Variable „Counter“ und eine Boole „Error“ - die auch fleissig vom Skript befüllt werden.
Da das Skript dann irgendwann aussteigt (Abort Processing during exceed of maximal ErrorCount: Variable #0 existiert nicht), wird auch die HTML Variable nicht mehr beschrieben…
Irgendwelche Tipps ? Ich hab mir mal den Inhalt von $sensoren nach dem array ausdrucken lassen - das sah gut und auch vollständig aus.
Hier nochmal das angepasste Skript:
<?
if ( $_IPS['SENDER'] == 'Variable' )
{
FS20CounterUpdate($_IPS['VARIABLE']);
return;
}
ContentUpdate();
function ContentUpdate()
{
GLOBAL $debug;
$ah = 18888 /*[Archive Handler]*/; // Archiv ID
$tdheight = 42;
$textgroesse = 5;
$textgroesse2 = 3;
$border = 0;
$hgcolor = '#838383';
$hgerror = '#CC3333';
$contentid = IPSUtil_ObjectIDByPath('Program.Test.FS20_Übersicht');
$sensoren = array
(
// VariableID , Text in der Anzeige , Farbumschlag bei x pro Tag (normal=270/490) , Farbumschlag bei x pro Stunde (normal=13)
array(IPSUtil_ObjectIDByPath('Sensoren.Tiefkuehlung') ,'Tiefkuehlung' ,200,10),
array(IPSUtil_ObjectIDByPath('Sensoren.Aussentemperatur') ,'Aussentemperatur' ,200,10),
array(IPSUtil_ObjectIDByPath('Sensoren.Temperatur.TF_Bad') ,'Bad' ,200,10),
array(IPSUtil_ObjectIDByPath('Sensoren.Temperatur.TF_Werkstatt') ,'Werkstatt' ,200,10),
array(IPSUtil_ObjectIDByPath('Sensoren.Temperatur.Temperatur_Wohnzimmer') ,'Wohnzimmer' ,200,10),
array(IPSUtil_ObjectIDByPath('Sensoren.Temperatur.Temperatur_Schlafzimmer') ,'Schlafzimmer' ,200,10),
array(IPSUtil_ObjectIDByPath('Sensoren.Temperatur.Temperatur_Kueche') ,'Küche',200,10),
/* array(IPSUtil_ObjectIDByPath('Hardware.FS20.Temperaturfuehler.Wohnen.Wohnen.Temperatur') ,'Wohnzimmer' ,200,10),
array(IPSUtil_ObjectIDByPath('Hardware.FS20.Temperaturfuehler.Wohnen.Ofen.Temperatur') ,'Ofen Wohnzimmer' ,200,10),
array(IPSUtil_ObjectIDByPath('Hardware.FS20.Drucksensor.Bett.RawData') ,'Drucksensor' ,200,10),
array(IPSUtil_ObjectIDByPath('Hardware.FS20.Helligkeitssensor.Sensor1.RawData') ,'Helligkeitssensor' ,200,10),
array(IPSUtil_ObjectIDByPath('Hardware.FS20.Wetterstation.KS300 Wetterstation.Temperatur') ,'Wetterstation' ,400,20),
*/ );
$now = time();
$html = "";
$html .= "<table border='$border' width='100%' CELLSPACING='0' >";
$html .= "<colgroup>";
$html .= "<col width='20%'>";
$html .= "<col width='20%'>";
$html .= "<col width='20%'>";
$html .= "<col width='10%'>";
$html .= "<col width='10%'>";
$html .= "</colgroup>";
foreach ( $sensoren as $sensor )
{
$name = $sensor[1];
$cid = IPS_GetVariableIDByName('Counter', IPS_GetParent($sensor[0]));
$array = IPS_GetVariable($cid);
$updatet = $array["VariableUpdated"];
$updatet = date('d.m.Y H:i:s',$updatet);
$error = GetValueBoolean(IPS_GetVariableIDByName('Error',IPS_GetParent($sensor[0])));
$day = AC_GetLoggedValues($ah,$cid,$now-(3600*24),$now,0);
$hour = AC_GetLoggedValues($ah,$cid,$now-(3600),$now,0);
$counttag = count ($day);
$countstd = count ($hour);
if ( $counttag < $sensor[2] or $countstd < $sensor[3] )
$color = $hgerror;
else
$color = $hgcolor;
$html .= "<tr BGCOLOR=$color height='".$tdheight."'>" ;
$html .= "<td><font size=".$textgroesse.">" . $name . "</font></td>";
$html .= "<td><font size=".$textgroesse.">" . $updatet . "</font></td>";
$html .= "<td align='center'><font size=".$textgroesse.">" . $counttag . "</font></td>";
$html .= "<td align='center'><font size=".$textgroesse.">" . $countstd . "</font></td>";
if ( $error )
$html .= "<td><img src='/user/icons/fixed/alarm.gif' width='40' height='40' align='center'></td>";
else
$html .= "<td></font></td>";
$html .= "</tr>" ;
$html .= "<tr><td height='6'></td></tr>";
}
$html .= "</table>";
$contentid =IPSUtil_ObjectIDByPath('Program.Test.FS20_Übersicht');
SetValueString($contentid,$html);
print_r($html);
}
function FS20CounterUpdate($var)
{
GLOBAL $debug;
//$debug = true;
if ($debug) IPSLogger_Dbg(__FILE__, 'FS20CounterUpdate '. $var );
$parent = IPS_GetParent($var);
$id = IPS_GetVariableIDByName('Counter',$parent);
$counter = GetValueInteger($id);
$counter = $counter + 1;
SetValueInteger($id,$counter);
}
?>
Gruß
Martin