1
0

modified init and some debugging

This commit is contained in:
2022-01-06 13:03:26 +01:00
parent 85a7fd7ed9
commit 004c6aa572
10 changed files with 178 additions and 34 deletions

View File

@ -1,41 +0,0 @@
<?php
class availability
{
// by default all devices are listening for availability
// callback fonction. Is called with these 3 parameters
// $device -> calling device
// $param -> parameter passed by mqtt
// $value -> value of the parameter
public function callBack($device, $param, $value)
{
switch($param)
{
case "availability": // theorically can't be other, but ....
if ($device->availability != $value)
{
//echo "==========>>>>>> Availability $value" . EOL;
if (!empty($device->availability))
{
$log = WARNING;
}else
{
$log = INFO;
}
$device->availability = $value;
logger($log, sprintf(_("Device: %s/%s is %s"), $device->topic, $device->friendlyName, $value));
}
break;
}
echo sprintf(_("notification received from MQTT -> device %s is %s"), $device->friendlyName , $value). EOL;
//echo $param . "=> " . $value . EOL;
}
public function getHook()
{
return array($this,"callback");
}
}
$hooks["availability"] = new availability;
?>

View File

@ -28,7 +28,7 @@ class device
public $description;
public $functions;
public $payload;
public $availibility;
public $availability = array();
public function set($event)
{