diff --git a/Monitoring Server Influx V1/module.php b/Monitoring Server Influx V1/module.php index 9c9512c..03d2462 100644 --- a/Monitoring Server Influx V1/module.php +++ b/Monitoring Server Influx V1/module.php @@ -32,13 +32,19 @@ class MonitoringServer extends IPSModule { $this->RegisterTimer("UpdateAlarms", 0, 'SEMS_checkAlarms('.$this->InstanceID.');'); - $this->RegisterTimer("UpdateValues", 0, 'SEMS_checkValues('.$this->InstanceID.');'); + $this->RegisterTimer("UpdateValues", 0, 'SEMS_checkValues('.$this->InstanceID.',false);'); + $this->RegisterTimer("ForceUpdateValues", 0, 'SEMS_checkValues('.$this->InstanceID.',true);'); $this->RegisterVariableInteger("AlarmVarCount", "Number of Alarmvalues", "", 0); $this->RegisterVariableInteger("AlarmActiveCount", "Number of Values in Alarmstate", "", 1); $this->RegisterVariableInteger("AnalogVarCount", "Number of Analogvalues", "", 2); $this->RegisterVariableInteger("DigitalVarCount", "Number of DigitalValues", "", 3); + $this->RegisterVariableString("Alarmtable", "Alarmhistorie", "~HTMLBox", 30); + $this->RegisterAttributeString("AtAlarmtable", ""); + + + } @@ -49,6 +55,8 @@ class MonitoringServer extends IPSModule { $this->SetTimerInterval("UpdateAlarms", $this->ReadPropertyInteger("UpdateintervallAlarms") * 1000); $this->SetTimerInterval("UpdateValues", $this->ReadPropertyInteger("UpdateintervallValues") * 1000); + $this->SetTimerInterval("ForceUpdateValues", $this->ReadPropertyInteger("UpdateintervallForceValues") * 1000 * 60); + $this->clearNames(); // Diese Zeile nicht löschen @@ -169,7 +177,7 @@ class MonitoringServer extends IPSModule { } - public function checkValues() { + public function checkValues($force) { $catNotifyId = $this->ReadPropertyInteger("ParseNotifyCategoryID"); $catAnalogId = $this->ReadPropertyInteger("ParseAnalogCategoryID"); @@ -180,7 +188,6 @@ class MonitoringServer extends IPSModule { $ispnumber = $this->ReadPropertyInteger("ISP"); $logit = $this->ReadPropertyBoolean("LogValues"); - $logit = $this->ReadPropertyBoolean("LogValues"); $numberofvalues = 0; @@ -215,7 +222,7 @@ class MonitoringServer extends IPSModule { $numberofvalues++; - if($changedtime > $time - $updatetime){ + if(($changedtime > $time - $updatetime) | $force){ $parname = str_replace(" ","", $parname); $varname = str_replace(" ","", $varname); @@ -241,11 +248,13 @@ class MonitoringServer extends IPSModule { $valuename = $parname."".$varname; //IPS_LogMessage ("Analog Var-Logger", "Ready: ".$system."/".$category."/".$valuename." with Value: ".$payload); + if ($logit == true){ + if($this->checkInfluxState() > -1){ + $this->Write2Influx($payload, $ssl, $server, $port, $db, $system, $category, $valuename); + IPS_LogMessage ("Analog Var-Logger", "LOGGED: ".$system."/".$category."/".$valuename." with Value: ".$payload); + } + } - if($this->checkInfluxState() > -1){ - $this->Write2Influx($payload, $ssl, $server, $port, $db, $system, $category, $valuename); - IPS_LogMessage ("Analog Var-Logger", "LOGGED: ".$system."/".$category."/".$valuename." with Value: ".$payload); - } } @@ -287,10 +296,11 @@ class MonitoringServer extends IPSModule { $category = $system."_Digital"; $valuename = $parname."_".$varname; + if ($logit == true){ if($this->checkInfluxState() > -1){ $this->Write2Influx($payload, $ssl, $server, $port, $db, $system, $category, $valuename); } - + } } @@ -301,16 +311,15 @@ class MonitoringServer extends IPSModule { } SetValueInteger($this->GetIDForIdent("DigitalVarCount"),$numberofvalues); - - - - - } private function notify($trigid, $webfrontid, $targetid, $projectnumber, $projectname, $ispnr){ + $tdOld = $this->ReadAttributeString("AtAlarmtable"); + $td = $tdOld; + + $time = date("Y-m-d H:i:s"); $art = $projectnumber." | ".$projectname. " | ISP ".$ispnr; $ico = "Flame"; @@ -322,19 +331,49 @@ class MonitoringServer extends IPSModule { $this->SetBuffer($smname, "false"); VISU_PostNotification($webfrontid, $art, $smname, $ico, $targetid); - WFC_PushNotification($webfrontid, $art, $smname, "", $targetid); + + $td = ''.$smname.''.$time.''.$tdOld; + $this->WriteAttributeString("AtAlarmtable", $td); + IPS_LogMessage ("Notify", "Alarmhistory updated"); } elseif (GetValue($trigid) == false) { $this->SetBuffer($smname, "true"); + } + $style = ' + + + + '; + $table = $style.''.$td.'
NameZeit / Datum
'; + SetValueString($this->GetIDForIdent("Alarmtable"), $table); + IPS_LogMessage ("Notify", "Alarmhistory writen"); if (GetValue($trigid) == true){ return true; }else{ return false; } + + + } private function getTextAfterLastSlash($inputString) { diff --git a/library.json b/library.json index cf0a5f2..7ed8e60 100644 --- a/library.json +++ b/library.json @@ -8,6 +8,6 @@ "date": 1491343200 }, "version": "1.9", - "build": 0, + "build": 1, "date": 0 } \ No newline at end of file