2022-01-06 13:03:26 +01:00
|
|
|
<?php
|
2022-07-10 19:33:19 +02:00
|
|
|
require_once "events.php";
|
|
|
|
|
2022-01-17 00:18:50 +01:00
|
|
|
class alerte_intrusion extends hook
|
2022-01-06 13:03:26 +01:00
|
|
|
{
|
|
|
|
public $hookName = "alerte_intrusion";
|
|
|
|
public $active = true;
|
|
|
|
|
2022-01-17 00:18:50 +01:00
|
|
|
protected $devicelist = array(
|
2022-03-13 22:33:26 +01:00
|
|
|
ENTREE_PORTE => "contact",
|
|
|
|
GARAGE_PORTE => "contact",
|
|
|
|
RDC_CHAMBRE_BAIE => "contact",
|
2022-07-30 22:08:02 +02:00
|
|
|
RDC_SALON_BAIE => "contact",
|
|
|
|
GARAGE_PORTAIL => "contact"
|
2022-03-13 22:33:26 +01:00
|
|
|
);
|
2022-01-06 13:03:26 +01:00
|
|
|
|
2022-08-12 10:41:55 +02:00
|
|
|
function installHooks(&$indexDevices)
|
|
|
|
{
|
|
|
|
return $this->installHooksFunction($indexDevices);
|
|
|
|
}
|
|
|
|
|
2022-01-06 13:03:26 +01:00
|
|
|
// callback fonction. Is called with these 4 parameters
|
2022-03-13 22:33:26 +01:00
|
|
|
public function callBack($device, $property, $value)
|
2022-01-06 13:03:26 +01:00
|
|
|
{
|
2022-03-28 00:40:34 +02:00
|
|
|
logger(DEBUG, sprintf(_("property=%s, value=%s"), $property, $value), __FILE__ . ":" . __LINE__);
|
2022-03-13 22:33:26 +01:00
|
|
|
switch($property)
|
2022-01-06 13:03:26 +01:00
|
|
|
{
|
|
|
|
case "contact":
|
|
|
|
if ($value == false)
|
|
|
|
{
|
2022-01-28 23:05:58 +01:00
|
|
|
logger(ALERT, sprintf(_("%s est ouverte alors que personne n'est présent"), $device->friendlyName), __FILE__ . ":" . __LINE__);
|
2022-01-06 13:03:26 +01:00
|
|
|
}
|
2022-03-13 22:33:26 +01:00
|
|
|
break;
|
2022-01-06 13:03:26 +01:00
|
|
|
}
|
|
|
|
}
|
2022-07-10 13:57:38 +02:00
|
|
|
|
2022-07-10 19:33:19 +02:00
|
|
|
public function testPortes()
|
2022-07-10 13:57:38 +02:00
|
|
|
{
|
|
|
|
global $indexDevices;
|
2022-07-10 19:33:19 +02:00
|
|
|
logger(DEBUG, _("Function alerte_intrusion->testPorte"), __FILE__ . ":" . __LINE__);
|
|
|
|
|
2022-07-10 13:57:38 +02:00
|
|
|
$msg = "";
|
|
|
|
foreach ($this->devicelist as $device => $property)
|
|
|
|
{
|
|
|
|
if($indexDevices[$device]->properties[$property] != false)
|
|
|
|
{
|
2022-07-10 19:33:19 +02:00
|
|
|
$msg .= $indexDevices[$device]->friendlyName . " is open" . EOL;
|
2022-07-10 13:57:38 +02:00
|
|
|
}
|
|
|
|
}
|
2022-07-10 19:33:19 +02:00
|
|
|
if (!empty($msg))
|
2022-07-10 13:57:38 +02:00
|
|
|
{
|
|
|
|
logger(ALERT, $msg, __FILE__ . ":" . __LINE__);
|
|
|
|
}
|
2022-07-10 19:33:19 +02:00
|
|
|
return nl2br($msg);
|
2022-07-10 13:57:38 +02:00
|
|
|
}
|
2022-01-06 13:03:26 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
$hooks["alerte_intrusion"] = new alerte_intrusion();
|
2022-07-10 19:33:19 +02:00
|
|
|
logger(DEBUG, _("Initializing event"), __FILE__ . ":" . __LINE__);
|
|
|
|
$function = array($hooks["alerte_intrusion"], "testPortes");
|
|
|
|
setRecurrentEvent($function, 0, 0, 0, 0, 0, 0, 21, 0, 0, 1, 0, 0, 0);
|
2022-01-06 13:03:26 +01:00
|
|
|
|
|
|
|
?>
|