Skip to content

Commit 1d16c43

Browse files
authored
Merge pull request #239 from jeedom-zigate/beta
v1.5.2
2 parents 22efec5 + 3ce86cf commit 1d16c43

File tree

7 files changed

+169
-110
lines changed

7 files changed

+169
-110
lines changed

core/class/zigate.class.php

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -132,10 +132,11 @@ public static function syncEqLogicWithZiGate()
132132
$ieee = $device['info']['ieee'];
133133
$eqLogic = self::byLogicalId($ieee, 'zigate');
134134
if (is_object($eqLogic)) {
135-
$eqLogic->setIsEnable(0);
136-
$eqLogic->save();
135+
// $eqLogic->setIsEnable(0);
136+
// $eqLogic->save();
137137
$humanName = $eqLogic->getHumanName();
138-
message::add('zigate', 'L\'équipement '.$humanName.' semble manquant, il a été désactivé.');
138+
// message::add('zigate', 'L\'équipement '.$humanName.' semble manquant, il a été désactivé.');
139+
log::add('zigate', 'info', 'L\'équipement '.$humanName.' semble manquant.');
139140
}
140141
}
141142
}
@@ -384,7 +385,10 @@ public function createCommands($device)
384385
public function update_command($endpoint_id, $cluster_id, $attribute)
385386
{
386387
$created_commands = [];
387-
$value = $attribute['data'];
388+
$value = '';
389+
if (isset($attribute['data'])) {
390+
$value = $attribute['data'];
391+
}
388392
if (isset($attribute['value'])) {
389393
$value = $attribute['value'];
390394
}
@@ -428,7 +432,10 @@ public function _create_command($endpoint_id, $cluster_id, $attribute)
428432
$name = $attribute['name'];
429433
}
430434

431-
$value = $attribute['data'];
435+
$value = '';
436+
if (isset($attribute['data'])) {
437+
$value = $attribute['data'];
438+
}
432439
if (isset($attribute['value'])) {
433440
$value = $attribute['value'];
434441
}

core/php/zigateproxy.php

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,18 @@
2727
if ($_GET && $_GET['url']) {
2828
$headers = getallheaders();
2929
$headers_str = [];
30-
#$url = $_GET['url'];
3130
$url = 'http://localhost'.$_GET['url'];
31+
$params = '';
32+
foreach ($_GET as $key => $value) {
33+
if ($key == 'url') {
34+
continue;
35+
}
36+
$params .= $key.'='.$value.'&';
37+
}
38+
$params = trim($params, '&');
39+
if ($params) {
40+
$url = $url.'?'.$params;
41+
}
3242

3343
foreach ($headers as $key => $value) {
3444
if ($key == 'Host') {
@@ -68,8 +78,16 @@
6878
$info = curl_getinfo($ch);
6979
curl_close($ch);
7080

71-
header('Content-Type: '.$info[CURLINFO_CONTENT_TYPE]);
72-
http_response_code($info[CURLINFO_RESPONSE_CODE]);
81+
if (isset($info[CURLINFO_CONTENT_TYPE])) {
82+
header('Content-Type: '.$info[CURLINFO_CONTENT_TYPE]);
83+
} else {
84+
header('Content-Type: text/html');
85+
}
86+
if (isset($info[CURLINFO_RESPONSE_CODE])) {
87+
http_response_code($info[CURLINFO_RESPONSE_CODE]);
88+
} else {
89+
http_response_code(200);
90+
}
7391
header('Access-Control-Allow-Origin: *');
7492
header('Access-Control-Allow-Methods: POST, GET, OPTIONS, PUT');
7593
echo $result;

0 commit comments

Comments
 (0)