Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 11 additions & 8 deletions src/SmappeeLocal.php
Original file line number Diff line number Diff line change
Expand Up @@ -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, [
Expand All @@ -67,9 +66,7 @@ protected function _postCall($uri, $body)
],
'body' => $body
]);

return $result;

}

public function login()
Expand All @@ -84,7 +81,7 @@ public function login()
}

public function getInstantaneous()
{
{
$result = $this->_postCall('/gateway/apipublic/instantaneous', 'loadInstantaneous');

$data = json_decode($result->getBody(), true);
Expand Down Expand Up @@ -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) {
Expand Down