Batterie Kontroll script zeigt einen Fehler

Hallo zusammen,
da mein WINDOS pc den Geist aufgegeben hat, steige ich auf Raspi um, auch wenn es noch beta ist.

Die Funktionen die ich brauche gehen soweit alle. :loveips:

Vielen Dank an alle die das ermöglichen.
Ich habe immer das Batteriekontrollscrip benutzt, welches mal hier im Forum vorgestellt wurde.

Ich bekomme an einer Stelle immer einen Fehler, den ich nicht lösen kann.

Es handelt sich um die $_IPS[‚SELF‘]
Der Fehler lautet:
Parse error: syntax error, unexpected ‚[‘, expecting ‚,‘ or ‚;‘ in /usr/share/symcon/scripts/23979.ips.php on line 141
Weiß jemand Rat?

<?
/*****
    *
    * Ü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 = 5;    // 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");
    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 />";
                    SMTP_SendMail(21198 /*[Objekt #21198 existiert nicht]*/,"!!! Achtung Batteriewarnung !!!","testtext");
                     $VariabletypID = "test";
					 }
            }
        }

        if ($result == "")
        {
            echo "Keine Probleme bekannt.";
            //SetValueString(48687 /*[Infos\Batteriekontrollscript	yp]*/,"Keine Probleme bekannt.");
            IPS_LogMessage("ID:".$_IPS['SELF'],"Keine Batterieprobleme gefunden");
            //SMTP_SendMail(21198 /*[Objekt #21198 existiert nicht]*/,"!!! Achtung Batteriewarnung !!!","Keine Batterieprobleme gefunden");
            SetValueBoolean($VariableWarningID, false);
        }
        else
        {
            echo "Geräte mit Batterieproblemen:<br /><br />".$result;
            SetValueString(48687 /*[Infos\Batteriekontrollscript	yp]*/,"Geräte mit Batterieproblemen:<br /><br />".$result);
            
            SetValueBoolean($VariableWarningID, true);
            IPS_LogMessage("ID:".$_IPS['SELF'],"Geräte mit Batterieproblemen:<br /><br />".$result);
            SMTP_SendMail(21198 /*[Objekt #21198 existiert nicht]*/,"!!! Achtung Batteriewarnung !!!","Geräte mit Batterieproblemen:<br /><br />".$result);
        }
        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; }
                
            }
        }

        SetValueBoolean($VariableWarningID, $warning);
        IPS_SetScriptTimer($_IPS['SELF'], $Interval * 60);
         
    }

    function CreateVariableByName($id, $name, $type, $profile = "")
    {
			global $_IPS['SELF']
		          $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;
    }
?>

in der Zeile hinter „global $_IPS[‚SELF‘]“ semikolon einfügen.

Hallo DJT0815,

ja stimmt, hatte ich auch schon probiert, aber der Fehler kommt immer noch, leider

Noch ein hinweis vielleicht hilft das:

Ich hatte das ganze script auf die neuen Befehle angepasst:
aus vorher global $IPS_SELF;
wurde dann global $_IPS[‚SELF‘];

Und somit geht nichts mehr!!

Dann versuchte es doch so:
Global $_IPS;
Aber ich glaube es gibt da noch einen offenen Bug (Systemvariablen sind nicht wirklich global o.ä.).
Wenn der nicht schon gefixt wurde.
Michael

Hmm,
ich habe es mal geändet und in Zeile 148 auch.
Es kommt keine Fehlermeldung mal testen ob es auch funktioniert!!

Danke Michael