mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
Apply fixes from StyleCI (#12117)
* Apply fixes from StyleCI * Disable style check
This commit is contained in:
@@ -21,10 +21,11 @@
|
||||
* @package LibreNMS
|
||||
* @subpackage Alerts
|
||||
*/
|
||||
|
||||
namespace LibreNMS\Alert\Transport;
|
||||
|
||||
use LibreNMS\Enum\AlertState;
|
||||
use LibreNMS\Alert\Transport;
|
||||
use LibreNMS\Enum\AlertState;
|
||||
|
||||
/**
|
||||
* The Hue API currently is fairly limited for alerts.
|
||||
@@ -35,7 +36,7 @@ class Hue extends Transport
|
||||
{
|
||||
public function deliverAlert($obj, $opts)
|
||||
{
|
||||
if (!empty($this->config)) {
|
||||
if (! empty($this->config)) {
|
||||
$opts['user'] = $this->config['hue-user'];
|
||||
$opts['bridge'] = $this->config['hue-host'];
|
||||
$opts['duration'] = $this->config['hue-duration'];
|
||||
@@ -51,16 +52,16 @@ class Hue extends Transport
|
||||
return true;
|
||||
} else {
|
||||
$device = device_by_id_cache($obj['device_id']); // for event logging
|
||||
$hue_user = $opts['user'];
|
||||
$url = $opts['bridge'] . "/api/$hue_user/groups/0/action";
|
||||
$curl = curl_init();
|
||||
$duration = $opts['duration'];
|
||||
$data = array("alert" => $duration);
|
||||
$hue_user = $opts['user'];
|
||||
$url = $opts['bridge'] . "/api/$hue_user/groups/0/action";
|
||||
$curl = curl_init();
|
||||
$duration = $opts['duration'];
|
||||
$data = ["alert" => $duration];
|
||||
$datastring = json_encode($data);
|
||||
|
||||
set_curl_proxy($curl);
|
||||
|
||||
$headers = array('Accept: application/json', 'Content-Type: application/json');
|
||||
$headers = ['Accept: application/json', 'Content-Type: application/json'];
|
||||
|
||||
curl_setopt($curl, CURLOPT_URL, $url);
|
||||
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
|
||||
@@ -69,13 +70,15 @@ class Hue extends Transport
|
||||
curl_setopt($curl, CURLOPT_VERBOSE, 1);
|
||||
curl_setopt($curl, CURLOPT_POSTFIELDS, $datastring);
|
||||
|
||||
$ret = curl_exec($curl);
|
||||
$ret = curl_exec($curl);
|
||||
$code = curl_getinfo($curl, CURLINFO_HTTP_CODE);
|
||||
if ($code == 200) {
|
||||
d_echo("Sent alert to Phillips Hue Bridge " . $opts['host'] . " for " . $device);
|
||||
|
||||
return true;
|
||||
} else {
|
||||
d_echo("Hue bridge connection error: " . serialize($ret));
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -86,33 +89,33 @@ class Hue extends Transport
|
||||
return [
|
||||
'config'=>[
|
||||
[
|
||||
'title'=> 'Host',
|
||||
'name' => 'hue-host',
|
||||
'descr' => 'Hue Host',
|
||||
'type' => 'text',
|
||||
'title'=> 'Host',
|
||||
'name' => 'hue-host',
|
||||
'descr' => 'Hue Host',
|
||||
'type' => 'text',
|
||||
],
|
||||
[
|
||||
'title'=> 'Hue User',
|
||||
'name' => 'hue-user',
|
||||
'descr' => 'Phillips Hue Host',
|
||||
'type' => 'text',
|
||||
'title'=> 'Hue User',
|
||||
'name' => 'hue-user',
|
||||
'descr' => 'Phillips Hue Host',
|
||||
'type' => 'text',
|
||||
],
|
||||
[
|
||||
'title'=> 'Duration',
|
||||
'name' => 'hue-duration',
|
||||
'descr' => 'Phillips Hue Duration',
|
||||
'type' => 'select',
|
||||
'options' => [
|
||||
'1 Second' => 'select',
|
||||
'15 Seconds' => 'lselect'
|
||||
]
|
||||
]
|
||||
'title'=> 'Duration',
|
||||
'name' => 'hue-duration',
|
||||
'descr' => 'Phillips Hue Duration',
|
||||
'type' => 'select',
|
||||
'options' => [
|
||||
'1 Second' => 'select',
|
||||
'15 Seconds' => 'lselect',
|
||||
],
|
||||
],
|
||||
],
|
||||
'validation' => [
|
||||
'hue-host' => 'required|string',
|
||||
'hue-user' => 'required|string',
|
||||
'hue-duration' => 'required|string'
|
||||
]
|
||||
'hue-duration' => 'required|string',
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user