debugage
This commit is contained in:
@@ -22,7 +22,10 @@ class rdc_salon_eclairage extends hook
|
||||
{
|
||||
global $indexDevices;
|
||||
logger(INFO, _("hook : rdc_salon_eclairage"), __FILE__ . ":" . __LINE__);
|
||||
$device = &$indexDevices[RDC_SALON_ECLAIRAGE_PANNEAU];
|
||||
$deviceTarget = &$indexDevices[RDC_SALON_ECLAIRAGE_PANNEAU];
|
||||
$lux = $indexDevices[RDC_SALON_LUMINOSITE];
|
||||
$mvmt = $indexDevices[RDC_SALON_MVMT];
|
||||
$mvmt2 = $indexDevices[RDC_SALON_MVMT2];
|
||||
switch($param)
|
||||
{
|
||||
case "occupancy":
|
||||
@@ -31,30 +34,30 @@ class rdc_salon_eclairage extends hook
|
||||
if ($value == ON and getValue(RDC_SALON_LUMINOSITE, "illuminance_lux") <= $this->luminance_min)
|
||||
{
|
||||
logger(DEBUG, _("setting to ON"), __FILE__ . ":" . __LINE__);
|
||||
$this->send("ON", null, AUTO);
|
||||
removeEvent($device, "state", "OFF");
|
||||
$this->send($deviceTarget, "ON", null, AUTO);
|
||||
removeEvent($deviceTarget, "state", "OFF");
|
||||
}elseif ($value == OFF)
|
||||
{
|
||||
logger(DEBUG, _("Value is OFF"), __FILE__ . ":" . __LINE__);
|
||||
if (getValue(RDC_SALON_MVMT, "occupancy") == OFF and (getValue(RDC_SALON_MVMT2, "occupancy") == OFF))
|
||||
{
|
||||
logger(DEBUG, _("Setting to OFF"), __FILE__ . ":" . __LINE__);
|
||||
setDelay($device, $this->delay, $this->timeUnit, "state", "OFF", true);
|
||||
//$this->send("ON", "OFF", AUTO);
|
||||
setDelay($deviceTarget, $this->delay, $this->timeUnit, "state", "OFF", true);
|
||||
//$this->send($deviceTarget, "ON", "OFF", AUTO);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case "contact":
|
||||
logger(DEBUG, _("CASE: Contact Door"), __FILE__ . ":" . __LINE__);
|
||||
if ($value == false and getValue(RDC_SALON_LUMINOSITE, "illuminance_lux") <= $this->luminance_min and getValue(RDC_SALON_ECLAIRAGE_PANNEAU, "state") == "OFF")
|
||||
if ($value == false and getValue(RDC_SALON_LUMINOSITE, "illuminance_lux") <= $this->luminance_min and getValue($deviceTarget->ieeeAddress, "state") == "OFF")
|
||||
{
|
||||
logger(DEBUG, _("Door is open and illumance < min"), __FILE__ . ":" . __LINE__);
|
||||
if (getValue(RDC_SALON_MVMT, "occupancy") == ON or getValue(RDC_SALON_MVMT2, "occupancy") == ON)
|
||||
{
|
||||
$this->send("ON", null, AUTO);
|
||||
$this->send($deviceTarget, "ON", null, AUTO);
|
||||
}else
|
||||
{
|
||||
$this->send("ON", "OFF", AUTO);
|
||||
$this->send($deviceTarget, "ON", "OFF", AUTO);
|
||||
}
|
||||
}
|
||||
break;
|
||||
@@ -63,39 +66,39 @@ class rdc_salon_eclairage extends hook
|
||||
if ($value >= $this->luminance_max)
|
||||
{
|
||||
logger(DEBUG, _("illuminace is > to max"), __FILE__ . ":" . __LINE__);
|
||||
//$this->send("OFF", null, AUTO);
|
||||
//$this->send($deviceTarget, "OFF", null, AUTO);
|
||||
//removeEvent($indexDevices[RDC_SALON_ECLAIRAGE_PANNEAU], "state", "OFF");
|
||||
if (searchEvent($device, "state", "OFF") === false)
|
||||
if (searchEvent($deviceTarget, "state", "OFF") === false)
|
||||
{
|
||||
setDelay($device, $this->delay, $this->timeUnit, "state", "OFF", true);
|
||||
setDelay($deviceTarget, $this->delay, $this->timeUnit, "state", "OFF", true);
|
||||
}
|
||||
}elseif ($value <= $this->luminance_min and (getValue(RDC_SALON_MVMT, "occupancy") == ON OR getValue(RDC_SALON_MVMT2,"occupancy") == ON))
|
||||
{
|
||||
logger(DEBUG, _("illuminance < min and movement detected"), __FILE__ . ":" . __LINE__);
|
||||
$this->send("ON", null, AUTO);
|
||||
$this->send($deviceTarget, "ON", null, AUTO);
|
||||
}
|
||||
break;
|
||||
}
|
||||
logger (INFO, sprintf(_("%s: notification received from MQTT from %s => parameter: %s value: %s"), $this->hookName, $device->friendlyName, $param, bool2string($value)), __FILE__ . ":" . __LINE__);
|
||||
}
|
||||
|
||||
private function send($state, $delayState = false, $method = MANUAL)
|
||||
private function send(&$deviceTarget, $state, $delayState = false, $method = MANUAL)
|
||||
{
|
||||
global $indexDevices;
|
||||
$device = & $indexDevices[RDC_SALON_ECLAIRAGE_PANNEAU];
|
||||
|
||||
$msg = array("state" => $state);
|
||||
if ($device->state["value"] != $state)
|
||||
if ($deviceTarget->properties["state"]["value"] != $state)
|
||||
{
|
||||
logger(INFO, sprintf(_("publishing message: %s to %s"), json_encode($msg), $device->friendlyName), __FILE__ . ":" . __LINE__);
|
||||
$device->payload = $msg;
|
||||
$device->set();
|
||||
$device->method = $method;
|
||||
logger(INFO, sprintf(_("publishing message: %s to %s"), json_encode($msg), $deviceTarget->friendlyName), __FILE__ . ":" . __LINE__);
|
||||
$deviceTarget->payload = $msg;
|
||||
$deviceTarget->set();
|
||||
$deviceTarget->method = $method;
|
||||
}else
|
||||
{
|
||||
logger(INFO, sprintf(_("not publishing message: %s to %s, already set"), json_encode($msg), $device->friendlyName), __FILE__ . ":" . __LINE__);
|
||||
logger(INFO, sprintf(_("not publishing message: %s to %s, already set"), json_encode($msg), $deviceTarget->friendlyName), __FILE__ . ":" . __LINE__);
|
||||
}
|
||||
//echo 'delaystate = ' . var_dump($delayState);
|
||||
if ($delayState !== false) setDelay($device, $this->delay, $this->timeUnit, "state", $delayState, true);
|
||||
if ($delayState !== false) setDelay($deviceTarget, $this->delay, $this->timeUnit, "state", $delayState, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user