debug
This commit is contained in:
parent
0f9f3d5a98
commit
e313205148
@ -606,7 +606,7 @@ function test()
|
|||||||
|
|
||||||
logger(DEBUG, _("Testing doors") , __FILE__ . ":" . __LINE__);
|
logger(DEBUG, _("Testing doors") , __FILE__ . ":" . __LINE__);
|
||||||
echo "testing doors";
|
echo "testing doors";
|
||||||
$portes = $hooks["alerte_intrusion"]->testPortes();
|
$portes = $hooks["test_portes"]->testPortes();
|
||||||
if (!empty($portes))
|
if (!empty($portes))
|
||||||
{
|
{
|
||||||
$msg = _("Opened doors:") . EOLH;
|
$msg = _("Opened doors:") . EOLH;
|
||||||
|
@ -1,19 +1,4 @@
|
|||||||
<?php
|
<?php
|
||||||
function aliases($fn, $property)
|
|
||||||
{
|
|
||||||
global $aliases;
|
|
||||||
logger(DEBUG, "Function aliases " . $fn . "/" . $property, __FILE__ . ":" . __LINE__);
|
|
||||||
if (array_key_exists($fn . "/" . $property, $aliases))
|
|
||||||
{
|
|
||||||
logger(DEBUG, "exists " . $fn . "/" . $property, __FILE__ . ":" . __LINE__);
|
|
||||||
return "/" . $aliases[$fn . "/" . $property];
|
|
||||||
}else
|
|
||||||
{
|
|
||||||
return "/" . _($property);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
$aliases = array(
|
$aliases = array(
|
||||||
"rdc/wc-sdb/eclairage/state_l1" => "sdb",
|
"rdc/wc-sdb/eclairage/state_l1" => "sdb",
|
||||||
|
@ -35,6 +35,7 @@ $properties2log = array(
|
|||||||
"UV" => null,
|
"UV" => null,
|
||||||
"indoortempc" => 0.5,
|
"indoortempc" => 0.5,
|
||||||
"indoorhumidity" => 0.5,
|
"indoorhumidity" => 0.5,
|
||||||
"baromin" => 10
|
"baromin" => 10,
|
||||||
|
"presence" => null
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -26,6 +26,6 @@ $types = array(
|
|||||||
"cover" => array(
|
"cover" => array(
|
||||||
"0x842e14fffe9be0fc"
|
"0x842e14fffe9be0fc"
|
||||||
),
|
),
|
||||||
"hvac" =>
|
"hvac" => array()
|
||||||
);
|
);
|
||||||
?>
|
?>
|
||||||
|
@ -43,7 +43,7 @@ class alerte_intrusion extends hook
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testPortes($deviceList=false, $send=true, $opened=true) :array
|
/* public function testPortes($deviceList=false, $send=true, $opened=true) :array
|
||||||
{
|
{
|
||||||
global $indexDevices;
|
global $indexDevices;
|
||||||
$portes = array();
|
$portes = array();
|
||||||
@ -81,12 +81,12 @@ class alerte_intrusion extends hook
|
|||||||
logger(ALERT, _("doors opened :") . $msg, null ,$device);
|
logger(ALERT, _("doors opened :") . $msg, null ,$device);
|
||||||
}
|
}
|
||||||
return $portes;
|
return $portes;
|
||||||
}
|
}*/
|
||||||
}
|
}
|
||||||
|
|
||||||
$hooks["alerte_intrusion"] = new alerte_intrusion();
|
$hooks["alerte_intrusion"] = new alerte_intrusion();
|
||||||
logger(DEBUG, _("Initializing event"), __FILE__ . ":" . __LINE__);
|
logger(DEBUG, _("Initializing event"), __FILE__ . ":" . __LINE__);
|
||||||
$function = array($hooks["alerte_intrusion"], "testPortes");
|
//$function = array($hooks["testPortes"], "testPortes");
|
||||||
//setRecurrentEvent("alerte_intrusion", $function, "", "", 0, -1, "", "", false, 21);
|
//setRecurrentEvent("alerte_intrusion", $function, "", "", 0, -1, "", "", false, 21);
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
@ -16,7 +16,7 @@ class rdc_salon_eclairage extends hook
|
|||||||
protected $actionneurs = array(
|
protected $actionneurs = array(
|
||||||
array(RDC_SALON_MVMT, "occupancy", 1),
|
array(RDC_SALON_MVMT, "occupancy", 1),
|
||||||
array(RDC_SALON_MVMT2, "occupancy", 1),
|
array(RDC_SALON_MVMT2, "occupancy", 1),
|
||||||
array(RDC_SALON_PRESENCE => "presence", 1)
|
array(RDC_SALON_PRESENCE, "presence", 1)
|
||||||
);
|
);
|
||||||
public $delay = 3; // amount of time in $timeunit
|
public $delay = 3; // amount of time in $timeunit
|
||||||
public $timeUnit = "minute"; // unit of time for delay, second, minute, hour, day, week, month, year
|
public $timeUnit = "minute"; // unit of time for delay, second, minute, hour, day, week, month, year
|
||||||
@ -61,7 +61,7 @@ class rdc_salon_eclairage extends hook
|
|||||||
}else
|
}else
|
||||||
{
|
{
|
||||||
logger(INFO, _("Value is OFF"), __FILE__ . ":" . __LINE__);
|
logger(INFO, _("Value is OFF"), __FILE__ . ":" . __LINE__);
|
||||||
if (testActionneurs($this->actionneurs) and $method = AUTO)
|
if (testActionneurs($this->actionneurs) === false and $method == AUTO)
|
||||||
//if ((getValue(RDC_SALON_MVMT, "occupancy") == OFF) and (getValue(RDC_SALON_MVMT2, "occupancy") == OFF) and $method == AUTO)
|
//if ((getValue(RDC_SALON_MVMT, "occupancy") == OFF) and (getValue(RDC_SALON_MVMT2, "occupancy") == OFF) and $method == AUTO)
|
||||||
{
|
{
|
||||||
logger(INFO, _("Setting to OFF"), __FILE__ . ":" . __LINE__);
|
logger(INFO, _("Setting to OFF"), __FILE__ . ":" . __LINE__);
|
||||||
|
@ -68,18 +68,22 @@ class rdc_temperature_int_ext extends hook
|
|||||||
}
|
}
|
||||||
logger (INFO, sprintf(_("%s: notification received from MQTT from %s => parameter: %s value: %s"), $this->hookName, $device->friendlyName, $property, bool2string($value)), __FILE__ . ":" . __LINE__, $device);
|
logger (INFO, sprintf(_("%s: notification received from MQTT from %s => parameter: %s value: %s"), $this->hookName, $device->friendlyName, $property, bool2string($value)), __FILE__ . ":" . __LINE__, $device);
|
||||||
}
|
}
|
||||||
$portes = $hooks["alerte_intrusion"]->testPortes($this->portesList, false, true);
|
|
||||||
print_r($portes);
|
print_r($portes);
|
||||||
if ($status == 1)
|
if ($status == 1)
|
||||||
{
|
{
|
||||||
|
$portes = $hooks["test_portes"]->testPortes($this->portesList, false, false);
|
||||||
if (empty($portes))
|
if (empty($portes))
|
||||||
{
|
{
|
||||||
logger(ALERT, _("Open doors to climate"), null, $device);
|
|
||||||
$time = now();
|
$time = now();
|
||||||
|
foreach($portes as $porte)
|
||||||
|
{
|
||||||
|
$msg .= $porte . "\n";
|
||||||
|
}
|
||||||
|
logger(ALERT, _("Open doors to climate") . $msg, null, $device);
|
||||||
}
|
}
|
||||||
}else
|
}else
|
||||||
{
|
{
|
||||||
//$portes = $hooks["alerte_intrusion"]->testPortes(false, true);
|
$portes = $hooks["test_portes"]->testPortes($this->portesList, false, true);
|
||||||
if (!empty($portes))
|
if (!empty($portes))
|
||||||
{
|
{
|
||||||
$time = now();
|
$time = now();
|
||||||
|
62
hooks/scripts/test_portes.php
Normal file
62
hooks/scripts/test_portes.php
Normal file
@ -0,0 +1,62 @@
|
|||||||
|
<?php
|
||||||
|
require_once "events.php";
|
||||||
|
|
||||||
|
|
||||||
|
class test_portes extends hook
|
||||||
|
{
|
||||||
|
public $hookName = "test_portes";
|
||||||
|
public $active = true;
|
||||||
|
|
||||||
|
protected $devicelist = array(
|
||||||
|
);
|
||||||
|
|
||||||
|
function installHooks(&$indexDevices)
|
||||||
|
{
|
||||||
|
return $this->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);
|
||||||
|
?>
|
@ -27,14 +27,14 @@ function presence($argList)
|
|||||||
{
|
{
|
||||||
if ($presence[$name] == false)
|
if ($presence[$name] == false)
|
||||||
{
|
{
|
||||||
logger(ALERT, $name . _(" est présent"), __FILE__ . ":" . __LINE__ , $device);
|
logger(ALERT, $name . _(" est présent"), __FILE__ . ":" . __LINE__);
|
||||||
//echo $name . " est présent";
|
//echo $name . " est présent";
|
||||||
$presence[$name] = true;
|
$presence[$name] = true;
|
||||||
}
|
}
|
||||||
}elseif ($presence[$name] == true)
|
}elseif ($presence[$name] == true)
|
||||||
{
|
{
|
||||||
$presence[$name] = false;
|
$presence[$name] = false;
|
||||||
logger(ALERT, $name . _(" est présent"), __FILE__ . ":" . __LINE__, $device);
|
logger(ALERT, $name . _(" est présent"), __FILE__ . ":" . __LINE__);
|
||||||
}
|
}
|
||||||
return _("demande prise en compte");
|
return _("demande prise en compte");
|
||||||
}
|
}
|
||||||
@ -45,7 +45,7 @@ function isPresent($name = false, $returnNames = false)
|
|||||||
global $presence;
|
global $presence;
|
||||||
|
|
||||||
$r = false;
|
$r = false;
|
||||||
$list = "";
|
$liste = "";
|
||||||
|
|
||||||
if ($name === false)
|
if ($name === false)
|
||||||
{
|
{
|
||||||
@ -72,6 +72,5 @@ function isPresent($name = false, $returnNames = false)
|
|||||||
{
|
{
|
||||||
return $r;
|
return $r;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
@ -42,6 +42,7 @@ function testActionneurs(array $actionneurs) //return 0 for no actionneurs and
|
|||||||
$r = 0;
|
$r = 0;
|
||||||
foreach ($actionneurs as $device)
|
foreach ($actionneurs as $device)
|
||||||
{
|
{
|
||||||
|
logger(DEBUG, _("device: ") . var_dump($device), __FILE__ . ":" . __LINE__ );
|
||||||
if (array_key_exists($device[0], $indexDevices))
|
if (array_key_exists($device[0], $indexDevices))
|
||||||
{
|
{
|
||||||
if (array_key_exists($device[1], $indexDevices[$device[0]]->properties))
|
if (array_key_exists($device[1], $indexDevices[$device[0]]->properties))
|
||||||
|
Loading…
Reference in New Issue
Block a user