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; }
<head> <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1" /> <?php error_reporting(E_ERROR); include "Telnet.php"; ?> </head> <body> <?php $requestMsg = $_POST['request']; $responseMsg = 'Welcome'; try { $telnet = new Telnet('192.168.0.12', 4444); $telnet->setPrompt("\n"); if (!isset($requestMsg)) { $requestMsg = "getStatus"; } $responseMsg = $telnet->exec($requestMsg); } catch (Exception $e) { $responseMsg = 'Exception: ' . $e->getMessage(); } $responseMsg = str_replace("\r\n", '', $responseMsg); ?> <form action="" method="POST"> <?php if ($responseMsg == "stopped") { ?> <div>
public function getListXML() { $T = new Telnet($this->A("FhemServerIP"), $this->A("FhemServerPort")); $T->setPrompt("</FHZINFO>"); return $T->fireAndGet("xmllist") . "</FHZINFO>"; }