correction de bugs
This commit is contained in:
@ -29,16 +29,16 @@ class alerte_intrusion extends hook
|
||||
switch($property)
|
||||
{
|
||||
case "contact":
|
||||
if ($value == false)
|
||||
if (isPresent() === false)
|
||||
{
|
||||
logger(ALERT, sprintf(_("%s vient de s'ouvrir alors que personne n'est présent"), $device->friendlyName), __FILE__ . ":" . __LINE__);
|
||||
}else
|
||||
{
|
||||
logger(ALERT, sprintf(_("%s vient de se fermer alors que personne n'est présent"), $device->friendlyName), __FILE__ . ":" . __LINE__);
|
||||
if ($value == false and isPresent() === false)
|
||||
{
|
||||
logger(ALERT, sprintf(_("%s vient de s'ouvrir alors que personne n'est présent"), $device->friendlyName), __FILE__ . ":" . __LINE__);
|
||||
}else
|
||||
{
|
||||
logger(ALERT, sprintf(_("%s vient de se fermer alors que personne n'est présent"), $device->friendlyName), __FILE__ . ":" . __LINE__);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -87,6 +87,6 @@ class alerte_intrusion extends hook
|
||||
$hooks["alerte_intrusion"] = new alerte_intrusion();
|
||||
logger(DEBUG, _("Initializing event"), __FILE__ . ":" . __LINE__);
|
||||
$function = array($hooks["alerte_intrusion"], "testPortes");
|
||||
setRecurrentEvent($function, 0, 0, 0, false, 0, 0, 21, 0, 0, 0, 0, 0, 0);
|
||||
//setRecurrentEvent("alerte_intrusion", $function, "", "", 0, -1, "", "", false, 21);
|
||||
|
||||
?>
|
||||
|
@ -10,11 +10,13 @@ class rdc_salon_eclairage extends hook
|
||||
RDC_SALON_MVMT2 => "occupancy",
|
||||
RDC_ENTREE_PORTE => "contact",
|
||||
RDC_SALON_LUMINOSITE => "illuminance_lux",
|
||||
RDC_SALON_ECLAIRAGE_PANNEAU => "state"
|
||||
RDC_SALON_ECLAIRAGE_PANNEAU => "state",
|
||||
RDC_SALON_PRESENCE => "presence"
|
||||
);
|
||||
protected $actionneurs = array(
|
||||
array(RDC_SALON_MVMT, "occupancy", 1),
|
||||
array(RDC_SALON_MVMT2, "occupancy", 1)
|
||||
array(RDC_SALON_MVMT2, "occupancy", 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
|
||||
@ -41,6 +43,8 @@ class rdc_salon_eclairage extends hook
|
||||
logger (INFO, _("property => ") . $param . _("value =>") . bool2string($value), __FILE__ . ":" . __LINE__);
|
||||
switch($param)
|
||||
{
|
||||
case "presence":
|
||||
logger(INFO, _("CASE: Présence => ") . bool2string($value), __FILE__ . ":" . __LINE__);
|
||||
case "occupancy":
|
||||
$method = $deviceTarget->properties["state"]["method"];
|
||||
logger(INFO, _("CASE: Occupancy => ") . bool2string($value), __FILE__ . ":" . __LINE__);
|
||||
@ -57,7 +61,8 @@ class rdc_salon_eclairage extends hook
|
||||
}else
|
||||
{
|
||||
logger(INFO, _("Value is OFF"), __FILE__ . ":" . __LINE__);
|
||||
if ((getValue(RDC_SALON_MVMT, "occupancy") == OFF) and (getValue(RDC_SALON_MVMT2, "occupancy") == OFF) and $method == AUTO)
|
||||
if (testActionneurs($this->actionneurs) 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__);
|
||||
$this->send($deviceTarget, "OFF", false, IDLE);
|
||||
@ -65,6 +70,7 @@ class rdc_salon_eclairage extends hook
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case "contact":
|
||||
$method = $deviceTarget->properties["state"]["method"];
|
||||
logger(INFO, _("CASE: Contact Door"), __FILE__ . ":" . __LINE__);
|
||||
@ -78,6 +84,7 @@ class rdc_salon_eclairage extends hook
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case "illuminance_lux":
|
||||
logger(INFO, _("CASE : Illuminance"), __FILE__ . ":" . __LINE__);
|
||||
if ($value >= $this->luminance_max and $deviceTarget->properties["state"]["value"] == "ON")
|
||||
@ -87,6 +94,7 @@ class rdc_salon_eclairage extends hook
|
||||
removeEvent($deviceTarget, "state", "OFF");
|
||||
}
|
||||
break;
|
||||
|
||||
case "state":
|
||||
logger(INFO, _("CASE : State"), __FILE__ . ":" . __LINE__);
|
||||
$method = $deviceTarget->properties["state"]["method"];
|
||||
|
@ -2,7 +2,7 @@
|
||||
// script to prevent when exterior temperature become inferior or superior to interior one
|
||||
class rdc_temperature_int_ext extends hook
|
||||
{
|
||||
public $hookName = "rdc_wc_eclairage";
|
||||
public $hookName = "rdc_temperature_int_ext";
|
||||
public $active = true; //enable/disable hook (true => enabled)
|
||||
public $tempSup = 25;
|
||||
public $tempInf = 20;
|
||||
@ -12,6 +12,13 @@ class rdc_temperature_int_ext extends hook
|
||||
METEO=> "tempc",
|
||||
);
|
||||
|
||||
protected $portesList = array(
|
||||
ENTREE_PORTE => "contact",
|
||||
//GARAGE_PORTE => "contact",
|
||||
RDC_CHAMBRE_BAIE => "contact",
|
||||
RDC_SALON_BAIE => "contact"
|
||||
);
|
||||
|
||||
function installHooks(&$indexDevices)
|
||||
{
|
||||
return $this->installHooksFunction($indexDevices);
|
||||
@ -26,51 +33,60 @@ class rdc_temperature_int_ext extends hook
|
||||
$status = -1;
|
||||
$msg = "";
|
||||
|
||||
logger(DEBUG, _("rdc_temperature_int_ext hook"), null ,$device);
|
||||
|
||||
if (empty($time)) $time = now();
|
||||
$indoorTemp = $device->properties["indoortempc"]["value"];
|
||||
//echo "Time is " . var_dump($time) . EOL;
|
||||
//echo "minutes since time :" . now()->format("U") - $time->format("U");
|
||||
if ((now()->format("U") - $time->format("U")) > 300)
|
||||
{
|
||||
|
||||
$indoorTemp = $device->properties["indoortempc"]["value"];
|
||||
|
||||
|
||||
if ( $value > $indoorTemp)
|
||||
{
|
||||
if( ($indoorTemp <= $this->tempSup) and empty($portes))
|
||||
if ( $value > $indoorTemp)
|
||||
{
|
||||
$status = 1;
|
||||
//logger(ALERT, _("Open doors to climate"), null ,$device);
|
||||
}elseif($indoorTemp >= $this -> tempSup and ! empty($portes))
|
||||
{
|
||||
$status = 0;
|
||||
//logger(ALERT, _("Close doors to climate"), null, $device);
|
||||
}
|
||||
}elseif ( $value < $indoorTemp )
|
||||
{
|
||||
if (($indoorTemp >= $this->tempSup) and empty($portes) )
|
||||
{
|
||||
$status = 1;
|
||||
//logger(ALERT, _("Open doors to climate"), null ,$device);
|
||||
}elseif ($indoorTemp <= $this->tempSup)
|
||||
{
|
||||
$status = 0;
|
||||
//logger(ALERT, _("Close doors to climate"), null, $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(false, true);
|
||||
if ($status == 1)
|
||||
{
|
||||
if (empty($portes) and ($time->diff(now())->format("i")) > 5)
|
||||
{
|
||||
logger(ALERT, _("Open doors to climate"), null, $device);
|
||||
$time = now();
|
||||
}
|
||||
}else
|
||||
{
|
||||
//$portes = $hooks["alerte_intrusion"]->testPortes(false, true);
|
||||
if (!empty($portes) and ($time.diff(now()).format("i") > 5))
|
||||
{
|
||||
$time = now();
|
||||
foreach($portes as $porte)
|
||||
if( ($indoorTemp <= $this->tempSup) and empty($portes))
|
||||
{
|
||||
$msg .= $porte . "\n";
|
||||
$status = 1;
|
||||
//logger(ALERT, _("Open doors to climate"), null ,$device);
|
||||
}elseif($indoorTemp >= $this -> tempSup and ! empty($portes))
|
||||
{
|
||||
$status = 0;
|
||||
//logger(ALERT, _("Close doors to climate"), null, $device);
|
||||
}
|
||||
}elseif ( $value < $indoorTemp )
|
||||
{
|
||||
if (($indoorTemp >= $this->tempSup) and empty($portes) )
|
||||
{
|
||||
$status = 1;
|
||||
//logger(ALERT, _("Open doors to climate"), null ,$device);
|
||||
}elseif ($indoorTemp <= $this->tempSup)
|
||||
{
|
||||
$status = 0;
|
||||
//logger(ALERT, _("Close doors to climate"), null, $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);
|
||||
if ($status == 1)
|
||||
{
|
||||
if (empty($portes))
|
||||
{
|
||||
logger(ALERT, _("Open doors to climate"), null, $device);
|
||||
$time = now();
|
||||
}
|
||||
}else
|
||||
{
|
||||
//$portes = $hooks["alerte_intrusion"]->testPortes(false, true);
|
||||
if (!empty($portes))
|
||||
{
|
||||
$time = now();
|
||||
foreach($portes as $porte)
|
||||
{
|
||||
$msg .= $porte . "\n";
|
||||
}
|
||||
logger(ALERT, _("Close doors to climate\n") . $msg, null, $device);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user