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 getData() { $S = new FhemServer($this->A("FhemServerID")); try { if (!isset(self::$connections[$S->A("FhemServerIP")])) { self::$connections[$S->getID()] = new Telnet($S->A("FhemServerIP"), $S->A("FhemServerPort")); } $T = self::$connections[$S->getID()]; } catch (NoServerConnectionException $e) { die("error:'The connection to the server with IP-address " . $S->A("FhemServerIP") . " could not be established!'"); } $T->setPrompt("</FHZINFO>"); $answer = $T->fireAndGet("xmllist") . "</FHZINFO>"; $simpleXML = new SimpleXMLElement($answer); $S = array(); $I = array(); if ($this->A("FhemType") == "FHT") { $target = $simpleXML->FHT_LIST->FHT; } if ($this->A("FhemType") == "FS20") { $target = $simpleXML->FS20_LIST->FS20; } if ($this->A("FhemType") == "IT") { $target = $simpleXML->IT_LIST->IT; } if ($this->A("FhemType") == "CUL_HM") { $target = $simpleXML->CUL_HM_LIST->CUL_HM; } if ($this->A("FhemType") == "CUL_EM") { $target = $simpleXML->CUL_EM_LIST->CUL_EM; } if ($this->A("FhemType") == "notify") { $target = $simpleXML->notify_LIST->notify; } if ($this->A("FhemType") == "dummy") { $target = $simpleXML->dummy_LIST->dummy; } if (isset($target)) { foreach ($target as $fht) { if ($fht->attributes()->name != $this->A("FhemName")) { continue; } foreach ($fht->STATE as $state) { $S[] = array(0 => $state->attributes()->key, 1 => $state->attributes()->value, 2 => $state->attributes()->measured, "key" => $state->attributes()->key, "value" => $state->attributes()->value, "date" => $state->attributes()->measured); } #$TabS->addRow(array($state->attributes()->key, $state->attributes()->value, "<small>".$state->attributes()->measured."</small>")); foreach ($fht->INT as $int) { $I[] = array(0 => $int->attributes()->key, 1 => $int->attributes()->value, "key" => $int->attributes()->key, "value" => $int->attributes()->value); } #$TabI->addRow(array($int->attributes()->key, $int->attributes()->value, "")); } } return array($S, $I); #$T->disconnect(); }
private function getDeviceStatus($FhemID) { $F = new Fhem($FhemID); $S = new FhemServer($F->A("FhemServerID")); try { $T = new Telnet($S->A("FhemServerIP"), $S->A("FhemServerPort")); $T->setPrompt("</FHZINFO>"); $answer = $T->fireAndGet("xmllist") . "</FHZINFO>"; } catch (Exception $e) { return null; } $x = simplexml_load_string($answer); if (isset($x->FS20_LIST->FS20) and count($x->FS20_LIST->FS20) > 0) { foreach ($x->FS20_LIST->FS20 as $k => $v) { if ($v->attributes()->name != $F->A("FhemName")) { continue; } return $v->attributes()->state; } } return null; }