Refactor SendSetting and SendReboot methods to include IP check; update module status codes and increment build number in library.json
This commit is contained in:
@@ -7,7 +7,7 @@ class AwtrixSettings extends IPSModule {
|
|||||||
|
|
||||||
|
|
||||||
public function Create() {
|
public function Create() {
|
||||||
|
$this->SetStatus(101);
|
||||||
$this->RegisterAttributeString('Settings','');
|
$this->RegisterAttributeString('Settings','');
|
||||||
$this->RegisterAttributeInteger('State',0);
|
$this->RegisterAttributeInteger('State',0);
|
||||||
|
|
||||||
@@ -284,7 +284,7 @@ class AwtrixSettings extends IPSModule {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function SendSetting() {
|
public function SendSetting() {
|
||||||
|
if (!$this->CheckIP()) {
|
||||||
// Discord webhook URL
|
// Discord webhook URL
|
||||||
$awtrixIp = $this->ReadPropertyString("AwtrixIp");
|
$awtrixIp = $this->ReadPropertyString("AwtrixIp");
|
||||||
$url="http://{$awtrixIp}/api/settings";
|
$url="http://{$awtrixIp}/api/settings";
|
||||||
@@ -412,7 +412,7 @@ class AwtrixSettings extends IPSModule {
|
|||||||
curl_close($ch);
|
curl_close($ch);
|
||||||
|
|
||||||
//$this->WriteAttributeString('Settings',$settings);
|
//$this->WriteAttributeString('Settings',$settings);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
public function UpdateConfig() {
|
public function UpdateConfig() {
|
||||||
@@ -492,6 +492,7 @@ class AwtrixSettings extends IPSModule {
|
|||||||
|
|
||||||
public function SendReboot() {
|
public function SendReboot() {
|
||||||
|
|
||||||
|
if (!$this->CheckIP()) {
|
||||||
// Discord webhook URL
|
// Discord webhook URL
|
||||||
$awtrixIp = $this->ReadPropertyString("AwtrixIp");
|
$awtrixIp = $this->ReadPropertyString("AwtrixIp");
|
||||||
$url="http://{$awtrixIp}/api/reboot";
|
$url="http://{$awtrixIp}/api/reboot";
|
||||||
@@ -519,6 +520,7 @@ class AwtrixSettings extends IPSModule {
|
|||||||
$error = curl_error($ch);
|
$error = curl_error($ch);
|
||||||
|
|
||||||
curl_close($ch);
|
curl_close($ch);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -540,11 +542,14 @@ class AwtrixSettings extends IPSModule {
|
|||||||
$http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
$http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
||||||
if ($http_code == 200) {
|
if ($http_code == 200) {
|
||||||
return true;
|
return true;
|
||||||
|
$this->SetStatus(102);
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
|
$this->SetStatus(104);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
|
$this->SetStatus(104);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -8,6 +8,6 @@
|
|||||||
"date": 1491343200
|
"date": 1491343200
|
||||||
},
|
},
|
||||||
"version": "1.2",
|
"version": "1.2",
|
||||||
"build": 1,
|
"build": 2,
|
||||||
"date": 0
|
"date": 0
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user