Esempio n. 1
0
 public function ApplyChanges()
 {
     //Never delete this line!
     parent::ApplyChanges();
     //Variablenprofil erstellen
     $this->RegisterProfileBooleanEx("HMON.OfflineOnline", "Network", "", "", array(array(false, "Offline", "", 0xff0000), array(true, "Online", "", 0xff00)));
     if ($this->ReadPropertyString("HostName") != "" and $this->ReadPropertyString("HostAdresse") != "") {
         //Status setzen
         $this->SetStatus(102);
         //Variablen erstellen
         $this->RegisterVariableBoolean("HostStatus", "Host - Status", "HMON.OfflineOnline");
         $this->RegisterVariableBoolean("HostBenachrichtigungsFlag", "Tmp");
         IPS_SetHidden($this->GetIDForIdent("HostBenachrichtigungsFlag"), true);
         $this->RegisterVariableInteger("HostLastOnline", "Host - Zuletzt online", "~UnixTimestamp");
         IPS_SetIcon($this->GetIDForIdent("HostLastOnline"), "Calendar");
         //Logging aktivieren
         if ($this->ReadPropertyBoolean("LoggingAktiv") === true) {
             $ArchiveHandlerID = IPS_GetInstanceListByModuleID('{43192F0B-135B-4CE7-A0A7-1475603F3060}')[0];
             AC_SetLoggingStatus($ArchiveHandlerID, $this->GetIDForIdent("HostStatus"), true);
             IPS_ApplyChanges($ArchiveHandlerID);
         } else {
             $ArchiveHandlerID = IPS_GetInstanceListByModuleID('{43192F0B-135B-4CE7-A0A7-1475603F3060}')[0];
             AC_SetLoggingStatus($ArchiveHandlerID, $this->GetIDForIdent("HostStatus"), false);
             IPS_ApplyChanges($ArchiveHandlerID);
         }
         //Timer erstellen
         $this->SetTimerInterval("HMON_UpdateTimer", $this->ReadPropertyInteger("Intervall"));
         $this->SetTimerByIdent_InSekunden("HMON_BenachrichtigungOfflineTimer", false);
         IPS_SetHidden($this->GetIDForIdent("HMON_BenachrichtigungOfflineTimer"), true);
         //Update
         $this->Update();
     } else {
         $this->SetStatus(206);
     }
     //Fehlerhafte Konfiguration melden
     if ($this->ReadPropertyBoolean("PushMsgAktiv") === true and $this->ReadPropertyInteger("WebFrontInstanceID") == "") {
         $this->SetStatus(201);
     }
     if ($this->ReadPropertyBoolean("EMailMsgAktiv") === true and $this->ReadPropertyInteger("SmtpInstanceID") == "") {
         $this->SetStatus(202);
     }
     if ($this->ReadPropertyBoolean("EigenesSkriptAktiv") === true and $this->ReadPropertyInteger("EigenesSkriptID") == "") {
         $this->SetStatus(203);
     }
     if ($this->ReadPropertyBoolean("PushMsgAktiv") === false and $this->ReadPropertyBoolean("EMailMsgAktiv") === false and $this->ReadPropertyBoolean("EigenesSkriptAktiv") === false and $this->ReadPropertyBoolean("OfflineBenachrichtigung") === true) {
         $this->SetStatus(204);
     }
     if ($this->ReadPropertyBoolean("OfflineBenachrichtigung") === false and $this->ReadPropertyBoolean("OnlineBenachrichtigung") === true) {
         $this->SetStatus(205);
     }
 }
