some adjustments
This commit is contained in:
@@ -9,7 +9,8 @@ class rdc_salon_eclairage extends hook
|
||||
RDC_SALON_MVMT => "occupancy",
|
||||
RDC_SALON_MVMT2 => "occupancy",
|
||||
RDC_ENTREE_PORTE => "contact",
|
||||
RDC_SALON_LUMINOSITE => "illuminance_lux"
|
||||
RDC_SALON_LUMINOSITE => "illuminance_lux",
|
||||
RDC_SALON_ECLAIRAGE_PANNEAU => "state"
|
||||
);
|
||||
protected $actionneurs = array(
|
||||
array(RDC_SALON_MVMT, "occupancy", 1),
|
||||
@@ -34,15 +35,17 @@ class rdc_salon_eclairage extends hook
|
||||
$lux = $indexDevices[RDC_SALON_LUMINOSITE];
|
||||
$mvmt = $indexDevices[RDC_SALON_MVMT];
|
||||
$mvmt2 = $indexDevices[RDC_SALON_MVMT2];
|
||||
$method;
|
||||
$illuminance = getValue(RDC_SALON_LUMINOSITE, "illuminance_lux");
|
||||
|
||||
logger (INFO, _("property => ") . $param . _("value =>") . bool2string($value), __FILE__ . ":" . __LINE__);
|
||||
switch($param)
|
||||
{
|
||||
case "occupancy":
|
||||
$method = $deviceTarget->properties["state"]["method"];
|
||||
logger(INFO, _("CASE: Occupancy => ") . bool2string($value), __FILE__ . ":" . __LINE__);
|
||||
//print_r(getValue(RDC_SALON_LUMINOSITE, "illuminance_lux"));
|
||||
if ($value == ON)
|
||||
if ($value == ON and $method == IDLE)
|
||||
{
|
||||
logger(INFO, _("illuminance value : ") . $illuminance, __FILE__ . ":" . __LINE__);
|
||||
if ($illuminance <= $this->luminance_min)
|
||||
@@ -54,22 +57,24 @@ 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))
|
||||
if ((getValue(RDC_SALON_MVMT, "occupancy") == OFF) and (getValue(RDC_SALON_MVMT2, "occupancy") == OFF) and $method == AUTO)
|
||||
{
|
||||
logger(INFO, _("Setting to OFF"), __FILE__ . ":" . __LINE__);
|
||||
setDelay($deviceTarget, $this->delay, $this->timeUnit, "state", "OFF", true);
|
||||
//$this->send($deviceTarget, "OFF", false, IDLE);
|
||||
$this->send($deviceTarget, "OFF", false, IDLE);
|
||||
removeEvent($deviceTarget, "state", "OFF");
|
||||
}
|
||||
}
|
||||
break;
|
||||
case "contact":
|
||||
$method = $deviceTarget->properties["state"]["method"];
|
||||
logger(INFO, _("CASE: Contact Door"), __FILE__ . ":" . __LINE__);
|
||||
if ($value == false and $illuminance <= $this->luminance_min)
|
||||
if ($value == false and $illuminance <= $this->luminance_min and $method == IDLE)
|
||||
{
|
||||
logger(INFO, _("Door is open and illumance < min and method =>") . $deviceTarget->properties["state"]["method"], __FILE__ . ":" . __LINE__);
|
||||
if ($deviceTarget->properties["state"]["method"] == IDLE)
|
||||
if ($method == IDLE)
|
||||
{
|
||||
$this->send($deviceTarget, "ON", "OFF", AUTO);
|
||||
$this->send($deviceTarget, "ON", false, AUTO);
|
||||
removeEvent($deviceTarget, "state", "OFF");
|
||||
}
|
||||
}
|
||||
break;
|
||||
@@ -78,17 +83,21 @@ class rdc_salon_eclairage extends hook
|
||||
if ($value >= $this->luminance_max and $deviceTarget->properties["state"]["value"] == "ON")
|
||||
{
|
||||
logger(INFO, _("illuminace is > to max"), __FILE__ . ":" . __LINE__);
|
||||
//$this->send($deviceTarget, "OFF", null, AUTO);
|
||||
//removeEvent($indexDevices[RDC_SALON_ECLAIRAGE_PANNEAU], "state", "OFF");
|
||||
if (searchEvent($deviceTarget, "state", "OFF") === false)
|
||||
{
|
||||
setDelay($deviceTarget, $this->delay, $this->timeUnit, "state", "OFF", true, IDLE);
|
||||
}
|
||||
}/*elseif ($value <= $this->luminance_min and (getValue(RDC_SALON_MVMT, "occupancy") == ON || getValue(RDC_SALON_MVMT2,"occupancy") == ON))
|
||||
$this->send($deviceTarget, "OFF", false, IDLE);
|
||||
removeEvent($deviceTarget, "state", "OFF");
|
||||
}
|
||||
break;
|
||||
case "state":
|
||||
logger(INFO, _("CASE : State"), __FILE__ . ":" . __LINE__);
|
||||
$method = $deviceTarget->properties["state"]["method"];
|
||||
if($value == "ON" and $method == IDLE)
|
||||
{
|
||||
logger(INFO, _("illuminance < min and movement detected"), __FILE__ . ":" . __LINE__);
|
||||
$this->send($deviceTarget, "ON", false, AUTO);
|
||||
}*/
|
||||
$deviceTarget->properties["state"]["method"] = MANUAL;
|
||||
removeEvent($deviceTarget, "state", "OFF");
|
||||
}else
|
||||
{
|
||||
$deviceTarget->properties["state"]["method"] = IDLE;
|
||||
}
|
||||
break;
|
||||
}
|
||||
logger (INFO, sprintf(_("%s: notification received from MQTT from %s => parameter: %s value: %s"), $this->hookName, $device->friendlyName, $param, bool2string($value)), __FILE__ . ":" . __LINE__);
|
||||
@@ -99,17 +108,9 @@ class rdc_salon_eclairage extends hook
|
||||
global $indexDevices;
|
||||
|
||||
$msg = array("state" => $state);
|
||||
//if ($deviceTarget->properties["state"]["value"] != $state)
|
||||
//{
|
||||
logger(INFO, sprintf(_("publishing message: %s to %s"), json_encode($msg), $deviceTarget->friendlyName), __FILE__ . ":" . __LINE__);
|
||||
$deviceTarget->payload = $msg;
|
||||
$deviceTarget->set("state", $method);
|
||||
//$deviceTarget->properties["state"]["method"] = $method;
|
||||
/*}else
|
||||
{
|
||||
logger(INFO, sprintf(_("not publishing message: %s to %s, already set"), json_encode($msg), $deviceTarget->friendlyName), __FILE__ . ":" . __LINE__);
|
||||
}*/
|
||||
//echo 'delaystate = ' . var_dump($delayState);
|
||||
logger(INFO, sprintf(_("publishing message: %s to %s"), json_encode($msg), $deviceTarget->friendlyName), __FILE__ . ":" . __LINE__);
|
||||
$deviceTarget->payload = $msg;
|
||||
$deviceTarget->set("state", $method);
|
||||
if ($delayState !== false) setDelay($deviceTarget, $this->delay, $this->timeUnit, "state", $delayState, true);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user