32 lines
596 B
PHP
32 lines
596 B
PHP
<?php
|
|
<?php
|
|
class availability
|
|
{
|
|
// by default all devices are listening for availability
|
|
|
|
// callback fonction. Is called with these 4 parameters
|
|
public function callBack($topic, $fn, $param, $value)
|
|
{
|
|
global $devices, $indexDevices, $notificationMethods;
|
|
switch($param)
|
|
{
|
|
case "availability":
|
|
if ($value != "online")
|
|
{
|
|
//your code here
|
|
logger("Device: " . $topic . "/" . $fn . "is offline");
|
|
}
|
|
break;
|
|
}
|
|
echo _("notification received from MQTT") . EOL;
|
|
//echo $param . "=> " . $value . EOL;
|
|
}
|
|
}
|
|
|
|
$hooks["availability"] = new availability;
|
|
?>
|
|
|
|
|
|
|
|
?>
|