1
0
This commit is contained in:
Daniel Tartavel 2022-09-02 17:59:33 +02:00
parent 0f9f3d5a98
commit e313205148
10 changed files with 82 additions and 30 deletions

View File

@ -606,7 +606,7 @@ function test()
logger(DEBUG, _("Testing doors") , __FILE__ . ":" . __LINE__);
echo "testing doors";
$portes = $hooks["alerte_intrusion"]->testPortes();
$portes = $hooks["test_portes"]->testPortes();
if (!empty($portes))
{
$msg = _("Opened doors:") . EOLH;

View File

@ -1,19 +1,4 @@
<?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(
"rdc/wc-sdb/eclairage/state_l1" => "sdb",

View File

@ -35,6 +35,7 @@ $properties2log = array(
"UV" => null,
"indoortempc" => 0.5,
"indoorhumidity" => 0.5,
"baromin" => 10
"baromin" => 10,
"presence" => null
);

View File

@ -26,6 +26,6 @@ $types = array(
"cover" => array(
"0x842e14fffe9be0fc"
),
"hvac" =>
"hvac" => array()
);
?>

View File

@ -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;
$portes = array();
@ -81,12 +81,12 @@ class alerte_intrusion extends hook
logger(ALERT, _("doors opened :") . $msg, null ,$device);
}
return $portes;
}
}*/
}
$hooks["alerte_intrusion"] = new alerte_intrusion();
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);
?>

View File

@ -16,7 +16,7 @@ class rdc_salon_eclairage extends hook
protected $actionneurs = array(
array(RDC_SALON_MVMT, "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 $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
{
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)
{
logger(INFO, _("Setting to OFF"), __FILE__ . ":" . __LINE__);

View File

@ -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);
}
$portes = $hooks["alerte_intrusion"]->testPortes($this->portesList, false, true);
print_r($portes);
if ($status == 1)
{
$portes = $hooks["test_portes"]->testPortes($this->portesList, false, false);
if (empty($portes))
{
logger(ALERT, _("Open doors to climate"), null, $device);
$time = now();
foreach($portes as $porte)
{
$msg .= $porte . "\n";
}
logger(ALERT, _("Open doors to climate") . $msg, null, $device);
}
}else
{
//$portes = $hooks["alerte_intrusion"]->testPortes(false, true);
$portes = $hooks["test_portes"]->testPortes($this->portesList, false, true);
if (!empty($portes))
{
$time = now();

View 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);
?>

View File

@ -27,14 +27,14 @@ function presence($argList)
{
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";
$presence[$name] = true;
}
}elseif ($presence[$name] == true)
{
$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");
}
@ -45,7 +45,7 @@ function isPresent($name = false, $returnNames = false)
global $presence;
$r = false;
$list = "";
$liste = "";
if ($name === false)
{
@ -72,6 +72,5 @@ function isPresent($name = false, $returnNames = false)
{
return $r;
}
}
?>

View File

@ -42,6 +42,7 @@ function testActionneurs(array $actionneurs) //return 0 for no actionneurs and
$r = 0;
foreach ($actionneurs as $device)
{
logger(DEBUG, _("device: ") . var_dump($device), __FILE__ . ":" . __LINE__ );
if (array_key_exists($device[0], $indexDevices))
{
if (array_key_exists($device[1], $indexDevices[$device[0]]->properties))