récupération après crash
This commit is contained in:
86
scripts/test_portes.php
Normal file
86
scripts/test_portes.php
Normal file
@ -0,0 +1,86 @@
|
||||
<?php
|
||||
require_once "events.php";
|
||||
|
||||
|
||||
class test_portes
|
||||
{
|
||||
public $hookName = "test_portes";
|
||||
public $active = true;
|
||||
|
||||
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",
|
||||
);
|
||||
|
||||
/*function installHooks(&$indexDevices)
|
||||
{
|
||||
return 1;
|
||||
}*/
|
||||
|
||||
public function testPortes($deviceList=false, $send=true, $opened=true) :array
|
||||
{
|
||||
global $indexDevices, $hooks;
|
||||
$portes = array();
|
||||
|
||||
logger(DEBUG, _("Function testPorte"), __FILE__ . ":" . __LINE__);
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
$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;
|
||||
}
|
||||
}
|
||||
$scripts["test_portes"] = new test_portes();
|
||||
logger(DEBUG, _("Initializing test_portes"), __FILE__ . ":" . __LINE__);
|
||||
$function = array($scripts["test_portes"], "testPortes");
|
||||
//setRecurrentEvent("test_portes", $function, "", "", 0, -1, "", "", false, 21);
|
||||
?>
|
Reference in New Issue
Block a user