Esempio n. 2
0
 public function ApplyChanges()
 {
     // Diese Zeile nicht löschen
     parent::ApplyChanges();
     //Variablenprofil anlegen
     if (!IPS_VariableProfileExists("Megabyte")) {
         IPS_CreateVariableProfile("Megabyte", 2);
         IPS_SetVariableProfileValues("Megabyte", 0, 0, 2);
         IPS_SetVariableProfileText("Megabyte", "", " MB");
     }
     if ($this->ReadPropertyString("IPS_Pfad") != "" and $this->ReadPropertyString("Netzwerkkarte") != "") {
         //Variablen erstellen
         $this->RegisterVariableFloat("CPU_idle", "CPU-Auslastung", "Humidity.F", 1);
         $this->RegisterVariableFloat("CPU_volts", "CPU-Spannung", "Volt", 2);
         $this->RegisterVariableFloat("CPU_temp", "CPU-Temperatur", "Temperature", 3);
         $this->RegisterVariableFloat("HDD_total", "Gesamt Speicherplatz", "Megabyte", 4);
         $this->RegisterVariableFloat("HDD_used", "Belegter Speicherplatz", "Megabyte", 5);
         $this->RegisterVariableFloat("HDD_percent", "HDD-Belegung", "Humidity.F", 6);
         $this->RegisterVariableFloat("HDD_symcon", "IPS-Speicherbelegung", "Megabyte", 7);
         $this->RegisterVariableFloat("RAM_total", "Gesamt RAM", "Megabyte", 8);
         $this->RegisterVariableFloat("RAM_used", "Benutzer RAM", "Megabyte", 9);
         $this->RegisterVariableFloat("RAM_percent", "RAM-Auslastung", "Humidity.F", 10);
         $this->RegisterVariableString("System_Info", "System Informationen", "HTMLBox", 11);
         //Timer zeit setzen
         $this->SetTimerInterval("Update", $this->ReadPropertyInteger("UpdateInterval") * 1000);
     } else {
         //Instanz ist inaktiv
         $this->SetStatus(104);
     }
     //Variablen Logging Aktivieren / Deaktivieren
     $archiveHandlerID = IPS_GetInstanceListByModuleID('{43192F0B-135B-4CE7-A0A7-1475603F3060}')[0];
     AC_SetLoggingStatus($archiveHandlerID, $this->GetIDForIdent("CPU_idle"), $this->ReadPropertyBoolean("logCPU_idle"));
     AC_SetLoggingStatus($archiveHandlerID, $this->GetIDForIdent("CPU_volts"), $this->ReadPropertyBoolean("logCPU_volts"));
     AC_SetLoggingStatus($archiveHandlerID, $this->GetIDForIdent("CPU_temp"), $this->ReadPropertyBoolean("logCPU_temp"));
     AC_SetLoggingStatus($archiveHandlerID, $this->GetIDForIdent("HDD_total"), $this->ReadPropertyBoolean("logHDD_total"));
     AC_SetLoggingStatus($archiveHandlerID, $this->GetIDForIdent("HDD_used"), $this->ReadPropertyBoolean("logHDD_used"));
     AC_SetLoggingStatus($archiveHandlerID, $this->GetIDForIdent("HDD_percent"), $this->ReadPropertyBoolean("logHDD_percent"));
     AC_SetLoggingStatus($archiveHandlerID, $this->GetIDForIdent("HDD_symcon"), $this->ReadPropertyBoolean("logHDD_symcon"));
     AC_SetLoggingStatus($archiveHandlerID, $this->GetIDForIdent("RAM_total"), $this->ReadPropertyBoolean("logRAM_total"));
     AC_SetLoggingStatus($archiveHandlerID, $this->GetIDForIdent("RAM_used"), $this->ReadPropertyBoolean("logRAM_used"));
     AC_SetLoggingStatus($archiveHandlerID, $this->GetIDForIdent("RAM_percent"), $this->ReadPropertyBoolean("logRAM_percent"));
     IPS_ApplyChanges($archiveHandlerID);
     copy(IPS_GetKernelDir() . "modules/IPS_PI_Monitor/PI_Monitor/Raspi-PGB001.png", IPS_GetKernelDir() . "webfront/user/Raspi-PGB001.png");
 }
 /**
  * checks if the variable logging state fits the settings
  * if not this method will update the variable logging
  *
  * @throws Exception if $archiveId is not set while logging is enabled
  * @access private
  */
 private function verifyVariableLogging()
 {
     if ($this->enableLogging) {
         if ($this->archiveId == NULL) {
             throw new Exception("Parameter \$archiveId is not set but \$enableLogging is true");
         }
         if ($this->checkArchive($this->archiveId)) {
             if (!AC_GetLoggingStatus($this->archiveId, $this->id)) {
                 AC_SetLoggingStatus($this->archiveId, $this->id, true);
                 AC_SetAggregationType($this->archiveId, $this->id, $this->aggregationType);
                 IPS_ApplyChanges($this->archiveId);
             }
         }
     } else {
         //todo: disable logging not implemented
     }
 }
