Add files via upload

This commit is contained in:
J.H. Artworks
2024-01-11 13:41:40 +01:00
committed by GitHub
parent 0f2a072c1f
commit c34dc87a52
4 changed files with 349 additions and 69 deletions
+5 -2
View File
@@ -1,7 +1,10 @@
{
"elements":
[
{ "type": "SelectCategory", "name": "ParseCategoryID", "caption": "Target" },
{ "type": "SelectCategory", "name": "ParseNotifyCategoryID", "caption": "Notify Target ID" },
{ "type": "SelectCategory", "name": "ParseAlarmCategoryID", "caption": "Alarm Target ID" },
{ "type": "SelectCategory", "name": "ParseAnalogCategoryID", "caption": "Analog Target ID" },
{ "type": "SelectObject", "name": "MqttCLientID", "caption": "MQTT-Client" },
{ "type": "NumberSpinner", "name": "Projectyear", "caption": "Projectyear" },
{ "type": "ValidationTextBox", "name": "Projectnumber", "caption": "Projectnumber" },
@@ -12,7 +15,7 @@
],
"actions":
[
{ "type": "Button", "label": "Force Send", "onClick": "SEMC_ForceSendTopic($id);" }
],
"status":
[
+86 -27
View File
@@ -6,7 +6,10 @@ class MonitoringClient extends IPSModule {
// Diese Zeile nicht löschen.
parent::Create();
$this->RegisterPropertyInteger("ParseCategoryID","0");
$this->RegisterPropertyInteger("ParseNotifyCategoryID","0");
$this->RegisterPropertyInteger("ParseAlarmCategoryID","0");
$this->RegisterPropertyInteger("ParseAnalogCategoryID","0");
$this->RegisterPropertyInteger("MqttCLientID","0");
$this->RegisterPropertyString("Projectnumber","");
$this->RegisterPropertyString("Projectname","");
@@ -113,44 +116,100 @@ class MonitoringClient extends IPSModule {
} // MQTT_Publish
public function SendTopic() {
// Discord webhook URL
$catId = $this->ReadPropertyInteger("ParseCategoryID");
$mqttId = $this->ReadPropertyInteger("MqttCLientID");
$projectyear = $this->ReadPropertyInteger("Projectyear");
$projectnumber = $this->ReadPropertyString("Projectnumber");
$projectname = $this->ReadPropertyString("Projectname");
$ispnumber = $this->ReadPropertyInteger("ISP");
$updatetime = $this->ReadPropertyInteger("Updatetime");
$mqttId = $this->ReadPropertyInteger("MqttCLientID");
$projectyear = $this->ReadPropertyInteger("Projectyear");
$projectnumber = $this->ReadPropertyString("Projectnumber");
$projectname = $this->ReadPropertyString("Projectname");
$ispnumber = $this->ReadPropertyInteger("ISP");
$updatetime = $this->ReadPropertyInteger("Updatetime");
$catChilds = IPS_GetChildrenIDs($catId);
$catIds[0]["id"] = $this->ReadPropertyInteger("ParseNotifyCategoryID");
$catIds[0]["top"] = "Projekte". $projectyear."/".$projectnumber. "/ISP" .$ispnumber. "/Notify/";
$catIds[1]["id"] = $this->ReadPropertyInteger("ParseAlarmCategoryID");
$catIds[1]["top"] = "Projekte". $projectyear."/".$projectnumber. "/ISP" .$ispnumber. "/Alarm/";
$catIds[2]["id"] = $this->ReadPropertyInteger("ParseAnalogCategoryID");
$catIds[2]["top"] = "Projekte". $projectyear."/".$projectnumber. "/ISP" .$ispnumber. "/Analog/";
foreach ($catChilds as $catChild) {
$childids = IPS_GetChildrenIDs($catChild);
$parname = IPS_GetName($catChild);
foreach ($catIds as $catId){
foreach ($childids as $childid){
$catChilds = IPS_GetChildrenIDs($catId["id"]);
$varInfo = IPS_GetVariable($childid);
$changedtime = $varInfo["VariableChanged"];
$varname = IPS_GetName($childid);
$topic = "Projekte". $projectyear."/".$projectnumber. "/ISP" .$ispnumber. "/". $parname."_".$varname;
$time = time();
$payload = round(getvalue($childid), 2);
if($changedtime > time() - $updatetime){
SEMC_MqttPublish($this->InstanceID,$mqttId, $topic, $payload, false);
foreach ($catChilds as $catChild) {
$childids = IPS_GetChildrenIDs($catChild);
$parname = IPS_GetName($catChild);
foreach ($childids as $childid){
$varInfo = IPS_GetVariable($childid);
$changedtime = $varInfo["VariableChanged"];
$varname = IPS_GetName($childid);
$topic = $catId["top"]. $parname."_".$varname;
$time = time();
$payload = round(getvalue($childid), 2);
if($changedtime > time() - $updatetime){
SEMC_MqttPublish($this->InstanceID,$mqttId, $topic, $payload, false);
}
}
}
}
}
}
public function ForceSendTopic() {
$mqttId = $this->ReadPropertyInteger("MqttCLientID");
$projectyear = $this->ReadPropertyInteger("Projectyear");
$projectnumber = $this->ReadPropertyString("Projectnumber");
$projectname = $this->ReadPropertyString("Projectname");
$ispnumber = $this->ReadPropertyInteger("ISP");
$updatetime = $this->ReadPropertyInteger("Updatetime");
$catIds[0]["id"] = $this->ReadPropertyInteger("ParseNotifyCategoryID");
$catIds[0]["top"] = "Projekte". $projectyear."/".$projectnumber. "/ISP" .$ispnumber. "/Notify/";
$catIds[1]["id"] = $this->ReadPropertyInteger("ParseAlarmCategoryID");
$catIds[1]["top"] = "Projekte". $projectyear."/".$projectnumber. "/ISP" .$ispnumber. "/Alarm/";
$catIds[2]["id"] = $this->ReadPropertyInteger("ParseAnalogCategoryID");
$catIds[2]["top"] = "Projekte". $projectyear."/".$projectnumber. "/ISP" .$ispnumber. "/Analog/";
foreach ($catIds as $catId){
$catChilds = IPS_GetChildrenIDs($catId["id"]);
foreach ($catChilds as $catChild) {
$childids = IPS_GetChildrenIDs($catChild);
$parname = IPS_GetName($catChild);
foreach ($childids as $childid){
$varname = IPS_GetName($childid);
$topic = $catId["top"]. $parname."_".$varname;
$payload = round(getvalue($childid), 2);
SEMC_MqttPublish($this->InstanceID,$mqttId, $topic, $payload, false);
}
}
}
$topic = "Projekte". $projectyear."/".$projectnumber. "/ISP" .$ispnumber. "/Name";
SEMC_MqttPublish($this->InstanceID,$mqttId, $topic, $projectname, false);
}
}
?>