51 lines
1.1 KiB
PHP
51 lines
1.1 KiB
PHP
<?php
|
|
class alerte_intrusion extends hook
|
|
{
|
|
public $hookName = "alerte_intrusion";
|
|
public $active = true;
|
|
|
|
protected $devicelist = array(
|
|
ENTREE_PORTE => "contact",
|
|
GARAGE_PORTE => "contact",
|
|
RDC_CHAMBRE_BAIE => "contact",
|
|
RDC_SALON_BAIE => "contact",
|
|
GARAGE_PORTAIL => "contact"
|
|
);
|
|
|
|
// callback fonction. Is called with these 4 parameters
|
|
public function callBack($device, $property, $value)
|
|
{
|
|
logger(DEBUG, sprintf(_("property=%s, value=%s"), $property, $value), __FILE__ . ":" . __LINE__);
|
|
switch($property)
|
|
{
|
|
case "contact":
|
|
if ($value == false)
|
|
{
|
|
logger(ALERT, sprintf(_("%s est ouverte alors que personne n'est présent"), $device->friendlyName), __FILE__ . ":" . __LINE__);
|
|
}
|
|
break;
|
|
}
|
|
}
|
|
|
|
public function test()
|
|
{
|
|
global $indexDevices;
|
|
$msg = "";
|
|
foreach ($this->devicelist as $device => $property)
|
|
{
|
|
if($indexDevices[$device]->properties[$property] != false)
|
|
{
|
|
$msg .= $indexDevices->friendlyName . " is open" . EOL;
|
|
}
|
|
}
|
|
if ($msg != "")
|
|
{
|
|
logger(ALERT, $msg, __FILE__ . ":" . __LINE__);
|
|
}
|
|
}
|
|
}
|
|
|
|
$hooks["alerte_intrusion"] = new alerte_intrusion();
|
|
|
|
?>
|