diff --git a/src/SmappeeLocal.php b/src/SmappeeLocal.php index bb3b884..2dd83e0 100644 --- a/src/SmappeeLocal.php +++ b/src/SmappeeLocal.php @@ -52,13 +52,12 @@ public function __construct($smappee_ip, $password) protected function _postCall($uri, $body) { - $client = $this->getHttpClient(); + $client = $this->getHttpClient(); $host = $this->getSmappeeHost(); if(empty($host)) { throw new \Exception("You must set the local Smappee device address to access it."); } - $url = "http://{$host}".$uri; $result = $client->request('POST', $url, [ @@ -67,9 +66,7 @@ protected function _postCall($uri, $body) ], 'body' => $body ]); - return $result; - } public function login() @@ -84,7 +81,7 @@ public function login() } public function getInstantaneous() - { + { $result = $this->_postCall('/gateway/apipublic/instantaneous', 'loadInstantaneous'); $data = json_decode($result->getBody(), true); @@ -119,12 +116,18 @@ public function listComfortPlugs() public function setComfortPlug($plug_id, $plug_status) { - $body = 'control,controlId=' . urlencode($plug_id) . '|' . (int)(bool)$plug_status; - - $result = $this->_postCall('/gateway/apipublic/commandControlPublic', $body); + if ($plug_status) { + $plug_action = 'ON'; + } else { + $plug_action = 'OFF'; + } + $body = 'control,{"controllableNodeId":"'.$plug_id.'","action":"'.$plug_action.'"}'; + $result = $this->_postCall('/gateway/apipublic/commandControlPublic', $body); $data = json_decode($result->getBody(), true); + var_dump($data); + $retval = []; foreach($data as $item) {