Ejemplo n.º 1
0
 private function deviceInstanceExists($name)
 {
     //if ($isUpdate)
     //{
     $children = IPS_GetChildrenIDs($this->InstanceID);
     foreach ($children as $child) {
         if (IPS_InstanceExists($child)) {
             $childInstance = @IPS_GetInstance($child);
             $childInstanceID = $childInstance['InstanceID'];
             $childInstanceName = @IPS_GetName($childInstanceID);
             // Check if it is a Dummy Module and if it has a known device name
             if ($childInstanceName == $name and $childInstance['ModuleInfo']['ModuleID'] == "{485D0419-BE97-4548-AA9C-C083EB82E61E}") {
                 return true;
             }
         }
     }
     return false;
     //} else {
     //	return false;
     //}
 }
Ejemplo n.º 2
0
 private function Benachrichtigung($Batterien_AR)
 {
     if ($this->ReadPropertyInteger("BenachrichtigungsVar") != 0) {
         if (GetValueBoolean($this->ReadPropertyInteger("BenachrichtigungsVar")) === false) {
             return;
         }
     }
     $ParentName1Tabelle = $this->Umlaute_Ersetzen($this->ReadPropertyString("NameParentTabelle1TB"));
     $ParentName2Tabelle = $this->Umlaute_Ersetzen($this->ReadPropertyString("NameParentTabelle2TB"));
     $ParentName3Tabelle = $this->Umlaute_Ersetzen($this->ReadPropertyString("NameParentTabelle3TB"));
     $BenachrichtigungsText = $this->ReadPropertyString("BatterieBenachrichtigungTEXT");
     foreach ($Batterien_AR as $Aktor) {
         $AktorName = $Aktor["Name"];
         if ($this->ReadPropertyBoolean("NamenParentObjekt1CB") == true) {
             $AktorParent1Name = $Aktor[$ParentName1Tabelle];
         }
         if ($this->ReadPropertyBoolean("NamenParentObjekt2CB") == true) {
             $AktorParent2Name = $Aktor[$ParentName2Tabelle];
         }
         if ($this->ReadPropertyBoolean("NamenParentObjekt3CB") == true) {
             $AktorParent3Name = $Aktor[$ParentName3Tabelle];
         }
         $AktorHersteller = $Aktor["Hersteller"];
         $AktorID = $Aktor["ID"];
         $AktorBatterie = $Aktor["Batterie"];
         $AktorLetztesUpdateSEK = $Aktor["LetztesVarUpdateVorSek"];
         $AktorLetztesUpdateTS = date("d.m.Y H:i", $Aktor["LetztesVarUpdateTimestamp"]);
         //Code-Wörter austauschen gegen gewünschte Werte
         $search = array("§AKTORHERSTELLER", "§AKTORID", "§AKTORBATTERIE", "§AKTORLETZTESUPDATE");
         $replace = array($AktorHersteller, $AktorID, $AktorBatterie, $AktorLetztesUpdateTS);
         if ($this->ReadPropertyBoolean("NamenAktorObjektCB") == true) {
             array_push($search, "§AKTORNAME");
             array_push($replace, $AktorName);
         }
         if ($this->ReadPropertyBoolean("NamenParentObjekt1CB") == true) {
             array_push($search, "§AKTORPARENT1");
             array_push($replace, $AktorParent1Name);
         }
         if ($this->ReadPropertyBoolean("NamenParentObjekt2CB") == true) {
             array_push($search, "§AKTORPARENT2");
             array_push($replace, $AktorParent2Name);
         }
         if ($this->ReadPropertyBoolean("NamenParentObjekt3CB") == true) {
             array_push($search, "§AKTORPARENT3");
             array_push($replace, $AktorParent3Name);
         }
         $Text = str_replace($search, $replace, $BenachrichtigungsText);
         $Text = str_replace('Â', '', $Text);
         //PUSH-NACHRICHT
         if ($this->ReadPropertyBoolean("PushMsgAktiv") == true) {
             $WFinstanzID = $this->ReadPropertyInteger("WebFrontInstanceID");
             if ($WFinstanzID != "" and @IPS_InstanceExists($WFinstanzID) === true) {
                 if (strlen($Text) <= 256) {
                     WFC_PushNotification($WFinstanzID, "BatterieMonitor", $Text, "", 0);
                 } else {
                     IPS_LogMessage("BatterieMonitor", "FEHLER!!! - Die Textlänge einer Push-Nachricht darf maximal 256 Zeichen betragen!!!");
                 }
             }
         }
         //EMAIL-NACHRICHT
         if ($this->ReadPropertyBoolean("EMailMsgAktiv") == true) {
             $SMTPinstanzID = $this->ReadPropertyInteger("SmtpInstanceID");
             if ($SMTPinstanzID != "" and @IPS_InstanceExists($SMTPinstanzID) === true) {
                 SMTP_SendMail($SMTPinstanzID, "BatterieMonitor", $Text);
             }
         }
         //EIGENE-AKTION
         if ($this->ReadPropertyBoolean("EigenesSkriptAktiv") == true) {
             $SkriptID = $this->ReadPropertyInteger("EigenesSkriptID");
             if ($SkriptID != "" and @IPS_ScriptExists($SkriptID) === true) {
                 if ($this->ReadPropertyBoolean("NamenParentObjekt1CB") == true and $this->ReadPropertyBoolean("NamenParentObjekt2CB") == false and $this->ReadPropertyBoolean("NamenParentObjekt3CB") == false) {
                     IPS_RunScriptEx($SkriptID, array("BMON_Name" => $AktorName, "BMON_ParentName1" => $AktorParent1Name, "BMON_Hersteller" => $AktorHersteller, "BMON_ID" => $AktorID, "BMON_Batterie" => $AktorBatterie, "BMON_Text" => $Text, "BMON_LetztesUpdateTS" => $AktorLetztesUpdateTS, "BMON_LetztesUpdateSEK" => $AktorLetztesUpdateSEK));
                 } elseif ($this->ReadPropertyBoolean("NamenParentObjekt1CB") == false and $this->ReadPropertyBoolean("NamenParentObjekt2CB") == true and $this->ReadPropertyBoolean("NamenParentObjekt3CB") == false) {
                     IPS_RunScriptEx($SkriptID, array("BMON_Name" => $AktorName, "BMON_ParentName2" => $AktorParent2Name, "BMON_Hersteller" => $AktorHersteller, "BMON_ID" => $AktorID, "BMON_Batterie" => $AktorBatterie, "BMON_Text" => $Text, "BMON_LetztesUpdateTS" => $AktorLetztesUpdateTS, "BMON_LetztesUpdateSEK" => $AktorLetztesUpdateSEK));
                 } elseif ($this->ReadPropertyBoolean("NamenParentObjekt1CB") == false and $this->ReadPropertyBoolean("NamenParentObjekt2CB") == false and $this->ReadPropertyBoolean("NamenParentObjekt3CB") == true) {
                     IPS_RunScriptEx($SkriptID, array("BMON_Name" => $AktorName, "BMON_ParentName3" => $AktorParent3Name, "BMON_Hersteller" => $AktorHersteller, "BMON_ID" => $AktorID, "BMON_Batterie" => $AktorBatterie, "BMON_Text" => $Text, "BMON_LetztesUpdateTS" => $AktorLetztesUpdateTS, "BMON_LetztesUpdateSEK" => $AktorLetztesUpdateSEK));
                 } elseif ($this->ReadPropertyBoolean("NamenParentObjekt1CB") == true and $this->ReadPropertyBoolean("NamenParentObjekt2CB") == true and $this->ReadPropertyBoolean("NamenParentObjekt3CB") == true) {
                     IPS_RunScriptEx($SkriptID, array("BMON_Name" => $AktorName, "BMON_ParentName1" => $AktorParent1Name, "BMON_ParentName2" => $AktorParent2Name, "BMON_ParentName3" => $AktorParent3Name, "BMON_Hersteller" => $AktorHersteller, "BMON_ID" => $AktorID, "BMON_Batterie" => $AktorBatterie, "BMON_Text" => $Text, "BMON_LetztesUpdateTS" => $AktorLetztesUpdateTS, "BMON_LetztesUpdateSEK" => $AktorLetztesUpdateSEK));
                 } elseif ($this->ReadPropertyBoolean("NamenParentObjekt1CB") == true and $this->ReadPropertyBoolean("NamenParentObjekt2CB") == true and $this->ReadPropertyBoolean("NamenParentObjekt3CB") == false) {
                     IPS_RunScriptEx($SkriptID, array("BMON_Name" => $AktorName, "BMON_ParentName1" => $AktorParent1Name, "BMON_ParentName2" => $AktorParent2Name, "BMON_Hersteller" => $AktorHersteller, "BMON_ID" => $AktorID, "BMON_Batterie" => $AktorBatterie, "BMON_Text" => $Text, "BMON_LetztesUpdateTS" => $AktorLetztesUpdateTS, "BMON_LetztesUpdateSEK" => $AktorLetztesUpdateSEK));
                 } elseif ($this->ReadPropertyBoolean("NamenParentObjekt1CB") == false and $this->ReadPropertyBoolean("NamenParentObjekt2CB") == true and $this->ReadPropertyBoolean("NamenParentObjekt3CB") == true) {
                     IPS_RunScriptEx($SkriptID, array("BMON_Name" => $AktorName, "BMON_ParentName2" => $AktorParent2Name, "BMON_ParentName3" => $AktorParent3Name, "BMON_Hersteller" => $AktorHersteller, "BMON_ID" => $AktorID, "BMON_Batterie" => $AktorBatterie, "BMON_Text" => $Text, "BMON_LetztesUpdateTS" => $AktorLetztesUpdateTS, "BMON_LetztesUpdateSEK" => $AktorLetztesUpdateSEK));
                 } elseif ($this->ReadPropertyBoolean("NamenParentObjekt1CB") == true and $this->ReadPropertyBoolean("NamenParentObjekt2CB") == false and $this->ReadPropertyBoolean("NamenParentObjekt3CB") == true) {
                     IPS_RunScriptEx($SkriptID, array("BMON_Name" => $AktorName, "BMON_ParentName1" => $AktorParent1Name, "BMON_ParentName3" => $AktorParent3Name, "BMON_Hersteller" => $AktorHersteller, "BMON_ID" => $AktorID, "BMON_Batterie" => $AktorBatterie, "BMON_Text" => $Text, "BMON_LetztesUpdateTS" => $AktorLetztesUpdateTS, "BMON_LetztesUpdateSEK" => $AktorLetztesUpdateSEK));
                 } elseif ($this->ReadPropertyBoolean("NamenParentObjekt1CB") == false and $this->ReadPropertyBoolean("NamenParentObjekt2CB") == false and $this->ReadPropertyBoolean("NamenParentObjekt3CB") == false) {
                     IPS_RunScriptEx($SkriptID, array("BMON_Name" => $AktorName, "BMON_Hersteller" => $AktorHersteller, "BMON_ID" => $AktorID, "BMON_Batterie" => $AktorBatterie, "BMON_Text" => $Text, "BMON_LetztesUpdateTS" => $AktorLetztesUpdateTS, "BMON_LetztesUpdateSEK" => $AktorLetztesUpdateSEK));
                 }
             }
         }
     }
 }
