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