diff --git a/events.php b/events.php index 45c9e17..e64159f 100644 --- a/events.php +++ b/events.php @@ -25,7 +25,7 @@ function checkEvents() if($event->dateTimeEvent < $now) { logger(DEBUG, _("Event must be executed"), __FILE__ . ":" . __LINE__); - + if (!empty($event->exceptionInterval) and $event->isInterval == true) { logger(DEBUG, _("Testing exceptions"), __FILE__ . ":" . __LINE__); @@ -40,7 +40,7 @@ function checkEvents() } } } - + if ($exception === false) { if (is_callable($event->function)) @@ -80,7 +80,7 @@ function checkEvents() // datetime format : "yyyy-mm-dd hh:mm:ss" -function setOneshotEvent(device &$deviceObject, string $datetime, $property, $value, $replace=false, $method=null) +function setOneshotEvent(device &$deviceObject, string $datetime, $property, $value, $function=null, $replace=false, $method=null) { global $events; $events[] = new event; @@ -91,6 +91,7 @@ function setOneshotEvent(device &$deviceObject, string $datetime, $property, $va $events[$key]->param = $property; $events[$key]->value = $value; $events[$key]->device = & $deviceObject; + $events[$key]->function = $function; if ($method !==null) $events[$key]->method =$method; } @@ -100,7 +101,7 @@ function setRecurrentEvent($function, $ieeeAddress, string $property, $value, bo { global $events, $indexDevices; logger(INFO, _("Setting recurrent event"), __FILE__ . ":" . __LINE__); - + $string = "P"; if (!empty($years)) $string .= $years . "Y"; if (!empty($months)) $string .= $months . "M"; @@ -111,8 +112,8 @@ function setRecurrentEvent($function, $ieeeAddress, string $property, $value, bo if (!empty($months)) $string .= $months . "M"; if (!empty($seconds)) $string .= $seconds . "S"; logger(DEBUG, _("reccurrent event string : ") . $string, __FILE__ . ":" . __LINE__); - - + + $event = new event; // pb in recurrent event in case of date and not interval if ($isInterval === true) @@ -122,7 +123,7 @@ function setRecurrentEvent($function, $ieeeAddress, string $property, $value, bo { $event->recurrenceInterval = 0; } - + if (!empty($startDatetime)) { $event->startDatetime = new datetime($startDatetime); @@ -131,7 +132,7 @@ function setRecurrentEvent($function, $ieeeAddress, string $property, $value, bo $event->startDatetime = now(); } $event->dateTimeEvent = $event->startDatetime; - + if (!empty($stopDatetime)) { $event->stopDatetime = new datetime($stopDatetime); @@ -144,7 +145,7 @@ function setRecurrentEvent($function, $ieeeAddress, string $property, $value, bo $event->param = $property; $event->value = $value; } - + if ($event->recurrenceInterval != 0) { if (($event->dateTimeEvent->add($event->recurrenceInterval)) === false) @@ -157,7 +158,7 @@ function setRecurrentEvent($function, $ieeeAddress, string $property, $value, bo return 0; } -function setDelay(device &$deviceObject, float $delay, string $unit, string $property, $value, bool $replace=false, int $method = null) +function setDelay(device &$deviceObject, float $delay, string $unit, string $property, $value, $function, bool $replace=false, int $method = null) { global $events, $logLevel; $oldLevel = $logLevel; @@ -211,6 +212,7 @@ function setDelay(device &$deviceObject, float $delay, string $unit, string $pro $events[$key]->param = $property; $events[$key]->value = $value; $events[$key]->device = & $deviceObject; + $events[$key]->function = $function; if ($method !== null) $events[$key]->method = $method; logger (DEBUG, _('Setting new delay in $events[]'), __FILE__ . ":" . __LINE__); //print_r($events[$key]); @@ -228,7 +230,7 @@ function removeEvent(device $deviceObject, string $property , $value, int $metho } } -function searchEvent(device $deviceObject, string $property , $value) +function searchEvent(device $deviceObject, string $property, $function, $value) { global $events; logger(DEBUG, sprintf(_("searching event for device %s, property %s and value %s"), $deviceObject->friendlyName, $property, bool2string($value)), __FILE__ . ":" . __LINE__); diff --git a/hooks/scripts/rdc_sdb_eclairage.php b/hooks/scripts/rdc_sdb_eclairage.php index 98899ee..0197741 100644 --- a/hooks/scripts/rdc_sdb_eclairage.php +++ b/hooks/scripts/rdc_sdb_eclairage.php @@ -52,7 +52,7 @@ class rdc_sdb_eclairage extends hook }elseif (testActionneurs($this->actionneurs)) { logger(DEBUG, _("Actionneurs are all false"), __FILE__ . ":" . __LINE__); - setDelay($deviceTarget, $this->delay, $this->timeUnit, "state_l1", "OFF", true, IDLE); + //setDelay($deviceTarget, $this->delay, $this->timeUnit, "state_l1", "OFF", true, IDLE); } break; case "state_l1":