added callable function in event object
This commit is contained in:
parent
c8772aeda0
commit
80234fc505
@ -64,6 +64,7 @@ class event
|
|||||||
public $topic;
|
public $topic;
|
||||||
public $param;
|
public $param;
|
||||||
public $value;
|
public $value;
|
||||||
|
public $function;
|
||||||
public $device;
|
public $device;
|
||||||
public $published;
|
public $published;
|
||||||
public $dateTimeEvent; // datetime : next occurence for recurrent event
|
public $dateTimeEvent; // datetime : next occurence for recurrent event
|
||||||
|
@ -15,7 +15,7 @@ function checkEvents()
|
|||||||
$now = now();
|
$now = now();
|
||||||
if (!empty($event->startDatetime))
|
if (!empty($event->startDatetime))
|
||||||
{
|
{
|
||||||
logger(DEBUG, _("StarDatetime is set"), __FILE__ . ":" . __LINE__);
|
logger(DEBUG, _("StartDatetime is set"), __FILE__ . ":" . __LINE__);
|
||||||
if($event->dateTimeEvent < $now)
|
if($event->dateTimeEvent < $now)
|
||||||
{
|
{
|
||||||
logger(DEBUG, _("Event must be executed"), __FILE__ . ":" . __LINE__);
|
logger(DEBUG, _("Event must be executed"), __FILE__ . ":" . __LINE__);
|
||||||
@ -34,6 +34,11 @@ function checkEvents()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ($exception === false)
|
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__);
|
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");
|
publish(mktopic($event->device), array($event->param => $event->value), "set");
|
||||||
@ -43,6 +48,7 @@ function checkEvents()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}elseif (!empty($event->dateTimeEvent) and $event->dateTimeEvent < now())
|
}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__);
|
logger(DEBUG, sprintf(_("Sending command set %s => %s to %s"),$event->param, bool2string($event->value), $event->device->friendlyName), __FILE__ . ":" . __LINE__);
|
||||||
|
@ -14,7 +14,7 @@ class rdc_salon_eclairage extends hook
|
|||||||
|
|
||||||
public $delay = 3; // amount of time in $timeunit
|
public $delay = 3; // amount of time in $timeunit
|
||||||
public $timeUnit = "minute"; // unit of time for delay, second, minute, hour, day, week, month, year
|
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;
|
public $luminance_max = 100;
|
||||||
|
|
||||||
// callback fonction. Is called with these 4 parameters
|
// callback fonction. Is called with these 4 parameters
|
||||||
|
@ -73,6 +73,7 @@ function zigbee2mqttCallback($topic, $message)
|
|||||||
logger(DEBUG, _("friendlyname = ") . $fn, __FILE__ . ":" . __LINE__);
|
logger(DEBUG, _("friendlyname = ") . $fn, __FILE__ . ":" . __LINE__);
|
||||||
if (!array_key_exists($fn, $indexFriendlyNames[$topicName]))
|
if (!array_key_exists($fn, $indexFriendlyNames[$topicName]))
|
||||||
{
|
{
|
||||||
|
mkDevicesDB($topicName, $message->payload);
|
||||||
logger(ERROR, sprintf(_("device with friendlyname %s not found"), $fn), __FILE__ . ":" . __LINE__);
|
logger(ERROR, sprintf(_("device with friendlyname %s not found"), $fn), __FILE__ . ":" . __LINE__);
|
||||||
}else
|
}else
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user