2022-01-06 13:11:18 +01:00
< ? php
2022-01-28 23:05:58 +01:00
class < name_of_class > extends hook
2022-01-06 13:11:18 +01:00
{
public $hookName = < public name of the hook > ;
2022-01-28 23:05:58 +01:00
public $active = true ; //enable/disable hook (true => enabled)
2022-01-06 13:11:18 +01:00
2022-01-28 23:05:58 +01:00
protected $devicelist = array ( < ieee address or constant defined in config / devices_constants . php > => array ( < property of the device to watch > , false ));
2022-01-06 13:11:18 +01:00
2022-01-28 23:05:58 +01:00
// 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 ()
2022-01-06 13:11:18 +01:00
{
2022-01-28 23:05:58 +01:00
// Your code here
2022-01-06 13:11:18 +01:00
}
2022-01-28 23:05:58 +01:00
*/
2022-01-06 13:11:18 +01:00
// 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
2022-02-23 10:23:16 +01:00
logger ( INFO , sprintf ( _ ( " %s: notification received from MQTT from %s => parameter: %s value: %s " ), $this -> hookName , $device -> friendlyName , $property , bool2string ( $value )), __FILE__ . " : " . __LINE__ );
2022-01-06 13:11:18 +01:00
}
}
$hooks [ < public name of the hook > ] = new < name_of_class > ();
?>