From 6a93af0dde18ced54bdd5e078c7dcaa70b575303 Mon Sep 17 00:00:00 2001 From: Jeroen Moors Date: Thu, 8 Feb 2018 23:30:09 +0100 Subject: [PATCH 1/2] Fix wrong order of plug id and plug status. --- src/SmappeeLocal.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/SmappeeLocal.php b/src/SmappeeLocal.php index 4b4e7a2..244ef75 100644 --- a/src/SmappeeLocal.php +++ b/src/SmappeeLocal.php @@ -115,7 +115,7 @@ public function listComfortPlugs() public function setComfortPlug($plug_id=1, $plug_status=1) { - $body = 'control,controlId='.$plug_id.'|'.$plug_status; + $body = 'control,controlId='.$plug_status.'|'.$plug_id; $result = $this->_postCall('/gateway/apipublic/commandControlPublic', $body); $data = json_decode($result->getBody(), true); From 7a22f971d649acaff904b00f1c3f1beca717b626 Mon Sep 17 00:00:00 2001 From: Jeroen Moors Date: Thu, 5 Apr 2018 20:58:44 +0200 Subject: [PATCH 2/2] Change format of Smart plug command control to support firmware 4.29. --- src/SmappeeLocal.php | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/SmappeeLocal.php b/src/SmappeeLocal.php index 244ef75..8496297 100644 --- a/src/SmappeeLocal.php +++ b/src/SmappeeLocal.php @@ -61,15 +61,12 @@ private function _postCall($uri, $body) throw new \Exception("You must set the local Smappee device address and the password to access it."); } - $url = "http://{$host}".$uri; - $result = $client->request('POST', $url, [ 'headers' => [ 'Content-Type' => 'application/json' ], 'body' => $body ]); - return $result; } @@ -80,7 +77,7 @@ public function logon() } public function getInstantaneous() - { + { $result = $this->_postCall('/gateway/apipublic/instantaneous', 'loadInstantaneous'); $data = json_decode($result->getBody(), true); @@ -115,11 +112,18 @@ public function listComfortPlugs() public function setComfortPlug($plug_id=1, $plug_status=1) { - $body = 'control,controlId='.$plug_status.'|'.$plug_id; + 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) {