Hallo,
habe mal am Pi (Odroid) das Skript „Automatische Reaggregation aller geloggten Variablen“ etwas umgebaut.
Es reicht mir, um einen Trend zu sehen.
<?
/*****
*
* Automatische Reaggregation aller geloggten Variablen
*
* Dieses Skript reaggregiert automatisch alle geloggten Variablen nacheinander
* automatisiert bei Ausführung. Nach Abschluss des Vorgangs wird der Skript-Timer
* gestoppt. Zur erneuten kompletten Reaggregation ist der Inhalt der automatisch
* unterhalb des Skripts angelegten Variable 'History' zu löschen.
*
*****/
$archiveHandlerID = IPS_GetInstanceIDByName("Archive", 0);
$historyID = CreateVariableByName($_IPS['SELF'], "History", 3, "");
// Neu rein, TS
$historyIDdef = CreateVariableByName($_IPS['SELF'], "History defekte ID", 3, "");
// Neu rein ENDE, TS
$finished = true;
$history = explode(',', GetValue($historyID));
// Neu rein, TS
$historydef = explode(',', GetValue($historyIDdef));
// Neu rein ENDE, TS
$variableIDs = IPS_GetVariableList();
foreach ($variableIDs as $variableID)
{
// Raus,TS!
// if(IPS_GetVariable($variableID)["VariableValue"]["ValueType"] != 3)
// Raus ENDE
if(IPS_GetVariable($variableID)["VariableType"] != 3)
{
if (AC_GetLoggingStatus($archiveHandlerID, $variableID) && !in_array($variableID,$history))
{
$finished = false;
// Neu rein, TS
$history[] = $variableID;
SetValue($historyID, implode(',', $history));
// Neu rein Ende, TS
if (@AC_ReAggregateVariable($archiveHandlerID, $variableID))
{
// Neu raus, TS
// $history[] = $variableID;
// SetValue($historyID, implode(',', $history));
// print_r ($variableID);
// Neu raus ENDE, TS
}
// Neu rein, TS
else
{
$historydef[] = $variableID;
SetValue($historyIDdef, implode(',', $historydef));
}
// Neu rein Ende, TS
break;
}
}
}
if ($finished)
{
IPS_LogMessage('Reaggregation', 'Reaggregation completed!');
}
IPS_SetScriptTimer($_IPS['SELF'], $finished ? 0 : 5); //zum testen, da schneller auf Odroid....
// IPS_SetScriptTimer($_IPS['SELF'], $finished ? 0 : 60); // Orginal
function CreateVariableByName($id, $name, $type, $profile = "")
{
$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;
}
?>
Starte ich um ca 0:10 Nachts, vorher der diedie „Variablen“ ($history und $historydef) per Timer gelöscht…