debugage
This commit is contained in:
@ -12,7 +12,7 @@ class etage_plan_travail_eclairage extends hook
|
||||
// $device -> calling device
|
||||
// $property -> property of the device (given by mqtt)
|
||||
// $value -> value of the property
|
||||
public function callBack(&$device, $property, $value)
|
||||
public function callBack($device, $property, $value)
|
||||
{
|
||||
// here your code
|
||||
if($value == "ON") // ON
|
||||
|
@ -19,38 +19,40 @@ class rdc_chambre_eclairage extends hook
|
||||
// $device -> calling device
|
||||
// $property -> property of the device (given by mqtt)
|
||||
// $value -> value of the property
|
||||
public function callBack(&$device, $property, $value)
|
||||
public function callBack($device, $property, $value)
|
||||
{
|
||||
global $devices, $indexDevices;
|
||||
$lux = $indexDevices[RDC_CHAMBRE_LUMINOSITE]->illuminance_lux;
|
||||
$lux = $indexDevices[RDC_CHAMBRE_LUMINOSITE]->properties["illuminance_lux"];
|
||||
$targetAmbiance = $indexDevices[RDC_CHAMBRE_AMBIANCE];
|
||||
$targetEclairage = $indexDevices[RDC_CHAMBRE_ECLAIRAGE];
|
||||
|
||||
if ($property == "occupancy" and $value == "ON")
|
||||
{
|
||||
$this->send(RDC_CHAMBRE_AMBIANCE, "ON", "OFF", AUTO);
|
||||
$this->send($targetAmbiance, "ON", "OFF", AUTO);
|
||||
}elseif ($property == "contact" and $value = true and getValue(RDC_CHAMBRE_ECLAIRAGE, "state_l1") == "OFF")
|
||||
{
|
||||
$this->send(RDC_CHAMBRE_ECLAIRAGE, "ON", "OFF", AUTO);
|
||||
$this->send($targetEclairage, "ON", "OFF", AUTO);
|
||||
}
|
||||
logger (INFO, sprintf(_("%s: notification received from MQTT from %s => parameter: %s value: %s"), $this->hookName, $device->friendlyName, $property, bool2string($value)), __FILE__ . ":" . __LINE__);
|
||||
}
|
||||
|
||||
private function send($device, $state, $delayState = false, $method = MANUAL)
|
||||
private function send($deviceObject, $state, $delayState = false, $method = MANUAL)
|
||||
{
|
||||
global $devices, $indexDevices;
|
||||
$device = &$indexDevices[$device];
|
||||
$msg = array("state" => $state);
|
||||
if ($device->state["value"] != $state)
|
||||
if ($deviceObject->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), $deviceObject->friendlyName), __FILE__ . ":" . __LINE__);
|
||||
$deviceObject->payload = $msg;
|
||||
$deviceObject->set();
|
||||
$deviceObject->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), $deviceObject->friendlyName), __FILE__ . ":" . __LINE__);
|
||||
|
||||
}
|
||||
//echo 'delaystate = ' . var_dump($delayState);
|
||||
if ($delayState !== false) setDelay($device, $this->delay, $this->timeUnit, "state", $delayState, true);
|
||||
if ($delayState !== false) setDelay($deviceObject, $this->delay, $this->timeUnit, "state", $delayState, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -15,9 +15,8 @@ class alerte_intrusion extends hook
|
||||
public $timeUnit = "minute"; // unit of time for delay, second, minute, day, week, month, year
|
||||
|
||||
// callback fonction. Is called with these 4 parameters
|
||||
public function callBack(&$device, $param, $value)
|
||||
public function callBack($device, $param, $value)
|
||||
{
|
||||
global $devices, $indexDevices;
|
||||
switch($param)
|
||||
{
|
||||
case "contact":
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -26,14 +26,16 @@ class rdc_sdb_eclairage extends hook
|
||||
// callback fonction. Is called with these 3 parameters
|
||||
public function callBack(&$device, $property, $value)
|
||||
{
|
||||
global $devices, $indexDevices;
|
||||
global $indexDevices;
|
||||
//var_dump($value);
|
||||
$deviceTarget = $indexDevices[RDC_SDB_WC_ECLAIRAGE];
|
||||
|
||||
switch($property)
|
||||
{
|
||||
case "occupancy":
|
||||
if ($value == ON)
|
||||
{
|
||||
if (getValue(RDC_SDB_WC_ECLAIRAGE, "state_l1") != "ON")
|
||||
if (getValue($deviceTarget->ieeeAddress, "state_l1") != "ON")
|
||||
{
|
||||
$this->send("ON");
|
||||
}
|
||||
@ -42,13 +44,13 @@ class rdc_sdb_eclairage extends hook
|
||||
}
|
||||
break;
|
||||
case "state_l1":
|
||||
if ($value == ON)
|
||||
if ($value == "ON")
|
||||
{
|
||||
setDelay($indexDevices[RDC_SDB_WC_ECLAIRAGE], $this->delayManual, $this->timeUnit, "state_l1", "OFF", true);
|
||||
setDelay($deviceTarget, $this->delay, $this->timeUnit, "state_l1", "OFF", true);
|
||||
$device->method = MANUAL;
|
||||
}elseif ($value = OFF)
|
||||
}elseif ($value = "OFF")
|
||||
{
|
||||
removeEvent($indexDevices[RDC_SDB_WC_ECLAIRAGE], "state_l1", "OFF");
|
||||
removeEvent($deviceTarget, "state_l1", "OFF");
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -57,13 +59,12 @@ class rdc_sdb_eclairage extends hook
|
||||
|
||||
private function send($state)
|
||||
{
|
||||
global $devices, $indexDevices;
|
||||
global $indexDevices;
|
||||
$msg = array("state_l1" => $state);
|
||||
$device = & $indexDevices[RDC_SDB_WC_ECLAIRAGE];
|
||||
$device = &$indexDevices[RDC_SDB_WC_ECLAIRAGE];
|
||||
logger(INFO, sprintf(_("publishing message: %s to %s"), $state, $device->friendlyName), __FILE__ . ":" . __LINE__);
|
||||
$device->payload = $msg;
|
||||
$device->set(null);
|
||||
|
||||
}
|
||||
}
|
||||
$hooks["rdc_sdb_eclairage"] = new rdc_sdb_eclairage();
|
||||
|
@ -11,9 +11,9 @@ class rdc_wc_eclairage extends hook
|
||||
public $timeUnit = "minute"; // unit of time for delay, second, minute, day, week, month, year
|
||||
|
||||
// callback fonction. Is called with these 4 parameters
|
||||
public function callBack(&$device, $property, $value)
|
||||
public function callBack($device, $property, $value)
|
||||
{
|
||||
global $devices, $indexDevices;
|
||||
global $indexDevices;
|
||||
//var_dump($value);
|
||||
switch($property)
|
||||
{
|
||||
|
Reference in New Issue
Block a user