DTux
/
dtux__moha
Archived
1
0
Fork 0
This repository has been archived on 2023-11-30. You can view files and clone it, but cannot push or open issues or pull requests.
dtux__moha/hooks/scripts/test_portes.php

63 lines
1.6 KiB
PHP

<?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);
?>