public function getHTML($id) { $bps = $this->getMyBPSData(); $t = new HTMLTable(1); $t->setTableStyle("width:160px;float:right;margin-right:10px;"); if (!isset($bps["ID"])) { $F = new mFhemGUI(); $F->addAssocV3("FhemType", "!=", "FHZ"); while ($f = $F->getNextEntry()) { $B = new Button($f->getA()->FhemName, "./fheME/Fhem/fhem.png"); $B->onclick("contentManager.loadFrame('contentRight','mFhemTimer',-1,0,'mFhemTimerGUI;ID:" . $f->getID() . ";type:D;name:" . $f->getA()->FhemName . "');"); $t->addRow($B); $t->addRowClass("backgroundColor0"); } $t->addRow(""); $t->addRowClass("backgroundColor1"); $F = new anyC(); $F->setCollectionOf("FhemPreset"); $F->addAssocV3("FhemPresetHide", "=", "0"); while ($f = $F->getNextEntry()) { $B = new Button($f->getA()->FhemPresetName, "./fheME/Fhem/events.png"); $B->onclick("contentManager.loadFrame('contentRight','mFhemTimer',-1,0,'mFhemTimerGUI;ID:" . $f->getID() . ";type:P;name:" . $f->getA()->FhemPresetName . "');"); $t->addRow($B); $t->addRowClass("backgroundColor0"); } return $t; } if (isset($bps["ID"])) { if ($bps["type"] == "D") { $F = new Fhem($bps["ID"]); $F->loadMe(); $FF = new Fhem("timer"); $FF->setA($F->getA()); $C = new FhemControlGUI(); $control = $C->getControl($FF); } else { $control = ""; } $rand = rand(10, 10000000); $B = new Button("set timer", "okCatch"); $B->rme("FhemControl", '', 'setTimer', array($bps["ID"], "'setBPSValue'", "'{$bps['type']}'", "parent.clock4Timer{$rand}.stunden", "parent.clock4Timer{$rand}.minuten", "'{$bps['name']}'"), "contentManager.loadFrame(\\'contentRight\\',\\'mFhem\\',-1,0,\\'\\');"); $B->style("float:right;"); $t->addRow("<iframe name=\"clock4Timer{$rand}\" style=\"width:240px;height:330px;border:0px;\" src=\"./libraries/ClockGUI.class.php\"></iframe>"); $t->addRowClass("backgroundColor0"); $t->addRow($B); $t->addRowClass("backgroundColor0"); return $control . $t; } }
public static function ActionParser($w, $l, $p) { $s = HTMLGUI::getArrayFromParametersString($p); if ($s[2] == "-1") { $I = new HTMLInput("FhemEventAction", "multiInput", $w, array("FhemEvent", $s[0], "FhemEventAction")); $I->style("width:95%;text-align:left;"); return $I; } $Fhem = new Fhem($s[1]); $Fhem->loadMe(); $op = $Fhem->getAvailableOptions(); $o = "<option value=\"\">select...</option>"; foreach ($op as $k => $v) { $o .= "<option " . ($w == $v ? "selected=\"selected\"" : "") . " value=\"{$v}\">{$k}</option>"; } return "<select onchange=\"rme('FhemEvent', '{$s['0']}', 'saveMultiEditField', Array('FhemEventAction',this.value), 'checkResponse(transport);');\">{$o}</select>"; }
function addDevice($id) { $Fhem = new Fhem($id); $Fhem->loadMe(); /*$test1 = new anyC(); $test1->setCollectionOf("FhemEvent"); $test1->addJoinV3("Fhem","FhemEventFhemID","=","FhemID"); $test1->addAssocV3("FhemEventPresetID","=",$this->ID); $test1->addAssocV3("FhemServerID","!=",$Fhem->getA()->FhemServerID); if($test1->getNextEntry() != null) die("error:'You may only use devices connected to the same server!'");*/ /*$test2 = new anyC(); $test2->setCollectionOf("FhemEvent"); $test2->addAssocV3("FhemEventPresetID","=",$this->ID); $test2->addAssocV3("FhemEventFhemID","=",$id); if($test2->getNextEntry() != null) die("error:'Device already added!'");*/ $FE = new FhemEvent(-1); $FEA = $FE->newAttributes(); $FEA->FhemEventFhemID = $id; $FEA->FhemEventPresetID = $this->ID; $FE->setA($FEA); $FE->newMe(true, true); }
public function setTimer($id, $action, $type, $stunden, $minuten, $deviceName) { if ($action == "setBPSValue") { $action = $_SESSION["BPS"]->getProperty("mFhemTimer", "FhemValue"); } switch ($type) { case "D": $F = new Fhem($id); $F->loadMe(); $S = new FhemServer($F->getA()->FhemServerID); $S->loadMe(); break; case "P": $ac = new anyC(); $ac->setCollectionOf("FhemPreset"); $ac->addJoinV3("FhemServer", "FhemPresetServerID", "=", "FhemServerID"); $ac->addAssocV3("FhemPresetID", "=", $id); $ac->setLimitV3("1"); $S = $ac->getNextEntry(); $action = "on"; break; } try { $T = new Telnet($S->getA()->FhemServerIP, $S->getA()->FhemServerPort); } catch (NoServerConnectionException $e) { die("error:'The connection to the server with IP-address " . $S->getA()->FhemServerIP . " could not be established!'"); } $T->fireAndForget("define a" . rand(10, 10000000) . " at " . ($stunden < 10 ? "0" : "") . "{$stunden}:" . ($minuten < 10 ? "0" : "") . "{$minuten}:00 set " . $deviceName . " {$action}"); $T->disconnect(); }