Ejemplo n.º 3
0
 public function Benachrichtigung($status, $live)
 {
     if ($status == false) {
         $this->SetTimerByIdent_InSekunden("HMON_BenachrichtigungOfflineTimer", false);
         $BenachrichtigungsText = $this->ReadPropertyString("BenachrichtigungsTextOffline");
         $Hoststatus = "offline";
         if ($live == true) {
             $this->SetValueBoolean("HostBenachrichtigungsFlag", true);
         }
     } elseif ($status == true) {
         $BenachrichtigungsText = $this->ReadPropertyString("BenachrichtigungsTextOnline");
         $Hoststatus = "online";
         if ($live == true) {
             $this->SetValueBoolean("HostBenachrichtigungsFlag", false);
         }
     }
     $Hostname = $this->ReadPropertyString("HostName");
     $Hostadresse = $this->ReadPropertyString("HostAdresse");
     $LastOnlineTimeDiffSEK = (int) (time() - GetValueInteger($this->GetIDForIdent("HostLastOnline")));
     $LastOnlineTimeDiffMIN = (int) ($LastOnlineTimeDiffSEK / 60);
     $LastOnlineTimeDiffSTD = round($LastOnlineTimeDiffMIN / 60, 2);
     $LastOnlineTimeDiffTAGE = round($LastOnlineTimeDiffSTD / 24, 2);
     //Code-Wörter austauschen gegen gewünschte Werte
     $search = array("§HOST", "§ADRESSE", "§ZEITSEK", "§ZEITMIN", "§ZEITSTD", "§ZEITTAGE");
     $replace = array($Hostname, $Hostadresse, $LastOnlineTimeDiffSEK, $LastOnlineTimeDiffMIN, $LastOnlineTimeDiffSTD, $LastOnlineTimeDiffTAGE);
     $Text = str_replace($search, $replace, $BenachrichtigungsText);
     $Text = str_replace('Â', '', $Text);
     //PUSH-NACHRICHT
     if ($this->ReadPropertyBoolean("PushMsgAktiv") == true) {
         $WFinstanzID = $this->ReadPropertyInteger("WebFrontInstanceID");
         if ($WFinstanzID != "" and @IPS_InstanceExists($WFinstanzID) === true) {
             WFC_PushNotification($WFinstanzID, "HostMonitor", $Text, "", 0);
         }
     }
     //EMAIL-NACHRICHT
     if ($this->ReadPropertyBoolean("EMailMsgAktiv") == true) {
         $SMTPinstanzID = $this->ReadPropertyInteger("SmtpInstanceID");
         if ($SMTPinstanzID != "" and @IPS_InstanceExists($SMTPinstanzID) === true) {
             SMTP_SendMail($SMTPinstanzID, "HostMonitor", $Text);
         }
     }
     //EIGENE-AKTION
     if ($this->ReadPropertyBoolean("EigenesSkriptAktiv") == true) {
         $SkriptID = $this->ReadPropertyInteger("EigenesSkriptID");
         if ($SkriptID != "" and @IPS_ScriptExists($SkriptID) === true) {
             IPS_RunScriptEx($SkriptID, array("HMON_Name" => $Hostname, "HMON_Adresse" => $Hostadresse, "HMON_Status" => $Hoststatus, "HMON_Text" => $Text, "HMON_Zeit" => $LastOnlineTimeDiffSEK));
         }
     }
 }
 /**
  * Check if a parent for Instance $id exists
  * @param $id integer InstanceID
  * @return integer
  */
 protected function GetParent($id = 0)
 {
     $parent = 0;
     if ($id == 0) {
         $id = $this->InstanceID;
     }
     if (IPS_InstanceExists($id)) {
         $instance = IPS_GetInstance($id);
         $parent = $instance['ConnectionID'];
     } else {
         $this->debug(__FUNCTION__, "Instance #{$id} doesn't exists");
     }
     return $parent;
 }