From 813366df89e8bed1efe8968e157527d9349db81a Mon Sep 17 00:00:00 2001 From: Florian Arndt Date: Sat, 28 Dec 2013 10:52:25 +0100 Subject: [PATCH] Added immediate logout after each login as proposed by Ulf Haase - now manual login is possible between script requests --- class.EnerGenieSwitcher.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/class.EnerGenieSwitcher.php b/class.EnerGenieSwitcher.php index bc2146a..7aa0037 100644 --- a/class.EnerGenieSwitcher.php +++ b/class.EnerGenieSwitcher.php @@ -19,12 +19,17 @@ class EnerGenieSwitcher { $this->postRequest('http://'.$this->ip.'/login.html', array('pw' => $this->password)); } + public function doLogout() { + $this->postRequest('http://'.$this->ip.'/login.html', array('pw' => '')); + } + /** * Get status */ public function getStatus() { $this->doLogin(); $html = $this->getRequest('http://'.$this->ip.'/energenie.html', array()); + $this->doLogout(); preg_match_all('/var sockstates \= \[([0-1],[0,1],[0,1],[0,1])\]/', $html, $matches); if(!isset($matches[1][0])) { return false; } $states = explode(',', $matches[1][0]); @@ -47,6 +52,7 @@ class EnerGenieSwitcher { } $this->postRequest('http://'.$this->ip, $params); } + $this->doLogout(); } function postRequest($url, $fields) {