1
0

added callable function in event object

This commit is contained in:
daniel Tartavel 2022-03-15 22:49:13 +01:00
parent c8772aeda0
commit 80234fc505
4 changed files with 14 additions and 6 deletions

View File

@ -64,6 +64,7 @@ class event
public $topic;
public $param;
public $value;
public $function;
public $device;
public $published;
public $dateTimeEvent; // datetime : next occurence for recurrent event

View File

@ -15,7 +15,7 @@ function checkEvents()
$now = now();
if (!empty($event->startDatetime))
{
logger(DEBUG, _("StarDatetime is set"), __FILE__ . ":" . __LINE__);
logger(DEBUG, _("StartDatetime is set"), __FILE__ . ":" . __LINE__);
if($event->dateTimeEvent < $now)
{
logger(DEBUG, _("Event must be executed"), __FILE__ . ":" . __LINE__);
@ -34,6 +34,11 @@ function checkEvents()
}
}
if ($exception === false)
{
if (is_callable($this->function))
{
$this->function(&$event);
}else
{
logger(DEBUG, sprintf(_("sending command set %s => %s for %s"), $event->param ,bool2string($event->value), $event->device->friendlyName), __FILE__ . ":" . __LINE__);
publish(mktopic($event->device), array($event->param => $event->value), "set");
@ -43,6 +48,7 @@ function checkEvents()
}
}
}
}
}elseif (!empty($event->dateTimeEvent) and $event->dateTimeEvent < now())
{
logger(DEBUG, sprintf(_("Sending command set %s => %s to %s"),$event->param, bool2string($event->value), $event->device->friendlyName), __FILE__ . ":" . __LINE__);

View File

@ -14,7 +14,7 @@ class rdc_salon_eclairage extends hook
public $delay = 3; // amount of time in $timeunit
public $timeUnit = "minute"; // unit of time for delay, second, minute, hour, day, week, month, year
public $luminance_min = 60;
public $luminance_min = 50;
public $luminance_max = 100;
// callback fonction. Is called with these 4 parameters

View File

@ -73,6 +73,7 @@ function zigbee2mqttCallback($topic, $message)
logger(DEBUG, _("friendlyname = ") . $fn, __FILE__ . ":" . __LINE__);
if (!array_key_exists($fn, $indexFriendlyNames[$topicName]))
{
mkDevicesDB($topicName, $message->payload);
logger(ERROR, sprintf(_("device with friendlyname %s not found"), $fn), __FILE__ . ":" . __LINE__);
}else
{