Ich wird nicht schlau draus wie man den Batterie Status der HM Geräte auslesen kann.
Habe bei meinen HM Komponenten ja die BooleanVariablen „LOWBAT“
Dieses Script benutze ich zum Auslesen der „LOWBAT“ Variable ( Script unter der LOWBAT Variable):
<?
/*****
*
* Überprüfung aller Geräte auf Batterieprobleme
*
* Dieses Skript richtet beim Aufruf eine automatische Batterieprüfung ein.
* Wird es über das WebFront aufgerufen erscheint eine Liste der problematischen
* Geräte.
*
* Alle Geräte, deren Batteriestatus bereits ein Variablenprofil besitzet, werden
* automatisch erkannt. Für alle anderen Variablen ist dies manuell nachzuholen.
*
* Anleitung:
* - Intervall nach belieben anpassen.
* - Bei entsprechender Kenntnis eventuell die Profilliste erweitern.
* - Skript zur Ausführung bringen, um Timer und Warnungs-Variable zu erstellen.
*
*****/
/***** Konfiguration *****/
$Interval = 360; // Kontrollintervall in Minuten
// Variablenprofile mit Werten, bei deren Erreichen oder Unterschreitung gewarnt wird
$Profiles = array("~Battery" => true, "~Battery.Reversed" => false, "~Battery.100" => 25);
/***** Programmcode (ab hier nichts mehr verändern) *****/
$VariableWarningID = CreateVariableByName($IPS_SELF, "Warnung", 0, "~Battery");
$VariableLoctionID = CreateVariableByName($IPS_SELF, "Standort", 3, "~String");
if ($IPS_SENDER == "WebFront")
{
$result = "";
$VariableIDs = IPS_GetVariableList();
foreach($VariableIDs as $VariableID)
{
if ($VariableID != $VariableWarningID)
{
$variableData = IPS_GetVariable($VariableID);
$value = GetValue($VariableID);
$profileName = IPS_VariableProfileExists($variableData['VariableProfile']) ? $variableData['VariableProfile'] : "";
$profileName = (strlen($variableData['VariableCustomProfile']) > 0 && IPS_VariableProfileExists($variableData['VariableCustomProfile'])) ? $variableData['VariableCustomProfile'] : $profileName;
$warning = false;
if (strlen($profileName) > 0)
{
foreach ($Profiles as $pName => $pValue)
{
if ($profileName == $pName)
{
if (is_bool($pValue))
{
if ($value == $pValue) { $warning = true; }
}
else
{
if ($value <= $pValue) { $warning = true; }
}
break;
}
}
}
if ($warning)
{
$result .= "<em>".IPS_GetLocation($VariableID)."</em>: ".GetValueFormatted($VariableID)."<br />";
}
}
}
if ($result == "")
{
echo "Keine Probleme bekannt.";
SetValueBoolean($VariableWarningID, false);
}
else
{
echo "Geräte mit Batterieproblemen:<br /><br />".$result;
SetValueBoolean($VariableWarningID, true);
}
IPS_SetScriptTimer($IPS_SELF, $Interval * 60);
}
else
{
$warning = false;
$VariableIDs = IPS_GetVariableList();
foreach ($VariableIDs as $VariableID)
{
if ($VariableID != $VariableWarningID)
{
$variableData = IPS_GetVariable($VariableID);
$value = GetValue($VariableID);
$profileName = IPS_VariableProfileExists($variableData['VariableProfile']) ? $variableData['VariableProfile'] : "";
$profileName = (strlen($variableData['VariableCustomProfile']) > 0 && IPS_VariableProfileExists($variableData['VariableCustomProfile'])) ? $variableData['VariableCustomProfile'] : $profileName;
$warning = false;
if (strlen($profileName) > 0)
{
foreach ($Profiles as $pName => $pValue)
{
if ($profileName == $pName)
{
if (is_bool($pValue))
{
if ($value == $pValue) { $warning = true; }
}
else
{
if ($value <= $pValue) { $warning = true; }
}
break;
}
}
}
if ($warning) { break; }
}
}
if ($warning == false)
{
SetValueString($VariableLoctionID, "");
}
else
{
SetValueString($VariableLoctionID, IPS_GetLocation($VariableID));
}
SetValueBoolean($VariableWarningID, $warning);
IPS_SetScriptTimer($IPS_SELF, $Interval * 60);
}
function CreateVariableByName($id, $name, $type)
{
$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']);
}
return $vid;
}
?>
Beim Ausführen des Scriptes wird die „LOWBAT“ Variable ab nicht aktualisiert, steht immer bei Aktualisiert „Nie“ dabei
Wird die trotzdem Abgefragt?
Danke