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; } }
public function setDevice($id, $action) { if ($id == "timer") { $_SESSION["BPS"]->setProperty("mFhemTimer", "FhemValue", $action); return; } $F = new Fhem($id); $S = new FhemServer($F->A("FhemServerID")); 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->getA()->FhemServerIP . " could not be established!'"); } $T->fireAndForget("set " . $F->A("FhemName") . " {$action}"); $T->disconnect(); break; case "1": $S->setDevice($F->getID(), $action); #$url = $S->A("FhemServerURL")."?device=".$F->A("FhemName")."&value=".$action; #echo "opening URL $url..."; #fopen($url, "r"); break; } }