Example #1
0
 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;
     }
 }
Example #2
0
 public function updateGUI($ID = null)
 {
     $result = array();
     $S = new mFhemServerGUI();
     $S->addAssocV3("FhemServerType", "=", "0");
     while ($s = $S->getNextEntry()) {
         try {
             $x = simplexml_load_string($s->getListXML());
         } catch (NoServerConnectionException $e) {
             continue;
         }
         if (isset($x->dummy_LIST->dummy) and count($x->dummy_LIST->dummy) > 0) {
             foreach ($x->dummy_LIST->dummy as $k => $v) {
                 $F = new mFhemGUI();
                 $F->addAssocV3("FhemServerID", "=", $s->getID());
                 $F->addAssocV3("FhemName", "=", $v->attributes()->name);
                 $F = $F->getNextEntry();
                 if ($F == null) {
                     continue;
                 }
                 if ($ID and $F->getID() != $ID) {
                     continue;
                 }
                 $state = $v->attributes()->state;
                 #if($F->A("FhemModel") == "fs20irf") $state = "off";
                 #$state = strtolower(str_replace("dim", "", $state));
                 $FS = new Button("", "./fheME/Fhem/off.png", "icon");
                 $FS->style("float:left;margin-right:5px;");
                 if ($state != "off" && $state != "aus") {
                     $FS->image("./fheME/Fhem/on.png");
                 }
                 if (!is_numeric(str_replace("%", "", $state))) {
                     $state = "";
                 }
                 $return = "{$FS}<b>" . ($F->A("FhemAlias") == "" ? $F->A("FhemName") : $F->A("FhemAlias")) . "</b> <small style=\"color:grey;\">{$state}</small><div style=\"clear:both;\"></div>";
                 if ($F->A("FhemExtension") != "none" and $F->A("FhemExtension") != "") {
                     $c = $F->A("FhemExtension");
                     $c = new $c(-1);
                     $return = $c->process($F, $v);
                 }
                 $result[$F->getID()] = array("model" => $F->A("FhemModel"), "state" => $return);
             }
         }
         if (isset($x->FS20_LIST->FS20) and count($x->FS20_LIST->FS20) > 0) {
             foreach ($x->FS20_LIST->FS20 as $k => $v) {
                 $F = new mFhemGUI();
                 $F->addAssocV3("FhemServerID", "=", $s->getID());
                 $F->addAssocV3("FhemName", "=", $v->attributes()->name);
                 $F = $F->getNextEntry();
                 if ($F == null) {
                     continue;
                 }
                 if ($ID and $F->getID() != $ID) {
                     continue;
                 }
                 $state = $v->attributes()->state;
                 if ($F->A("FhemModel") == "fs20irf") {
                     $state = "off";
                 }
                 $state = strtolower(str_replace("dim", "", $state));
                 $FS = new Button("", "./fheME/Fhem/off.png", "icon");
                 $FS->style("float:left;margin-right:5px;");
                 if ($state != "off" && $state != "aus") {
                     $FS->image("./fheME/Fhem/on.png");
                 }
                 if (!is_numeric(str_replace("%", "", $state))) {
                     $state = "";
                 }
                 $result[$F->getID()] = array("model" => $F->A("FhemModel"), "state" => "{$FS}<b>" . ($F->A("FhemAlias") == "" ? $F->A("FhemName") : $F->A("FhemAlias")) . "</b> <small style=\"color:grey;\">{$state}</small><div style=\"clear:both;\"></div>");
             }
         }
         if (isset($x->IT_LIST->IT) and count($x->IT_LIST->IT) > 0) {
             foreach ($x->IT_LIST->IT as $k => $v) {
                 $F = new mFhemGUI();
                 $F->addAssocV3("FhemServerID", "=", $s->getID());
                 $F->addAssocV3("FhemName", "=", $v->attributes()->name);
                 $F = $F->getNextEntry();
                 if ($F == null) {
                     continue;
                 }
                 if ($ID and $F->getID() != $ID) {
                     continue;
                 }
                 $state = $v->attributes()->state;
                 $state = strtolower(str_replace("dim", "", $state));
                 $IT = new Button("", "./fheME/Fhem/off.png", "icon");
                 $IT->style("float:right;margin-right:-10px;margin-top:-13px;margin-left:3px;");
                 if ($state != "off" && $state != "aus") {
                     $IT->image("./fheME/Fhem/on.png");
                 }
                 $result[$F->getID()] = array("model" => $F->A("FhemITModel"), "state" => "{$IT}<b>" . ($F->A("FhemAlias") == "" ? $F->A("FhemName") : $F->A("FhemAlias")) . "</b> ");
             }
         }
         if (isset($x->CUL_HM_LIST->CUL_HM) and count($x->CUL_HM_LIST->CUL_HM) > 0) {
             foreach ($x->CUL_HM_LIST->CUL_HM as $k => $v) {
                 $F = new mFhemGUI();
                 $F->addAssocV3("FhemServerID", "=", $s->getID());
                 $F->addAssocV3("FhemName", "=", $v->attributes()->name);
                 $F = $F->getNextEntry();
                 if ($F == null) {
                     continue;
                 }
                 if ($ID and $F->getID() != $ID) {
                     continue;
                 }
                 $result[$F->getID()] = $F->getStatus($v);
             }
         }
         if (isset($x->CUL_EM_LIST->CUL_EM) and count($x->CUL_EM_LIST->CUL_EM) > 0) {
             foreach ($x->CUL_EM_LIST->CUL_EM as $em) {
                 $F = anyC::get("Fhem", "FhemServerID", $s->getID());
                 $F->addAssocV3("FhemName", "=", $em->attributes()->name);
                 $F = $F->getNextEntry();
                 if ($F == null) {
                     continue;
                 }
                 if ($ID and $F->getID() != $ID) {
                     continue;
                 }
                 foreach ($em->STATE as $state) {
                     if ($state->attributes()->key == "current") {
                         $current = $state->attributes()->value;
                     }
                 }
                 $result[$F->getID()] = array("model" => $F->A("FhemEMModel"), "state" => "<b>" . ($F->A("FhemAlias") == "" ? $F->A("FhemName") : $F->A("FhemAlias")) . "</b><small style=\"color:grey;\">" . $current . "</small>");
             }
         }
         if (isset($x->FHT_LIST->FHT) and count($x->FHT_LIST->FHT) > 0) {
             foreach ($x->FHT_LIST->FHT as $fht) {
                 $F = anyC::get("Fhem", "FhemServerID", $s->getID());
                 $F->addAssocV3("FhemName", "=", $fht->attributes()->name);
                 $F = $F->getNextEntry();
                 if ($F == null) {
                     continue;
                 }
                 if ($ID and $F->getID() != $ID) {
                     continue;
                 }
                 $measuredTemp = 0;
                 $warnings = "";
                 $actuator = "";
                 $desiredTemp = "";
                 $mode = "";
                 foreach ($fht->STATE as $state) {
                     if ($state->attributes()->key == "measured-temp") {
                         $measuredTemp = str_replace(" (Celsius)", "", $state->attributes()->value);
                     }
                     if ($state->attributes()->key == "warnings") {
                         $warnings = $state->attributes()->value;
                     }
                     if ($state->attributes()->key == "actuator") {
                         $actuator = $state->attributes()->value;
                     }
                     if ($state->attributes()->key == "desired-temp") {
                         $desiredTemp = $state->attributes()->value;
                     }
                     if ($state->attributes()->key == "mode") {
                         $mode = $state->attributes()->value;
                     }
                 }
                 $M = "";
                 if ($mode == "holiday_short") {
                     $M = new Button("", "./fheME/Fhem/modeHoliday.png", "icon");
                     $M->style("float:right;margin-top:-12px;margin-right:-9px;");
                 }
                 $B = "";
                 if ($warnings == "Temperature too low") {
                     $B = new Button("", "./fheME/Fhem/tooCold.png", "icon");
                     $B->style("float:left;margin-right:5px;");
                 }
                 if ($warnings == "Window open") {
                     $B = new Button("", "./fheME/Fhem/windowOpen.png", "icon");
                     $B->style("float:left;margin-right:5px;");
                 }
                 if ($warnings == "Battery low") {
                     $B = new Button("", "./fheME/Fhem/batteryLow.png", "icon");
                     $B->style("float:left;margin-right:5px;");
                 }
                 $Icon = new Button("", "./fheME/Fhem/fhemFHT.png", "icon");
                 $Icon->style("float:left;margin-right:5px;");
                 $result[$F->getID()] = array("model" => $F->A("FhemFHTModel"), "state" => "{$Icon}{$M}<b>" . ($F->A("FhemAlias") == "" ? $F->A("FhemName") : $F->A("FhemAlias")) . "</b><small style=\"color:grey;\"> " . Util::CLFormatNumber(str_replace(".", ".", $measuredTemp), 1) . "/" . Util::CLFormatNumber(str_replace(".", ".", $desiredTemp), 1) . "<span id=\"FhemID_" . $F->getID() . "TargetTemp\" data-value=\"desired-temp {$desiredTemp}\"></span> <small>({$actuator})</small>" . ($warnings != "none" ? "<br />{$B}{$warnings}" : "") . "<div style=\"clear:both;\"></div>");
             }
         }
     }
     echo json_encode($result, defined("JSON_UNESCAPED_UNICODE") ? JSON_UNESCAPED_UNICODE : 0);
 }