From e041f2234f31d08ef6f768980c7e5140451daa3a Mon Sep 17 00:00:00 2001 From: "J.H. Artworks" <98522442+jhartworks@users.noreply.github.com> Date: Thu, 22 Feb 2024 16:45:23 +0100 Subject: [PATCH] Add files via upload --- Multialarmer/form.json | 20 +++++ Multialarmer/module.json | 14 ++++ Multialarmer/module.php | 165 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 199 insertions(+) create mode 100644 Multialarmer/form.json create mode 100644 Multialarmer/module.json create mode 100644 Multialarmer/module.php diff --git a/Multialarmer/form.json b/Multialarmer/form.json new file mode 100644 index 0000000..a234060 --- /dev/null +++ b/Multialarmer/form.json @@ -0,0 +1,20 @@ +{ + "elements": + [ + + { "type": "SelectInstance", "name": "VisuId", "caption": "Web Visu" }, + { "type": "SelectVariable", "name": "ValueId01", "validVariableTypes": [0],"caption": "Überwachter Wert 1" }, + { "type": "SelectVariable", "name": "ValueId02", "validVariableTypes": [0],"caption": "Überwachter Wert 2" }, + { "type": "SelectVariable", "name": "ValueId03", "validVariableTypes": [0],"caption": "Überwachter Wert 3" }, + { "type": "SelectVariable", "name": "ValueId04", "validVariableTypes": [0],"caption": "Überwachter Wert 4" } + + ], + "actions": + [ + + ], + "status": + [ + + ] +} \ No newline at end of file diff --git a/Multialarmer/module.json b/Multialarmer/module.json new file mode 100644 index 0000000..08801ba --- /dev/null +++ b/Multialarmer/module.json @@ -0,0 +1,14 @@ +{ + "id": "{B702BA08-68ED-A0F6-BD98-857B4B302B63}", + "name": "Multialarmer", + "type": 3, + "vendor": "J.H. Artworks", + "aliases": + [ + ], + "url": "https://jh-artworks.com", + "parentRequirements": [], + "childRequirements": [], + "implemented": [], + "prefix": "VTMA" +} \ No newline at end of file diff --git a/Multialarmer/module.php b/Multialarmer/module.php new file mode 100644 index 0000000..bee06f7 --- /dev/null +++ b/Multialarmer/module.php @@ -0,0 +1,165 @@ +createLimitEnprofile(); + + $this->RegisterPropertyInteger("VisuId",0); + $this->RegisterPropertyInteger("ValueId01",0); + $this->RegisterPropertyInteger("ValueId02",0); + $this->RegisterPropertyInteger("ValueId03",0); + $this->RegisterPropertyInteger("ValueId04",0); + + SetValue($this->RegisterVariableBoolean("NotifyEn01", "Variable 01 Melden?","LimitEn",95),true); + $this->EnableAction("NotifyEn01"); + SetValue($this->RegisterVariableBoolean("NotifyEn02", "Variable 02 Melden?","LimitEn",115),true); + $this->EnableAction("NotifyEn02"); + SetValue($this->RegisterVariableBoolean("NotifyEn03", "Variable 03 Melden?","LimitEn",135),true); + $this->EnableAction("NotifyEn03"); + SetValue($this->RegisterVariableBoolean("NotifyEn04", "Variable 04 Melden?","LimitEn",155),true); + $this->EnableAction("NotifyEn04"); + + SetValue($this->RegisterVariableString("NotifyTitel01", "Titel der Benachrichtigung Var 01","~TextBox",100),"Störung!"); + $this->EnableAction("NotifyTitel01"); + + SetValue($this->RegisterVariableString("NotifyTitel02", "Titel der Benachrichtigung Var 02","~TextBox",120),"Störung!"); + $this->EnableAction("NotifyTitel02"); + + SetValue($this->RegisterVariableString("NotifyTitel03", "Titel der Benachrichtigung Var 03","~TextBox",140),"Störung!"); + $this->EnableAction("NotifyTitel03"); + + SetValue($this->RegisterVariableString("NotifyTitel04", "Titel der Benachrichtigung Var 04","~TextBox",160),"Störung!"); + $this->EnableAction("NotifyTitel04"); + + /* + SetValue($this->RegisterVariableString("NotifyText01", "Störungstext Var 01","~TextBox",110),"Störung 1"); + $this->EnableAction("NotifyText01"); + + SetValue($this->RegisterVariableString("NotifyText02", "Störungstext Var 02","~TextBox",130),"Störung 2"); + $this->EnableAction("NotifyText02"); + + SetValue($this->RegisterVariableString("NotifyText03", "Störungstext Var 03","~TextBox",150),"Störung 3"); + $this->EnableAction("NotifyText03"); + + SetValue($this->RegisterVariableString("NotifyText04", "Störungstext Var 04","~TextBox",170),"Störung 4"); + $this->EnableAction("NotifyText04"); + */ + + + $this->RegisterTimer("Update", 0, 'VTMA_checkValues('.$this->InstanceID.');'); + } + + // Überschreibt die intere IPS_ApplyChanges($id) Funktion + public function ApplyChanges() { + // Diese Zeile nicht löschen + parent::ApplyChanges(); + + $this->SetTimerInterval("Update", 5 * 1000); + + } + + + public function createLimitEnprofile(){ + if(!IPS_VariableProfileExists ("LimitEn") ){ + + IPS_CreateVariableProfile("LimitEn", 0); + IPS_SetVariableProfileAssociation("LimitEn", true, "Ja", "", 0x00FF00); + IPS_SetVariableProfileAssociation("LimitEn", false, "Nein", "", 0xFFFF00); + } + } + public function RequestAction($Ident, $Value) { + $varid = $this->GetIDForIdent($Ident); + SetValue($varid, $Value); + + + $this->checkValues(); + } + + + public function checkValues(){ + $webId = $this->ReadPropertyInteger("VisuId"); + + $IdVariable01 = $this->ReadPropertyInteger("ValueId01"); + + $IdVariable02 = $this->ReadPropertyInteger("ValueId02"); + + $IdVariable03 = $this->ReadPropertyInteger("ValueId03"); + + $IdVariable04 = $this->ReadPropertyInteger("ValueId04"); + + $NotifyEn01 = GetValue($this->GetIDForIdent("NotifyEn01")); + $NotifyEn02 = GetValue($this->GetIDForIdent("NotifyEn02")); + $NotifyEn03 = GetValue($this->GetIDForIdent("NotifyEn03")); + $NotifyEn04 = GetValue($this->GetIDForIdent("NotifyEn04")); + + + $NotifyTitel01 = GetValue($this->GetIDForIdent("NotifyTitel01")); + $NotifyText01 = IPS_GetName($IdVariable01);//GetValue($this->GetIDForIdent("NotifyText01")); + + $NotifyTitel02 = GetValue($this->GetIDForIdent("NotifyTitel02")); + $NotifyText02 = IPS_GetName($IdVariable02);//GetValue($this->GetIDForIdent("NotifyText02")); + + $NotifyTitel03 = GetValue($this->GetIDForIdent("NotifyTitel03")); + $NotifyText03 = IPS_GetName($IdVariable03);//GetValue($this->GetIDForIdent("NotifyText03")); + + $NotifyTitel04 = GetValue($this->GetIDForIdent("NotifyTitel04")); + $NotifyText04 = IPS_GetName($IdVariable04);//GetValue($this->GetIDForIdent("NotifyText04")); + + + if($NotifyEn01 == true && $IdVariable01 > 0){ + $value01 = GetValue($IdVariable01); + + $this->notify($IdVariable01, $webId, $IdVariable01, $NotifyTitel01, $NotifyText01, "Flame"); + + } + + if($NotifyEn02 == true && $IdVariable02 > 0){ + $value02 = GetValue($IdVariable02); + + $this->notify($IdVariable02, $webId, $IdVariable02, $NotifyTitel02, $NotifyText02, "Flame"); + + } + + if($NotifyEn03 == true && $IdVariable03 > 0){ + $value03 = GetValue($IdVariable03); + + $this->notify($IdVariable03, $webId, $IdVariable03, $NotifyTitel03, $NotifyText03, "Flame"); + + } + + if($NotifyEn04 == true && $IdVariable04 > 0){ + $value04 = GetValue($IdVariable04); + + $this->notify($IdVariable04, $webId, $IdVariable04, $NotifyTitel04, $NotifyText04, "Flame"); + + } + + + } + private function notify($trigid, $webfrontid, $targetid, $art, $smname, $ico){ + + if (GetValueBoolean($trigid) == true && ($this->GetBuffer($smname) == "true")) { + + $this->SetBuffer($smname, "false"); + + VISU_PostNotification($webfrontid, $art, $smname, $ico, $targetid); + + } + elseif (GetValueBoolean($trigid) == false) { + $this->SetBuffer($smname, "true"); + } + + if (GetValueBoolean($trigid) == true){ + return true; + }else{ + return false; + } + } + +} + +?> \ No newline at end of file