function Variable_GetOrSet($name, $parent, $value)
{
    global $Logging;
    $VarID = @IPS_GetVariableIDByName($name, $parent);
    if (!$VarID) {
        if ($name == "Name" or $name == "Marke" or $name == "ID" or $name == "Anschrift") {
            $VarID = IPS_CreateVariable(3);
        } elseif ($name == "Geöffnet_von" or $name == "Geöffnet_bis") {
            $VarID = IPS_CreateVariable(3);
            $ProfilName = "GeoffnetVonBis_Tankstelle_TK";
            if (!IPS_VariableProfileExists($ProfilName)) {
                IPS_CreateVariableProfile($ProfilName, 3);
                IPS_SetVariableProfileText($ProfilName, "", " Uhr");
                IPS_SetVariableProfileIcon($ProfilName, "Clock");
            }
            IPS_SetVariableCustomProfile($VarID, $ProfilName);
        } elseif ($name == "Geöffnet") {
            $VarID = IPS_CreateVariable(0);
            $ProfilName = "Geoeffnet_Tankstelle_TK";
            if (!IPS_VariableProfileExists($ProfilName)) {
                IPS_CreateVariableProfile($ProfilName, 0);
                IPS_SetVariableProfileAssociation($ProfilName, 0, "Geschlossen", "", -1);
                IPS_SetVariableProfileAssociation($ProfilName, 1, "Geöffnet", "", -1);
                IPS_SetVariableProfileIcon($ProfilName, "Information");
            }
            IPS_SetVariableCustomProfile($VarID, $ProfilName);
        } elseif ($name == "Distanz") {
            $VarID = IPS_CreateVariable(2);
            $ProfilName = "Distanz_Tankstelle_TK";
            if (!IPS_VariableProfileExists($ProfilName)) {
                IPS_CreateVariableProfile($ProfilName, 2);
                IPS_SetVariableProfileText($ProfilName, "", "km");
                IPS_SetVariableProfileDigits($ProfilName, 1);
                IPS_SetVariableProfileIcon($ProfilName, "Distance");
            }
            IPS_SetVariableCustomProfile($VarID, $ProfilName);
        } elseif ($name == "Preis" or $name == "Preis_E5" or $name == "Preis_E10" or $name == "Preis_Diesel") {
            if ($value === NULL) {
                return;
            }
            $VarID = IPS_CreateVariable(2);
            $ProfilName = "Euro_Tankstelle_TK";
            if (!IPS_VariableProfileExists($ProfilName)) {
                IPS_CreateVariableProfile($ProfilName, 2);
                IPS_SetVariableProfileText($ProfilName, "", "€");
                IPS_SetVariableProfileDigits($ProfilName, 3);
                IPS_SetVariableProfileIcon($ProfilName, "Euro");
            }
            IPS_SetVariableCustomProfile($VarID, $ProfilName);
            if ($Logging) {
                $ArchiveHandlerID = IPS_GetInstanceListByModuleID('{43192F0B-135B-4CE7-A0A7-1475603F3060}')[0];
                AC_SetLoggingStatus($ArchiveHandlerID, $VarID, true);
                IPS_ApplyChanges($ArchiveHandlerID);
            }
        }
        IPS_SetName($VarID, $name);
        IPS_SetParent($VarID, $parent);
    }
    SetValue($VarID, $value);
}
Esempio n. 5
0
 public function ApplyChanges()
 {
     //Never delete this line!
     parent::ApplyChanges();
     $ArchivID = IPS_GetInstanceListByModuleID("{43192F0B-135B-4CE7-A0A7-1475603F3060}");
     $ArchivID = $ArchivID[0];
     $this->RegisterProfile(1, "WITHINGS_M_Groesse", "Gauge", "", " cm");
     $this->RegisterProfile(1, "WITHINGS_M_Puls", "Graph", "", " bpm");
     $this->RegisterProfile(2, "WITHINGS_M_Kilo", "", "", " kg", false, false, false, 1);
     $this->RegisterProfile(2, "WITHINGS_M_Prozent", "", "", " %", false, false, false, 1);
     $this->RegisterProfile(2, "WITHINGS_M_BMI", "", "", " kg/m²", false, false, false, 1);
     $this->RegisterProfile(1, "WITHINGS_M_Blutdruck", "", "", " mmHg");
     $this->RegisterProfileGender("WITHINGS_M_Gender", "", "", "", array(array(0, "maennlich", "", 0xff), array(1, "weiblich", "", 0xff0000)));
     $id = $this->RegisterVariableString("name", "Name", "~String", 0);
     $id = $this->RegisterVariableInteger("gender", "Geschlecht", "WITHINGS_M_Gender", 2);
     $id = $this->RegisterVariableString("birthdate", "Geburtstag", "~String", 1);
     $id = $this->RegisterVariableInteger("height", "Groesse", "WITHINGS_M_Groesse", 3);
     $parent = IPS_GetParent($id);
     $CatID = false;
     if ($this->ReadPropertyBoolean("BloodMeasures") == true) {
         $CatID = $this->CreateKategorie("Blutdruck", $parent);
         if ($CatID === false) {
             throw new Exception("Kategorie Blutdruck nicht definiert");
         }
         $VariablenID = @IPS_GetVariableIDByName("Diastolic", $CatID);
         if ($VariablenID === false) {
             $id = $this->RegisterVariableInteger("diastolicblood", "Diastolic", "WITHINGS_M_Blutdruck", 2);
             IPS_SetParent($id, $CatID);
         }
         $VariablenID = @IPS_GetVariableIDByName("Systolic", $CatID);
         if ($VariablenID === false) {
             $id = $this->RegisterVariableInteger("systolicblood", "Systolic", "WITHINGS_M_Blutdruck", 1);
             IPS_SetParent($id, $CatID);
         }
         $VariablenID = @IPS_GetVariableIDByName("Puls", $CatID);
         if ($VariablenID === false) {
             $id = $this->RegisterVariableInteger("heartpulse", "Puls", "WITHINGS_M_Puls", 3);
             IPS_SetParent($id, $CatID);
         }
         $VariablenID = @IPS_GetVariableIDByName("DatumUhrzeit", $CatID);
         if ($VariablenID === false) {
             $id = $this->RegisterVariableInteger("timestamp", "DatumUhrzeit", "~UnixTimestamp", 0);
             IPS_SetParent($id, $CatID);
         }
     }
     $logging = $this->ReadPropertyBoolean("BloodLogging");
     if ($CatID) {
         if ($logging) {
             $this->Logging("BloodLogging wird eingeschaltet");
         } else {
             $this->Logging("BloodLogging wird ausgeschaltet");
         }
         $id = IPS_GetVariableIDByName("Diastolic", $CatID);
         if (AC_GetLoggingStatus($ArchivID, $id) != $logging) {
             AC_SetLoggingStatus($ArchivID, $id, $logging);
             IPS_ApplyChanges($ArchivID);
         }
         $id = IPS_GetVariableIDByName("Systolic", $CatID);
         if (AC_GetLoggingStatus($ArchivID, $id) != $logging) {
             AC_SetLoggingStatus($ArchivID, $id, $logging);
             IPS_ApplyChanges($ArchivID);
         }
         $id = IPS_GetVariableIDByName("Puls", $CatID);
         if (AC_GetLoggingStatus($ArchivID, $id) != $logging) {
             AC_SetLoggingStatus($ArchivID, $id, $logging);
             IPS_ApplyChanges($ArchivID);
         }
         $status = $this->ReadPropertyBoolean("BloodVisible");
         $this->KategorieEnable($parent, "Blutdruck", $status);
     }
     $CatID = false;
     if ($this->ReadPropertyBoolean("BodyMeasures") == true) {
         $CatID = $this->CreateKategorie("Waage", $parent);
         if ($CatID === false) {
             throw new Exception("Kategorie Waage nicht definiert");
         }
         $VariablenID = @IPS_GetVariableIDByName("DatumUhrzeit", $CatID);
         if ($VariablenID === false) {
             $id = $this->RegisterVariableInteger("timestamp", "DatumUhrzeit", "~UnixTimestamp", 0);
             IPS_SetParent($id, $CatID);
         }
         $VariablenID = @IPS_GetVariableIDByName("Gewicht", $CatID);
         if ($VariablenID === false) {
             $id = $this->RegisterVariableFloat("weight", "Gewicht", "WITHINGS_M_Kilo", 1);
             IPS_SetParent($id, $CatID);
         }
         $VariablenID = @IPS_GetVariableIDByName("Fettfrei Anteil", $CatID);
         if ($VariablenID === false) {
             $id = $this->RegisterVariableFloat("fatfree", "Fettfrei Anteil", "WITHINGS_M_Kilo", 3);
             IPS_SetParent($id, $CatID);
         }
         $VariablenID = @IPS_GetVariableIDByName("Fett Anteil", $CatID);
         if ($VariablenID === false) {
             $id = $this->RegisterVariableFloat("fatmassweight", "Fett Anteil", "WITHINGS_M_Kilo", 2);
             IPS_SetParent($id, $CatID);
         }
         $VariablenID = @IPS_GetVariableIDByName("Fett Prozent", $CatID);
         if ($VariablenID === false) {
             $id = $this->RegisterVariableFloat("fatradio", "Fett Prozent", "WITHINGS_M_Prozent", 4);
             IPS_SetParent($id, $CatID);
         }
         $VariablenID = @IPS_GetVariableIDByName("BMI", $CatID);
         if ($VariablenID === false) {
             $id = $this->RegisterVariableFloat("bmi", "BMI", "WITHINGS_M_BMI", 5);
             IPS_SetParent($id, $CatID);
         } else {
             @IPS_SetVariableCustomProfile($VariablenID, "WITHINGS_M_BMI");
         }
         if ($this->ReadPropertyBoolean("BodyPuls") == true) {
             $VariablenID = @IPS_GetVariableIDByName("Puls", $CatID);
             if ($VariablenID === false) {
                 $id = $this->RegisterVariableInteger("heartpulse", "Puls", "WITHINGS_M_Puls", 3);
                 IPS_SetParent($id, $CatID);
             }
         }
     }
     $logging = $this->ReadPropertyBoolean("BodyLogging");
     if ($CatID) {
         if ($logging) {
             $this->Logging("BodyLogging wird eingeschaltet");
         } else {
             $this->Logging("BodyLogging wird ausgeschaltet");
         }
         $id = IPS_GetVariableIDByName("Gewicht", $CatID);
         if (AC_GetLoggingStatus($ArchivID, $id) != $logging) {
             AC_SetLoggingStatus($ArchivID, $id, $logging);
             IPS_ApplyChanges($ArchivID);
         }
         $id = IPS_GetVariableIDByName("Fettfrei Anteil", $CatID);
         if (AC_GetLoggingStatus($ArchivID, $id) != $logging) {
             AC_SetLoggingStatus($ArchivID, $id, $logging);
             IPS_ApplyChanges($ArchivID);
         }
         $id = IPS_GetVariableIDByName("Fett Anteil", $CatID);
         if (AC_GetLoggingStatus($ArchivID, $id) != $logging) {
             AC_SetLoggingStatus($ArchivID, $id, $logging);
             IPS_ApplyChanges($ArchivID);
         }
         $id = IPS_GetVariableIDByName("Fett Prozent", $CatID);
         if (AC_GetLoggingStatus($ArchivID, $id) != $logging) {
             AC_SetLoggingStatus($ArchivID, $id, $logging);
             IPS_ApplyChanges($ArchivID);
         }
         $id = IPS_GetVariableIDByName("BMI", $CatID);
         if (AC_GetLoggingStatus($ArchivID, $id) != $logging) {
             AC_SetLoggingStatus($ArchivID, $id, $logging);
             IPS_ApplyChanges($ArchivID);
         }
         $id = @IPS_GetVariableIDByName("Puls", $CatID);
         if ($id > 0) {
             if (AC_GetLoggingStatus($ArchivID, $id) != $logging) {
                 AC_SetLoggingStatus($ArchivID, $id, $logging);
                 IPS_ApplyChanges($ArchivID);
             }
         }
     }
     $status = $this->ReadPropertyBoolean("BodyVisible");
     $this->KategorieEnable($parent, "Waage", $status);
     //Timer erstellen
     $this->SetTimerInterval("WIT_UpdateTimer", $this->ReadPropertyInteger("Intervall"));
     //Update
     $this->Update();
 }