1
0

added template and delete some debugging message

This commit is contained in:
2022-01-06 13:11:18 +01:00
parent 004c6aa572
commit e702d333c8
3 changed files with 38 additions and 2 deletions

37
docs/template.php Normal file
View File

@ -0,0 +1,37 @@
<?php
class <name_of_class>
{
public $hookName = <public name of the hook>;
public $active = true; enable/disable hook (true => enabled)
private $devicelist = array(<ieee address or constant defined in config/devices_constants.php>) => <property of the device to watch>);
// 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[<public name of the hook>] = new <name_of_class>();
?>