diff --git a/apiserver/cmd_functions.php b/apiserver/cmd_functions.php index e36e83c..41e6885 100644 --- a/apiserver/cmd_functions.php +++ b/apiserver/cmd_functions.php @@ -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; diff --git a/config/aliases.php b/config/aliases.php index e575759..09f878b 100644 --- a/config/aliases.php +++ b/config/aliases.php @@ -1,19 +1,4 @@ "sdb", diff --git a/config/properties2log.php b/config/properties2log.php index 8273aa6..67db416 100644 --- a/config/properties2log.php +++ b/config/properties2log.php @@ -35,6 +35,7 @@ $properties2log = array( "UV" => null, "indoortempc" => 0.5, "indoorhumidity" => 0.5, - "baromin" => 10 + "baromin" => 10, + "presence" => null ); diff --git a/config/types.php b/config/types.php index 9195cef..f61be20 100644 --- a/config/types.php +++ b/config/types.php @@ -26,6 +26,6 @@ $types = array( "cover" => array( "0x842e14fffe9be0fc" ), - "hvac" => + "hvac" => array() ); ?> diff --git a/hooks/scripts/rdc_portes_ouvertes.php b/hooks/scripts/rdc_portes_ouvertes.php index 0fc5a49..35abbf6 100644 --- a/hooks/scripts/rdc_portes_ouvertes.php +++ b/hooks/scripts/rdc_portes_ouvertes.php @@ -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); ?> diff --git a/hooks/scripts/rdc_salon_eclairage.php b/hooks/scripts/rdc_salon_eclairage.php index 15bf641..bdb9986 100644 --- a/hooks/scripts/rdc_salon_eclairage.php +++ b/hooks/scripts/rdc_salon_eclairage.php @@ -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__); diff --git a/hooks/scripts/rdc_temperature_int_ext.php b/hooks/scripts/rdc_temperature_int_ext.php index 39e7dac..27e165c 100644 --- a/hooks/scripts/rdc_temperature_int_ext.php +++ b/hooks/scripts/rdc_temperature_int_ext.php @@ -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(); diff --git a/hooks/scripts/test_portes.php b/hooks/scripts/test_portes.php new file mode 100644 index 0000000..a412e1c --- /dev/null +++ b/hooks/scripts/test_portes.php @@ -0,0 +1,62 @@ +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); +?> diff --git a/presence.php b/presence.php index 1413766..6ac62ee 100644 --- a/presence.php +++ b/presence.php @@ -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; } - } ?> diff --git a/utils.php b/utils.php index d5b346d..be998a5 100644 --- a/utils.php +++ b/utils.php @@ -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))