Added immediate logout after each login as proposed by Ulf Haase - now manual login is possible between script requests
This commit is contained in:
parent
253c30e0a9
commit
813366df89
@ -19,12 +19,17 @@ class EnerGenieSwitcher {
|
|||||||
$this->postRequest('http://'.$this->ip.'/login.html', array('pw' => $this->password));
|
$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
|
* Get status
|
||||||
*/
|
*/
|
||||||
public function getStatus() {
|
public function getStatus() {
|
||||||
$this->doLogin();
|
$this->doLogin();
|
||||||
$html = $this->getRequest('http://'.$this->ip.'/energenie.html', array());
|
$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);
|
preg_match_all('/var sockstates \= \[([0-1],[0,1],[0,1],[0,1])\]/', $html, $matches);
|
||||||
if(!isset($matches[1][0])) { return false; }
|
if(!isset($matches[1][0])) { return false; }
|
||||||
$states = explode(',', $matches[1][0]);
|
$states = explode(',', $matches[1][0]);
|
||||||
@ -47,6 +52,7 @@ class EnerGenieSwitcher {
|
|||||||
}
|
}
|
||||||
$this->postRequest('http://'.$this->ip, $params);
|
$this->postRequest('http://'.$this->ip, $params);
|
||||||
}
|
}
|
||||||
|
$this->doLogout();
|
||||||
}
|
}
|
||||||
|
|
||||||
function postRequest($url, $fields) {
|
function postRequest($url, $fields) {
|
||||||
|
Loading…
Reference in New Issue
Block a user