2022-09-02 17:59:33 +02:00
|
|
|
<?php
|
|
|
|
require_once "events.php";
|
|
|
|
|
|
|
|
|
2022-12-05 12:23:43 +01:00
|
|
|
class test_portes
|
2022-09-02 17:59:33 +02:00
|
|
|
{
|
|
|
|
public $hookName = "test_portes";
|
|
|
|
public $active = true;
|
|
|
|
|
2022-12-05 12:23:43 +01:00
|
|
|
public $deviceList = array(
|
|
|
|
RDC_ENTREE_PORTE => "contact",
|
|
|
|
GARAGE_PORTAIL => "contact",
|
|
|
|
GARAGE_PORTE => "contact",
|
|
|
|
ETAGE_PORTE_FENETRE => "contact",
|
|
|
|
ETAGE_CUISINE_FENETRE => "contact",
|
|
|
|
ETAGE_SALON_FENETRE => "contact",
|
|
|
|
RDC_CHAMBRE_BAIE => "contact",
|
|
|
|
RDC_SALON_BAIE => "contact",
|
2022-09-02 17:59:33 +02:00
|
|
|
);
|
|
|
|
|
2022-12-05 12:23:43 +01:00
|
|
|
/*function installHooks(&$indexDevices)
|
2022-09-02 17:59:33 +02:00
|
|
|
{
|
2022-12-05 12:23:43 +01:00
|
|
|
return 1;
|
|
|
|
}*/
|
2022-09-02 17:59:33 +02:00
|
|
|
|
|
|
|
public function testPortes($deviceList=false, $send=true, $opened=true) :array
|
|
|
|
{
|
2022-12-05 12:23:43 +01:00
|
|
|
global $indexDevices, $hooks;
|
2022-09-02 17:59:33 +02:00
|
|
|
$portes = array();
|
|
|
|
|
|
|
|
logger(DEBUG, _("Function testPorte"), __FILE__ . ":" . __LINE__);
|
|
|
|
|
2022-12-05 12:23:43 +01:00
|
|
|
if ($deviceList === false)
|
|
|
|
{
|
|
|
|
if (key_exists("rdc_portes_ouvertes", $hooks))
|
|
|
|
{
|
|
|
|
if (property_exists($hooks["rdc_portes_ouvertes"], devicelist))
|
|
|
|
{
|
|
|
|
$deviceList = $hooks["rdc_portes_ouvertes"]->devicelist;
|
|
|
|
}else
|
|
|
|
{
|
|
|
|
$deviceList = $this->deviceList;
|
|
|
|
}
|
|
|
|
}else
|
|
|
|
{
|
|
|
|
$deviceList = $this->deviceList;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-09-02 17:59:33 +02:00
|
|
|
$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;
|
|
|
|
}
|
|
|
|
}
|
2022-12-05 12:23:43 +01:00
|
|
|
$scripts["test_portes"] = new test_portes();
|
|
|
|
logger(DEBUG, _("Initializing test_portes"), __FILE__ . ":" . __LINE__);
|
|
|
|
$function = array($scripts["test_portes"], "testPortes");
|
2022-09-02 17:59:33 +02:00
|
|
|
//setRecurrentEvent("test_portes", $function, "", "", 0, -1, "", "", false, 21);
|
|
|
|
?>
|