debugging hooks and events
This commit is contained in:
@@ -33,14 +33,14 @@ class availability
|
||||
if ($device->availability != $value)
|
||||
{
|
||||
//echo "==========>>>>>> Availability $value" . EOL;
|
||||
if (!empty($device->availability))
|
||||
{
|
||||
$log = WARNING;
|
||||
}else
|
||||
{
|
||||
$log = INFO;
|
||||
}
|
||||
$device->availability = $value;
|
||||
//if (!empty($device->availability))
|
||||
//{
|
||||
$log = ALERT;
|
||||
//}else
|
||||
//{
|
||||
// $log = INFO;
|
||||
//}
|
||||
//$device->availability = $value;
|
||||
logger($log, sprintf(_("Device: %s/%s is %s"), $device->topic, $device->friendlyName, $value));
|
||||
}
|
||||
break;
|
||||
|
@@ -11,7 +11,7 @@ class rdc_salon_eclairage extends hook
|
||||
RDC_SALON_LUMINOSITE => array("illuminance_lux", false)
|
||||
);
|
||||
|
||||
public $delay = 3; // amount of time in $timeunit
|
||||
public $delay = 5; // amount of time in $timeunit
|
||||
public $timeUnit = "minute"; // unit of time for delay, second, minute, day, week, month, year
|
||||
public $luminance_min = 60;
|
||||
public $luminance_max = 3000;
|
||||
@@ -26,15 +26,15 @@ class rdc_salon_eclairage extends hook
|
||||
{
|
||||
case "occupancy":
|
||||
//print_r($indexDevices[RDC_SALON_LUMINOSITE]);
|
||||
if ($value == 1 and $indexDevices[RDC_SALON_LUMINOSITE]->illuminance_lux["value"] <= $this->luminance_min)
|
||||
if ($value == ON and $indexDevices[RDC_SALON_LUMINOSITE]->illuminance_lux["value"] <= $this->luminance_min)
|
||||
{
|
||||
$this->send("ON");
|
||||
$this->send("ON", "OFF", AUTO);
|
||||
}
|
||||
break;
|
||||
case "contact":
|
||||
if ($value == false and $indexDevices[RDC_SALON_LUMINOSITE]->illuminance_lux["value"] <= $this->luminance_min)
|
||||
{
|
||||
$this->send("ON");
|
||||
$this->send("ON", "OFF", AUTO);
|
||||
}
|
||||
break;
|
||||
case "illuminance_lux":
|
||||
@@ -47,7 +47,7 @@ class rdc_salon_eclairage extends hook
|
||||
logger (INFO, sprintf(_("%s: notification received from MQTT from %s => parameter: %s value: %s"), $this->hookName, $device->friendlyName, $param, bool2string($value)));
|
||||
}
|
||||
|
||||
private function send($state)
|
||||
private function send($state, $delayState = false, $method = MANUAL)
|
||||
{
|
||||
global $devices, $indexDevices;
|
||||
$device = & $indexDevices[RDC_SALON_ECLAIRAGE_PANNEAU];
|
||||
@@ -57,12 +57,14 @@ class rdc_salon_eclairage extends hook
|
||||
logger(INFO, sprintf(_("publishing message: %s to %s"), json_encode($msg), $device->friendlyName));
|
||||
$device->payload = $msg;
|
||||
$device->set();
|
||||
setDelay($device, $this->delay, $this->timeUnit, "state", "OFF", true);
|
||||
$device->method = $method;
|
||||
}else
|
||||
{
|
||||
logger(INFO, sprintf(_("not publishing message: %s to %s, already set"), json_encode($msg), $device->friendlyName));
|
||||
}
|
||||
|
||||
}
|
||||
//echo 'delaystate = ' . var_dump($delayState);
|
||||
if ($delayState !== false) setDelay($device, $this->delay, $this->timeUnit, "state", $delayState, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -9,7 +9,7 @@ class rdc_sdb_eclairage extends hook
|
||||
//public $initlialized = false;
|
||||
|
||||
public $delay = 3; // amount of time in $timeunit
|
||||
public $delayManual = 10; // amount of time in $timeunit for manual mode
|
||||
public $delayManual = 15; // amount of time in $timeunit for manual mode
|
||||
public $timeUnit = "minute"; // unit of time for delay, second, minute, day, week, month, year
|
||||
// list of devices we are listening to
|
||||
|
||||
@@ -26,6 +26,7 @@ class rdc_sdb_eclairage extends hook
|
||||
public function callBack(&$device, $property, $value)
|
||||
{
|
||||
global $devices, $indexDevices;
|
||||
var_dump($value);
|
||||
switch($property)
|
||||
{
|
||||
case "occupancy":
|
||||
@@ -47,14 +48,14 @@ class rdc_sdb_eclairage extends hook
|
||||
}
|
||||
break;
|
||||
}
|
||||
logger (INFO, sprintf(_("%s: notification received from MQTT from %s => parameter: %s value: %s"), $this->hookName, $device->friendlyName, $property, bool2string($value)));
|
||||
logger (INFO, sprintf(_("%s: notification received from MQTT from %s => parameter: %s value: %s"), $this->hookName, $device->friendlyName, $property, ($value == 0 ? "OFF" : "ON")));
|
||||
}
|
||||
|
||||
private function send($state)
|
||||
{
|
||||
global $devices, $indexDevices;
|
||||
$msg = array("state_l1" => $state);
|
||||
$device = & $indexDevices["0x00158d0005c1a998"];
|
||||
$device = & $indexDevices[RDC_SDB_WC_ECLAIRAGE];
|
||||
logger(INFO, sprintf(_("publishing message: %s to %s"), $msg, $device->friendlyName));
|
||||
$device->payload = $msg;
|
||||
$device->set(null);
|
||||
|
@@ -7,27 +7,28 @@ class rdc_wc_eclairage extends hook
|
||||
protected $devicelist = array(RDC_SDB_WC_ECLAIRAGE => array("state_l2", false));
|
||||
|
||||
public $delay = 3; // amount of time in $timeunit
|
||||
public $delayManual = 10; // amount of time in $timeunit for manual mode
|
||||
public $delayManual = 8; // amount of time in $timeunit for manual mode
|
||||
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)
|
||||
{
|
||||
global $devices, $indexDevices;
|
||||
var_dump($value);
|
||||
switch($property)
|
||||
{
|
||||
case "state_l2":
|
||||
if ($value == ON)
|
||||
if ($value == "ON")
|
||||
{
|
||||
setDelay($device, $this->delayManual, $this->timeUnit, "state_l2", "OFF", true);
|
||||
$device->method = MANUAL;
|
||||
}elseif ($value = OFF)
|
||||
}elseif ($value = "OFF")
|
||||
{
|
||||
deleteEvent(searchEvent($device, "state_l2", "OFF"));
|
||||
}
|
||||
break;
|
||||
}
|
||||
logger (INFO, sprintf(_("%s: notification received from MQTT from %s => parameter: %s value: %s"), $this->hookName, $device->friendlyName, $property, bool2string($value)));
|
||||
logger (INFO, sprintf(_("%s: notification received from MQTT from %s => parameter: %s value: %s"), $this->hookName, $device->friendlyName, $property, $value));
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user