1
0

some debbuging

This commit is contained in:
2022-01-02 18:14:13 +01:00
parent 2e6b2fe5cb
commit d79463fbd4
11 changed files with 147 additions and 242 deletions

View File

@ -3,12 +3,12 @@ class notificationFreemobile
{
private $url = "https://smsapi.free-mobile.fr/sendmsg?user=32886706&pass=JTGUY6l5OG73zX&msg=";
private $name = "freemobile";
public $active = true;
public $level;
function __construct()
{
global $notificationMethods;
$notificationMethods[$name]->active = true;
$notificationMethods[$name]->level = ALL;
$this->level = WARNING | ERROR;
}
function send($message)
@ -23,7 +23,13 @@ class notificationFreemobile
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
// $output contains the output string
logger(INFO, curl_exec($ch));
if (($result = curl_exec($ch)) === false)
{
logger(ERROR, _(sprintf( "Curl return error: %s when sending notification", curl_error($ch))));
}else
{
logger(INFO, _("Curl return: ") . $result . _(" when sending notification"));
}
// close curl resource to free up system resources
curl_close($ch);
@ -33,6 +39,6 @@ class notificationFreemobile
}
}
$notificationMethods["freemobile"] = new notificationMethod();
$notificationMethods["freemobile"] = new notificationFreemobile();
?>

View File

@ -4,7 +4,7 @@ class rdc_panneau_salon
// list of devices we are listening to
private $devicelist = array("0x00124b0022ebac5c", "0x588e81fffe2cf695", "0x00124b001f900753", "0x04cf8cdf3c78aff0");
public $delay = 3; // amount of time in $timeunit
public $timeUnit = "minute"; // unit of time for delay, second, minute, day, week, month, year
public $timeUnit = "minute"; // unit of time for delay, second, minute, day, week, month, year
public $luminance_min = 80;
public $luminance_max = 3000;
@ -21,36 +21,39 @@ class rdc_panneau_salon
}
// callback fonction. Is called with these 4 parameters
public function callBack($topic, $fn, $param, $value)
public function callBack(&$device, $param, $value)
{
global $devices, $indexDevices;
switch($param)
{
case "occupancy":
if ($value == 1) $this->send();
if ($value == 1 and $indexDevices["0x04cf8cdf3c78aff0"]->illuminance_lux <= $this->luminance_min)
{
$this->send("ON");
}
break;
case "contact":
if ($value == false) $this->send();
if ($value == false and $indexDevices["0x04cf8cdf3c78aff0"]->illuminance_lux <= $this->luminance_min)
{
$this->send("ON");
}
break;
case "illuminance_lux":
if ($value >= $this->luminance_max) $this->send();
if ($value >= $this->luminance_max) $this->send("OFF");
}
echo _("notification received from MQTT") . EOL;
//echo $param . "=> " . $value . EOL;
}
private function send()
private function send($state)
{
global $devices, $indexDevices;
if ($indexDevices["0x04cf8cdf3c78aff0"]->illuminance_lux <= $this->luminance_min)
{
$msg = array("state" => "ON");
$device = & $indexDevices["0x588e81fffe343e8f"];
logger(INFO, __("publishing ") . $msg . __(" message: ") . $device->friendlyName);
$device->payload = $msg;
$device->set(null);
setDelay($device, $this->delay, $this->timeUnit, "state", "OFF", true);
}
$msg = array("state" => $state);
$device = & $indexDevices["0x588e81fffe343e8f"];
logger(INFO, _("publishing ") . $msg . _(" message: ") . $device->friendlyName);
$device->payload = $msg;
$device->set(null);
setDelay($device, $this->delay, $this->timeUnit, "state", "OFF", true);
}
}