2022-09-02 17:59:33 +02:00
|
|
|
<?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)
|
|
|
|
{
|
2022-09-05 13:47:41 +02:00
|
|
|
logger(ALERT, _("doors opened :") . $msg, null, $device);
|
2022-09-02 17:59:33 +02:00
|
|
|
}
|
|
|
|
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);
|
|
|
|
?>
|