32 lines
1.0 KiB
PHP
32 lines
1.0 KiB
PHP
<?php
|
|
|
|
class <name_of_class> extends hook
|
|
{
|
|
public $hookName = <public name of the hook>;
|
|
public $active = true; //enable/disable hook (true => enabled)
|
|
|
|
protected $devicelist = array(<ieee address or constant defined in config/devices_constants.php> => array(<property of the device to watch>, false));
|
|
|
|
// if you need some initialisation when creating the object, uncomment andput your code here.
|
|
// If existing, This function is called by __construct
|
|
/*protected function init()
|
|
{
|
|
// Your code here
|
|
}
|
|
*/
|
|
|
|
// 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,sprintf(_("%s: notification received from MQTT from %s => parameter: %s value: %s"), $this->hookName, $device->friendlyName, $property, $value), __FILE__ . ":" . __LINE__);
|
|
}
|
|
}
|
|
|
|
$hooks[<public name of the hook>] = new <name_of_class>();
|
|
?>
|