public function registerSettings() { $tab = new HTMLTable(2, "Telnet-Commands"); $tab->maxHeight(500); $this->registerType($tab, "FHZ"); $this->registerType($tab, "FS20"); $this->registerType($tab, "FHT"); $this->registerType($tab, "IT"); $this->registerType($tab, "CUL_HM"); $this->registerType($tab, "CUL_EM"); $this->registerType($tab, "dummy"); $oldServer = ""; $T = null; $ac = new anyC(); $ac->setCollectionOf("Fhem"); $ac->addJoinV3("FhemServer", "FhemServerID", "=", "FhemServerID"); $ac->addOrderV3("t1.FhemServerID"); $ac->addAssocV3("FhemType", "=", "notify"); $ac->addAssocV3("FhemServerType", "=", "0"); $oldServer = ""; while ($t = $ac->getNextEntry()) { try { if ($oldServer != $t->A("FhemServerID")) { $T = new Telnet($t->A("FhemServerIP"), $t->A("FhemServerPort")); } } catch (NoServerConnectionException $e) { die("error:'The connection to the server with IP-address " . $t->A("FhemServerIP") . " could not be established!'"); } #$tel = "define ".$t->getA()->FhemName." notify ".$t->getA()->FhemRunOn." ".str_replace("\n"," ",$t->getA()->FhemCommand); #$T->fireAndForget($tel); $tel = $t->getDefineCommand(); foreach ($tel as $c) { $T->fireAndForget($c); } $tab->addRow(array($t->A("FhemServerName"), implode("<br />", $tel))); $oldServer = $t->A("FhemServerID"); } $ac = new mFhemPresetGUI(); $ac->addJoinV3("FhemServer", "FhemPresetServerID", "=", "FhemServerID"); $ac->addJoinV3("FhemEvent", "FhemPresetID", "=", "FhemEventPresetID"); $ac->addJoinV3("Fhem", "t3.FhemEventFhemID", "=", "FhemID"); #sleep 0.5;; $ac->setFieldsV3(array("FhemEventAction", "FhemPresetRunOn", "FhemPresetName", "FhemServerIP", "FhemPresetNightOnly", "FhemServerName", "FhemServerPort", "t2.FhemServerID", "FhemName", "FhemEventFhemID")); $ac->addOrderV3("FhemPresetID"); $ac->addOrderV3("FhemEventID"); $ac->addAssocV3("FhemServerType", "=", "0"); $tab->addRow(array("", "")); $tab->addRowColspan(1, 2); $command = ""; $oldServer = ""; while ($b = $ac->getNextEntry()) { try { if ($oldServer != $b->A("FhemServerID")) { $T = new Telnet($b->A("FhemServerIP"), $b->A("FhemServerPort")); } } catch (NoServerConnectionException $e) { die("error:'The connection to the server with IP-address " . $t->A("FhemServerIP") . " could not be established!'"); } if ($b->A("FhemEventFhemID") != "-1") { $command .= "set " . $b->A("FhemName") . " " . $b->A("FhemEventAction") . ";;"; } else { $command .= $b->A("FhemEventAction") . ";;"; } $next = $ac->getNextEntry(); if ($next == null or $next->A("FhemPresetID") != $b->A("FhemPresetID")) { $runOn = null; if ($b->A("FhemPresetRunOn") != "") { $runOn = $b->A("FhemPresetRunOn"); } $d = ""; if ($runOn == null) { $d = "define " . $b->A("FhemPresetName") . " dummy"; } $c = "define n" . $b->A("FhemPresetID") . " notify " . ($runOn == null ? $b->A("FhemPresetName") : $runOn) . " {fhem(\"" . str_replace("%", "%%", $command) . "\") " . ($b->A("FhemPresetNightOnly") == "1" ? "if(!isday())" : "") . "}"; $tab->addRow(array($b->A("FhemPresetName") . "<br />" . $b->A("FhemServerName"), $d . "<br />" . $c)); if ($runOn == null) { $T->fireAndForget($d); } $T->fireAndForget($c); $command = ""; } if ($next != null) { $ac->subPointer(); } } /*$oldServer = ""; while($b = $ac->getNextEntry()){ try { if($oldServer != $b->getA()->FhemServerID) $T = new Telnet($b->getA()->FhemServerIP, $b->getA()->FhemServerPort); } catch(NoFhemServerConnectionException $e){ die("error:'The connection to the server with IP-address ".$t->getA()->FhemServerIP." could not be established!'"); } $c = "define n".$b->getA()->FhemPresetID." notify ".$b->getA()->FhemPresetName." {fhem(\"".str_replace("%","%%",$b->getA()->action)."\") ".($b->getA()->FhemPresetNightOnly == "1" ? "if(!isday())" : "")."}"; $d = "define ".$b->getA()->FhemPresetName." dummy"; $tab->addRow(array($b->getA()->FhemPresetName."<br />".$b->getA()->FhemServerName,$d."<br />".$c)); $T->fireAndForget($d); $T->fireAndForget($c); $oldServer = $b->getA()->FhemServerID; }*/ echo $tab; }