debug
This commit is contained in:
62
hooks/scripts/test_portes.php
Normal file
62
hooks/scripts/test_portes.php
Normal file
@ -0,0 +1,62 @@
|
||||
<?php
|
||||
require_once "events.php";
|
||||
|
||||
|
||||
class test_portes extends hook
|
||||
{
|
||||
public $hookName = "test_portes";
|
||||
public $active = true;
|
||||
|
||||
protected $devicelist = array(
|
||||
);
|
||||
|
||||
function installHooks(&$indexDevices)
|
||||
{
|
||||
return $this->installHooksFunction($indexDevices);
|
||||
}
|
||||
|
||||
public function testPortes($deviceList=false, $send=true, $opened=true) :array
|
||||
{
|
||||
global $indexDevices;
|
||||
$portes = array();
|
||||
|
||||
logger(DEBUG, _("Function testPorte"), __FILE__ . ":" . __LINE__);
|
||||
|
||||
if ($deviceList === false) $deviceList = $hooks["rdc_portes_ouvertes"]->devicelist;
|
||||
$msg = "";
|
||||
foreach ($deviceList as $device => $property)
|
||||
{
|
||||
//echo "device: " . $device . "\n";
|
||||
//echo "opened = " . bool2string($opened);
|
||||
//echo " value = " . var_dump($indexDevices[$device]->properties[$property]);
|
||||
|
||||
if ($opened)
|
||||
{
|
||||
if($indexDevices[$device]->properties[$property]["value"] === false)
|
||||
{
|
||||
//echo "porte opened";
|
||||
$portes[] = $indexDevices[$device]->friendlyName;
|
||||
$msg .= $indexDevices[$device]->friendlyName . "\n";
|
||||
}
|
||||
}else
|
||||
{
|
||||
if($indexDevices[$device]->properties[$property]["value"] === true)
|
||||
{
|
||||
//echo "porte closed";
|
||||
$portes[] = $indexDevices[$device]->friendlyName;
|
||||
$msg .= $indexDevices[$device]->friendlyName . "\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($send)
|
||||
{
|
||||
logger(ALERT, _("doors opened :") . $msg, null ,$device);
|
||||
}
|
||||
return $portes;
|
||||
}
|
||||
}
|
||||
$hooks["test_portes"] = new test_portes();
|
||||
logger(DEBUG, _("Initializing event"), __FILE__ . ":" . __LINE__);
|
||||
$function = array($hooks["test_portes"], "testPortes");
|
||||
//setRecurrentEvent("test_portes", $function, "", "", 0, -1, "", "", false, 21);
|
||||
?>
|
Reference in New Issue
Block a user