Example #1
0
 public function activate()
 {
     /*$ac = new anyC();
     		$ac->setCollectionOf("FhemPreset");
     		$ac->addJoinV3("FhemServer","FhemPresetServerID","=","FhemServerID");
     		$ac->addAssocV3("FhemPresetID", "=", $PresetID);
     		$S = $ac->getNextEntry();*/
     $S = new FhemServer($this->A("FhemPresetServerID"));
     switch ($S->A("FhemServerType")) {
         case "0":
             try {
                 $T = new Telnet($S->A("FhemServerIP"), $S->A("FhemServerPort"));
             } catch (NoServerConnectionException $e) {
                 die("error:'The connection to the server with IP-address " . $S->A("FhemServerIP") . " could not be established!'");
             }
             $c = "set " . $this->A("FhemPresetName") . " on";
             $T->fireAndForget($c);
             $T->disconnect();
             break;
         case "1":
             $ac = new anyC();
             $ac->setCollectionOf("FhemEvent");
             $ac->addAssocV3("FhemEventPresetID", "=", $this->ID);
             $ac->lCV3();
             while ($E = $ac->getNextEntry()) {
                 $S->setDevice($E->A("FhemEventFhemID"), $E->A("FhemEventAction"));
             }
             break;
     }
 }
Example #2
0
 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();
 }
Example #3
0
     if ($DEBUG) {
         print "<br>telnet connect: " . $result . "<br>";
     }
     //lueften_ja berechnen und setzen
     if ($result) {
         $telnet->exec('setreading ' . $thName . ' T ' . $t10 . "\r\n", $result);
         // NOTE: $result may contain newlines
         if ($DEBUG) {
             print $result;
         }
         $telnet->exec('setreading ' . $thName . ' H ' . $h . "\r\n", $result);
         if ($DEBUG) {
             print '<br>setreading: ' . $result . '<br';
         }
         // say Disconnect(0); to break the connection without explicitly logging out
         $telnet->disconnect();
     } else {
         if ($DEBUG) {
             print "<br>telnet connect failed: " . $result . '<br>';
         }
     }
     //END send data via telnet
 }
 //end if useTelnet
 //SEND DATA using cUrl
 // http://192.168.0.40:8083/fhem?cmd=setreading%20testdummy%20Temperture%2013&XHR=1
 if ($useCurl) {
     if ($DEBUG) {
         print "<br>using CURL<br>";
     }
     // Get cURL resource