Eine Kleinigkeit habe ich noch auf die Schnelle fertiggestellt.TomT hat geschrieben:Wenn Badenpower nichts mehr hat zur Zeit, dann beende ich das testen auch erst einmal...
Diese Skript prüft, ob ein Timerausfall vorliegt und kann dieses protokollieren.
Im Skript kann man den Namen einer Systemvariable von Typ Zeichenkette angeben und diese auf "Protokollieren" stellen, damit man die Ausgabe im Systemprotokoll sehen kann.
Desweiteren kann man die Skriptvariable "lReactivate" auf true setzen, um einen Timer zu reaktivieren.
Das Skript packt man dann in ein Programm und läßt es durch einen Trigger starten.
Das kann entweder ein Zeitmodul sein, oder aber ein Sensor/Aktor bei dem man den Trigger dann auf "bei Aktuallisierung" stellt. Sollte das Programm noch häufiger gestartet werden, dann kann man ja auch mehrere Geräte welche zyklische Statusmeldungen versenden, in den Wenn-Abschnitt packen.
Code: Alles auswählen
!Zeitmodulkontrolle V1.0.2
!****************************************************
!www.homematic-forum.de (c) by BadenPower
boolean lReactivate = false;
string lTimerID = "";
string lSysVarProtocolIdent = "SYS-Protokoll";
string lSysVarDeadlockIdent = "SYS-Timerausfall";
string lSysVarDeadlockCountIdent = "SYS-Timerausfälle";
string lSysVarCounterIdent = "SYS-Timerneustarts";
!-------------Einstellungen Ende--------------
boolean lDeadlock = false;
integer lPeriodDiff = 0;
integer lPeriodDiffMin = 60;
integer lDeadlocks = 0;
string lEnum1 = "";
string lEnum2 = "";
string lProtocolText = "Timerausfall -";
string lSep = "\t";
time lZeroTime = @1970-01-01 01:00:00@;
object lProgram;
object lProtocol;
object lSysvarCounter;
object lSysvarDeadlock;
object lSysvarDeadlockCount;
object lSysVars = dom.GetObject(ID_SYSTEM_VARIABLES);
object lTimer;
object lTimers = dom.GetObject(ID_CALENDARDPS);
if(lSysVarProtocolIdent <> "")
{
lProtocol = lSysVars.Get(lSysVarProtocolIdent);
}
if(lSysVarCounterIdent <> "")
{
lSysvarCounter = lSysVars.Get(lSysVarCounterIdent);
}
if(lSysVarDeadlockIdent <> "")
{
lSysvarDeadlock = lSysVars.Get(lSysVarDeadlockIdent);
}
if(lSysVarDeadlockCountIdent <> "")
{
lSysvarDeadlockCount = lSysVars.Get(lSysVarDeadlockCountIdent);
}
if(lTimers)
{
foreach(lEnum1,lTimers.EnumIDs())
{
lTimer = dom.GetObject(lEnum1);
if(lTimer)
{
if(((lTimerID == "") || (lTimerID == (lTimer.ID()).ToString())) && (lTimer.TimerType() == ttPeriodic))
{
if(lTimer.DPUsageCount() > 0)
{
lProgram = dom.GetObject((lTimer.DPEnumUsagePrograms()).StrValueByIndex(lSep,0));
}
if(lProgram)
{
if(lProgram.Active())
{
lDeadlock = false;
lPeriodDiff = lPeriodDiffMin + lTimer.Period();
if(((lTimer.Timestamp() + lPeriodDiff) < lTimer.Next()) || (lTimer.Next() <= lZeroTime))
{
lDeadlock = true;
}
if(lDeadlock)
{
lDeadlocks = lDeadlocks + 1;
if(lProtocol)
{
lProtocolText = "Timerausfall ";
lProtocolText = lProtocolText # " Programm: " # lProgram.Name();
lProtocolText = lProtocolText # " PrgID: " # (lProgram.ID()).ToString();
lProtocolText = lProtocolText # " TimerID: " # (lTimer.ID()).ToString();
lProtocolText = lProtocolText # " TS: " # (lTimer.Timestamp()).ToString();
lProtocolText = lProtocolText # " N: " # (lTimer.Next()).ToString();
lProtocolText = lProtocolText # " Ende"
lProtocol.State(lProtocolText);
}
if(lReactivate)
{
lProgram.Active(false);
lProgram.Active(true);
if(lSysvarCounter)
{
if(lSysvarCounter.Value() >= lSysvarCounter.ValueMax())
{
lSysvarCounter.State(lSysvarCounter.ValueMin() + 1);
}
else
{
lSysvarCounter.State(lSysvarCounter.Value() + 1);
}
}
}
}
}
}
}
}
}
}
if(lSysvarDeadlock)
{
if(lSysvarDeadlockCount)
{
if((lSysvarDeadlock.Value() == false) && (lDeadlocks > 0))
{
if(lSysvarDeadlockCount.Value() >= lSysvarDeadlockCount.ValueMax())
{
lSysvarDeadlockCount.State(lSysvarDeadlockCount.ValueMin() + 1);
}
else
{
lSysvarDeadlockCount.State(lSysvarDeadlockCount.Value() + 1);
}
}
}
if(lSysvarDeadlock.Value() <> (lDeadlocks > 0))
{
lSysvarDeadlock.State((lDeadlocks > 0));
}
}
Sollte etwas nicht funktionieren, wie ich es eigentlich dachte, dann meldet Euch einfach.
.