Skip to content

Commit

Permalink
Merge pull request #239 from jeedom-zigate/beta
Browse files Browse the repository at this point in the history
v1.5.2
  • Loading branch information
doudz authored Dec 18, 2019
2 parents 22efec5 + 3ce86cf commit 1d16c43
Show file tree
Hide file tree
Showing 7 changed files with 169 additions and 110 deletions.
17 changes: 12 additions & 5 deletions core/class/zigate.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -132,10 +132,11 @@ public static function syncEqLogicWithZiGate()
$ieee = $device['info']['ieee'];
$eqLogic = self::byLogicalId($ieee, 'zigate');
if (is_object($eqLogic)) {
$eqLogic->setIsEnable(0);
$eqLogic->save();
// $eqLogic->setIsEnable(0);
// $eqLogic->save();
$humanName = $eqLogic->getHumanName();
message::add('zigate', 'L\'équipement '.$humanName.' semble manquant, il a été désactivé.');
// message::add('zigate', 'L\'équipement '.$humanName.' semble manquant, il a été désactivé.');
log::add('zigate', 'info', 'L\'équipement '.$humanName.' semble manquant.');
}
}
}
Expand Down Expand Up @@ -384,7 +385,10 @@ public function createCommands($device)
public function update_command($endpoint_id, $cluster_id, $attribute)
{
$created_commands = [];
$value = $attribute['data'];
$value = '';
if (isset($attribute['data'])) {
$value = $attribute['data'];
}
if (isset($attribute['value'])) {
$value = $attribute['value'];
}
Expand Down Expand Up @@ -428,7 +432,10 @@ public function _create_command($endpoint_id, $cluster_id, $attribute)
$name = $attribute['name'];
}

$value = $attribute['data'];
$value = '';
if (isset($attribute['data'])) {
$value = $attribute['data'];
}
if (isset($attribute['value'])) {
$value = $attribute['value'];
}
Expand Down
24 changes: 21 additions & 3 deletions core/php/zigateproxy.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,18 @@
if ($_GET && $_GET['url']) {
$headers = getallheaders();
$headers_str = [];
#$url = $_GET['url'];
$url = 'http://localhost'.$_GET['url'];
$params = '';
foreach ($_GET as $key => $value) {
if ($key == 'url') {
continue;
}
$params .= $key.'='.$value.'&';
}
$params = trim($params, '&');
if ($params) {
$url = $url.'?'.$params;
}

foreach ($headers as $key => $value) {
if ($key == 'Host') {
Expand Down Expand Up @@ -68,8 +78,16 @@
$info = curl_getinfo($ch);
curl_close($ch);

header('Content-Type: '.$info[CURLINFO_CONTENT_TYPE]);
http_response_code($info[CURLINFO_RESPONSE_CODE]);
if (isset($info[CURLINFO_CONTENT_TYPE])) {
header('Content-Type: '.$info[CURLINFO_CONTENT_TYPE]);
} else {
header('Content-Type: text/html');
}
if (isset($info[CURLINFO_RESPONSE_CODE])) {
http_response_code($info[CURLINFO_RESPONSE_CODE]);
} else {
http_response_code(200);
}
header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Methods: POST, GET, OPTIONS, PUT');
echo $result;
Expand Down
Loading

0 comments on commit 1d16c43

Please sign in to comment.