modified init and some debugging
This commit is contained in:
50
hooks/scripts/rdc_wc_eclairage.php
Normal file
50
hooks/scripts/rdc_wc_eclairage.php
Normal file
@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
class rdc_wc_eclairage
|
||||
{
|
||||
public $hookName = "rdc_wc_eclairage";
|
||||
public $active = true;
|
||||
|
||||
private $devicelist = array(RDC_SDB_WC_ECLAIRAGE => "state_l2");
|
||||
|
||||
public $delay = 3; // amount of time in $timeunit
|
||||
public $delayManual = 10; // amount of time in $timeunit for manual mode
|
||||
public $timeUnit = "minute"; // unit of time for delay, second, minute, day, week, month, year
|
||||
|
||||
function __construct()
|
||||
{
|
||||
global $indexDevices;
|
||||
|
||||
// assigne the function to the sensors devices
|
||||
if ($this->active === true)
|
||||
{
|
||||
foreach ($this->devicelist as $ieeeAddress => $property)
|
||||
{
|
||||
$indexDevices[$ieeeAddress]->$property["functions"][] = array($this,"callback");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// callback fonction. Is called with these 4 parameters
|
||||
public function callBack(&$device, $property, $value)
|
||||
{
|
||||
global $devices, $indexDevices;
|
||||
switch($property)
|
||||
{
|
||||
case "state_l2":
|
||||
if ($value == ON)
|
||||
{
|
||||
setDelay($device, $this->delayManual, $this->timeUnit, "state_l2", "OFF", true);
|
||||
$device->method = MANUAL;
|
||||
}elseif ($value = OFF)
|
||||
{
|
||||
deleteEvent(searchEvent($device, "state_l2", "OFF"));
|
||||
}
|
||||
break;
|
||||
}
|
||||
logger (INFO, _("%s: notification received from MQTT from %s => parameter: %s value: %s"), $this->hookName, $device->friendlyName, $property, $value);
|
||||
}
|
||||
}
|
||||
|
||||
$hooks["rdc_wc_eclairage"] = new rdc_wc_eclairage();
|
||||
?>
|
Reference in New Issue
Block a user