1
0

some debugging and modifying hooks functions to fetch parameters

This commit is contained in:
2022-01-05 00:01:41 +01:00
parent c97f05d2b6
commit 85a7fd7ed9
7 changed files with 81 additions and 31 deletions

View File

@@ -4,7 +4,14 @@ class rdc_salon_eclairage
public $hookName = "rdc_salon_eclairage";
public $active = true;
// list of devices we are listening to
private $devicelist = array("0x00124b0022ebac5c", "0x588e81fffe2cf695", "0x00124b001f900753", "0x04cf8cdf3c78aff0");
private $devicelist = array(
RDC_SALON_MVMT => "occupancy",
RDC_SALON_MVMT2 => "occupancy",
RDC_ENTREE_PORTE => "contact",
RDC_SALON_LUMINOSITE => "illuminance_lux"
);
public $delay = 3; // amount of time in $timeunit
public $timeUnit = "minute"; // unit of time for delay, second, minute, day, week, month, year
public $luminance_min = 80;
@@ -18,9 +25,9 @@ class rdc_salon_eclairage
// assigne the function to the sensors devices
if ($this->active === true)
{
foreach ($this->devicelist as $ieeeAddress)
foreach ($this->devicelist as $ieeeAddress => $param)
{
$indexDevices[$ieeeAddress]->functions[] = array($this,"callback");
$indexDevices[$ieeeAddress]->$param["functions"][] = array($this,"callback");
}
}
}
@@ -32,13 +39,13 @@ class rdc_salon_eclairage
switch($param)
{
case "occupancy":
if ($value == 1 and $indexDevices["0x04cf8cdf3c78aff0"]->illuminance_lux <= $this->luminance_min)
if ($value == 1 and $indexDevices[RDC_SALON_LUMINOSITE]->illuminance_lux["value"] <= $this->luminance_min)
{
$this->send("ON");
}
break;
case "contact":
if ($value == false and $indexDevices["0x04cf8cdf3c78aff0"]->illuminance_lux <= $this->luminance_min)
if ($value == false and $indexDevices[RDC_SALON_LUMINOSITE]->illuminance_lux["value"] <= $this->luminance_min)
{
$this->send("ON");
}
@@ -54,7 +61,7 @@ class rdc_salon_eclairage
{
global $devices, $indexDevices;
$msg = array("state" => $state);
$device = & $indexDevices["0x588e81fffe343e8f"];
$device = & $indexDevices[RDC_SALON_ECLAIRAGE_PANNEAU];
logger(INFO, sprintf(_("publishing message: %s to %s"), $msg, $device->friendlyName));
$device->payload = $msg;
$device->set(null);

View File

@@ -23,9 +23,9 @@ class rdc_sdb_eclairage
// assigne the function to the sensors devices
if ($this->active === true)
{
foreach ($this->devicelist as $ieeeAddress)
foreach ($this->devicelist as $ieeeAddress => $param)
{
$indexDevices[$ieeeAddress]->functions[] = array($this,"callback");
$indexDevices[$ieeeAddress]->$param["functions"][] = array($this,"callback");
}
}
}