- changed webserver to apiserver
- added webserver - a lot of debugging - install shell script
This commit is contained in:
@ -9,7 +9,7 @@ class rdc_wc_eclairage extends hook
|
||||
RDC_WC_MVMT => "occupancy"
|
||||
);
|
||||
|
||||
public $delay = 3; // amount of time in $timeunit
|
||||
public $delay = 5; // amount of time in $timeunit
|
||||
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
|
||||
|
||||
@ -17,7 +17,8 @@ class rdc_wc_eclairage extends hook
|
||||
public function callBack(&$device, $property, $value)
|
||||
{
|
||||
global $indexDevices;
|
||||
//var_dump($value);
|
||||
|
||||
$targetDevice = &$indexDevices[RDC_SDB_WC_ECLAIRAGE]; //var_dump($value);
|
||||
logger(DEBUG, "Callback : " . $this->hookName, __FILE__ . ":" . __LINE__);
|
||||
switch($property)
|
||||
{
|
||||
@ -25,38 +26,39 @@ class rdc_wc_eclairage extends hook
|
||||
logger(DEBUG, "CASE: state_l2", __FILE__ . ":" . __LINE__);
|
||||
if ($value == "ON")
|
||||
{
|
||||
if ($device->method == AUTO)
|
||||
if ($targetDevice->properties["state_l1"]["method"] !== AUTO)
|
||||
{
|
||||
setDelay($device, $this->delay, $this->timeUnit, "state_l2", "OFF", true);
|
||||
}else
|
||||
{
|
||||
$device->method = MANUAL;
|
||||
setDelay($device, $this->delayManual, $this->timeUnit, "state_l2", "OFF", true);
|
||||
$targetDevice->properties["state_l1"]["method"] = MANUAL;
|
||||
//setDelay($device, $this->delayManual, $this->timeUnit, "state_l2", "OFF", true);
|
||||
}
|
||||
}elseif ($value == "OFF")
|
||||
{
|
||||
removeEvent($device, "state_l2", "OFF");
|
||||
$device->method = null;
|
||||
removeEvent($device, "state_l2", "OFF", IDLE);
|
||||
}
|
||||
break;
|
||||
case "occupancy":
|
||||
logger(DEBUG, "CASE: occupancy", __FILE__ . ":" . __LINE__);
|
||||
if ($value == true)
|
||||
{
|
||||
$device->method = AUTO;
|
||||
$this->send("ON");
|
||||
$targetDevice->properties["state_l2"]["method"] = AUTO;
|
||||
//setDelay($device, $this->delay, $this->timeUnit, "state_l2", "OFF", true,IDLE);
|
||||
$this->send($targetDevice, "ON");
|
||||
}elseif ($targetDevice->properties["state_l2"]["method"] != MANUAL)
|
||||
{
|
||||
$targetDevice->properties["state_l2"]["method"] = IDLE;
|
||||
$this->send($targetDevice, "OFF");
|
||||
}
|
||||
}
|
||||
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($state)
|
||||
private function send($targetDevice, $state)
|
||||
{
|
||||
global $indexDevices;
|
||||
$deviceObject = $indexDevices[RDC_SDB_WC_ECLAIRAGE];
|
||||
|
||||
$msg = array("state_l2" => $state);
|
||||
logger(INFO, sprintf(_("publishing message: %s to %s"), json_encode($msg), $deviceObject->friendlyName), __FILE__ . ":" . __LINE__);
|
||||
$deviceObject->payload = $msg;
|
||||
$deviceObject->set(null);
|
||||
logger(INFO, sprintf(_("publishing message: %s to %s"), json_encode($msg), $targetDevice->friendlyName), __FILE__ . ":" . __LINE__);
|
||||
$targetDevice->payload = $msg;
|
||||
$targetDevice->set(null);
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user