diff --git a/docs/template.php b/docs/template.php new file mode 100644 index 0000000..7e1d134 --- /dev/null +++ b/docs/template.php @@ -0,0 +1,37 @@ + +{ + public $hookName = ; + public $active = true; enable/disable hook (true => enabled) + + private $devicelist = array() => ); + + // assigne the function to the sensors devices + function __construct() + { + global $indexDevices; + if ($this->active === true) + { + foreach ($this->devicelist as $ieeeAddress => $property) + { + $indexDevices[$ieeeAddress]->$property["functions"][] = array($this,"callback"); + } + } + // put here your code to init the class + } + + // callback fonction. Is called with these 3 parameters + // $device -> calling device + // $property -> property of the device (given by mqtt) + // $value -> value of the property + public function callBack(&$device, $property, $value) + { + // here your code + + logger (INFO, _("%s: notification received from MQTT from %s => parameter: %s value: %s"), $this->hookName, $device->friendlyName, $property, $value); + } +} + +$hooks[] = new (); +?> diff --git a/hooks/scripts/rdc_sdb_eclairage.php b/hooks/scripts/rdc_sdb_eclairage.php index 0715ce8..d956b78 100644 --- a/hooks/scripts/rdc_sdb_eclairage.php +++ b/hooks/scripts/rdc_sdb_eclairage.php @@ -31,7 +31,6 @@ class rdc_sdb_eclairage foreach ($this->devicelist as $ieeeAddress => $property) { $indexDevices[$ieeeAddress]->$property["functions"][] = array($this,"callback"); - print_r($indexDevices[$ieeeAddress]); } } } diff --git a/mqtt_functions.php b/mqtt_functions.php index 354346e..8f2b984 100644 --- a/mqtt_functions.php +++ b/mqtt_functions.php @@ -118,7 +118,7 @@ function connectResponse($r, $message) function subscribeResponse($mid, $qosCount) { global $topics, $mids, $nSubscribed; - print_r($mids); + //print_r($mids); $key = $mids[$mid]; echo _("Subscribed to ") . $key . EOL; $topics[$key]->status = true;