debugging hooks and events
This commit is contained in:
@ -11,7 +11,7 @@ class rdc_salon_eclairage extends hook
|
||||
RDC_SALON_LUMINOSITE => array("illuminance_lux", false)
|
||||
);
|
||||
|
||||
public $delay = 3; // amount of time in $timeunit
|
||||
public $delay = 5; // amount of time in $timeunit
|
||||
public $timeUnit = "minute"; // unit of time for delay, second, minute, day, week, month, year
|
||||
public $luminance_min = 60;
|
||||
public $luminance_max = 3000;
|
||||
@ -26,15 +26,15 @@ class rdc_salon_eclairage extends hook
|
||||
{
|
||||
case "occupancy":
|
||||
//print_r($indexDevices[RDC_SALON_LUMINOSITE]);
|
||||
if ($value == 1 and $indexDevices[RDC_SALON_LUMINOSITE]->illuminance_lux["value"] <= $this->luminance_min)
|
||||
if ($value == ON and $indexDevices[RDC_SALON_LUMINOSITE]->illuminance_lux["value"] <= $this->luminance_min)
|
||||
{
|
||||
$this->send("ON");
|
||||
$this->send("ON", "OFF", AUTO);
|
||||
}
|
||||
break;
|
||||
case "contact":
|
||||
if ($value == false and $indexDevices[RDC_SALON_LUMINOSITE]->illuminance_lux["value"] <= $this->luminance_min)
|
||||
{
|
||||
$this->send("ON");
|
||||
$this->send("ON", "OFF", AUTO);
|
||||
}
|
||||
break;
|
||||
case "illuminance_lux":
|
||||
@ -47,7 +47,7 @@ class rdc_salon_eclairage extends hook
|
||||
logger (INFO, sprintf(_("%s: notification received from MQTT from %s => parameter: %s value: %s"), $this->hookName, $device->friendlyName, $param, bool2string($value)));
|
||||
}
|
||||
|
||||
private function send($state)
|
||||
private function send($state, $delayState = false, $method = MANUAL)
|
||||
{
|
||||
global $devices, $indexDevices;
|
||||
$device = & $indexDevices[RDC_SALON_ECLAIRAGE_PANNEAU];
|
||||
@ -57,12 +57,14 @@ class rdc_salon_eclairage extends hook
|
||||
logger(INFO, sprintf(_("publishing message: %s to %s"), json_encode($msg), $device->friendlyName));
|
||||
$device->payload = $msg;
|
||||
$device->set();
|
||||
setDelay($device, $this->delay, $this->timeUnit, "state", "OFF", true);
|
||||
$device->method = $method;
|
||||
}else
|
||||
{
|
||||
logger(INFO, sprintf(_("not publishing message: %s to %s, already set"), json_encode($msg), $device->friendlyName));
|
||||
}
|
||||
|
||||
}
|
||||
//echo 'delaystate = ' . var_dump($delayState);
|
||||
if ($delayState !== false) setDelay($device, $this->delay, $this->timeUnit, "state", $delayState, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user