added templates
This commit is contained in:
@@ -38,67 +38,72 @@ class rdc_sdb_eclairage extends hook
|
||||
{
|
||||
global $indexDevices;
|
||||
//var_dump($value);
|
||||
$deviceTarget = &$indexDevices[RDC_SDB_WC_ECLAIRAGE];
|
||||
if ($deviceTarget !== null)
|
||||
if ($this->active)
|
||||
{
|
||||
logger(DEBUG, "Callback : " . $this->hookName, __FILE__ . ":" . __LINE__);
|
||||
switch($property)
|
||||
if (array_key_exists(RDC_SDB_WC_ECLAIRAGE, $indexDevices))
|
||||
{
|
||||
case "occupancy":
|
||||
$method = $deviceTarget->properties["state_l1"]["method"];
|
||||
logger(DEBUG, _("CASE: occupancy"), __FILE__ . ":" . __LINE__);
|
||||
if ($value == ON)
|
||||
{
|
||||
if($method == IDLE)
|
||||
$deviceTarget = &$indexDevices[RDC_SDB_WC_ECLAIRAGE];
|
||||
logger(DEBUG, "Callback : " . $this->hookName, __FILE__ . ":" . __LINE__);
|
||||
$method = $deviceTarget->properties["state_l1"]["method"];
|
||||
switch($property)
|
||||
{
|
||||
case "occupancy":
|
||||
logger(DEBUG, _("CASE: occupancy"), __FILE__ . ":" . __LINE__);
|
||||
if ($value == ON)
|
||||
{
|
||||
logger(DEBUG, _("lighting with method auto"), __FILE__ . ":" . __LINE__);
|
||||
//$deviceTarget->properties["state_l1"]["method"] = AUTO;
|
||||
$this->send("ON", AUTO);
|
||||
if($method == IDLE)
|
||||
{
|
||||
logger(DEBUG, _("lighting with method auto"), __FILE__ . ":" . __LINE__);
|
||||
//$deviceTarget->properties["state_l1"]["method"] = AUTO;
|
||||
$this->send("ON", AUTO);
|
||||
removeEvent($deviceTarget, "state", "OFF");
|
||||
}
|
||||
}elseif (!testActionneurs($this->actionneurs))
|
||||
{
|
||||
logger(DEBUG, _("Actionneurs are all false"), __FILE__ . ":" . __LINE__);
|
||||
$this->send("OFF", IDLE);
|
||||
removeEvent($deviceTarget, "state", "OFF");
|
||||
}
|
||||
}elseif (!testActionneurs($this->actionneurs))
|
||||
{
|
||||
logger(DEBUG, _("Actionneurs are all false"), __FILE__ . ":" . __LINE__);
|
||||
$this->send("OFF", IDLE);
|
||||
}
|
||||
break;
|
||||
case "state_l1":
|
||||
$method = $deviceTarget->properties["state_l1"]["method"];
|
||||
|
||||
logger(DEBUG, _("CASE: state_l1"), __FILE__ . ":" . __LINE__);
|
||||
if ($value == "ON")
|
||||
{
|
||||
if ($method == IDLE)
|
||||
break;
|
||||
case "state_l1":
|
||||
logger(DEBUG, _("CASE: state_l1"), __FILE__ . ":" . __LINE__);
|
||||
if ($value == "ON")
|
||||
{
|
||||
logger(DEBUG, _("State_l1 is IDLE"), __FILE__ . ":" . __LINE__);
|
||||
if ($method == IDLE)
|
||||
{
|
||||
logger(DEBUG, _("State_l1 is IDLE"), __FILE__ . ":" . __LINE__);
|
||||
removeEvent($deviceTarget, "state_l1", "OFF");
|
||||
$deviceTarget->properties["state_l1"]["method"] = MANUAL;
|
||||
//setDelay($deviceTarget, $this->delayManual, $this->timeUnit, "state_l1", "OFF", true, IDLE);
|
||||
}
|
||||
}elseif ($value == "OFF" and $method == MANUAL)
|
||||
{
|
||||
$deviceTarget->properties["state_l1"]["method"] = IDLE;
|
||||
removeEvent($deviceTarget, "state_l1", "OFF");
|
||||
$deviceTarget->properties["state_l1"]["method"] = MANUAL;
|
||||
//setDelay($deviceTarget, $this->delayManual, $this->timeUnit, "state_l1", "OFF", true, IDLE);
|
||||
//$deviceTarget->properties["state_l1"]["method"] = IDLE;
|
||||
logger(DEBUG, _("State_l1 is false light is off and method is ") . $method, __FILE__ . ":" . __LINE__);
|
||||
}
|
||||
}elseif ($value == "OFF")
|
||||
{
|
||||
$deviceTarget->properties["state_l1"]["method"] = IDLE;
|
||||
removeEvent($deviceTarget, "state_l1", "OFF");
|
||||
//$deviceTarget->properties["state_l1"]["method"] = IDLE;
|
||||
logger(DEBUG, _("State_l1 is false light is off and method is ") . $method, __FILE__ . ":" . __LINE__);
|
||||
}
|
||||
break;
|
||||
break;
|
||||
}
|
||||
logger (INFO, sprintf(_("%s: notification received from MQTT from %s => parameter: %s value: %s method: %s"), $this->hookName, $device->friendlyName, $property, bool2string($value), $deviceTarget->properties["state_l1"]["method"]), __FILE__ . ":" . __LINE__);
|
||||
}else
|
||||
{
|
||||
logger (ERROR, RDC_SDB_WC_ECLAIRAGE . _(" does not exists"), __FILE__ . ":" . __LINE__);
|
||||
}
|
||||
logger (INFO, sprintf(_("%s: notification received from MQTT from %s => parameter: %s value: %s method: %s"), $this->hookName, $device->friendlyName, $property, bool2string($value), $deviceTarget->properties["state_l1"]["method"]), __FILE__ . ":" . __LINE__);
|
||||
}else
|
||||
{
|
||||
logger (ERROR, RDC_SDB_WC_ECLAIRAGE . _(" does not exists"), __FILE__ . ":" . __LINE__);
|
||||
}
|
||||
}
|
||||
|
||||
private function send($state, $method)
|
||||
{
|
||||
global $indexDevices;
|
||||
$msg = array("state_l1" => $state);
|
||||
|
||||
$device = &$indexDevices[RDC_SDB_WC_ECLAIRAGE];
|
||||
logger(INFO, sprintf(_("publishing message: %s to %s"), $state, $device->friendlyName), __FILE__ . ":" . __LINE__);
|
||||
$device->properties["state_l1"]["method"] = $method;
|
||||
$msg = array("state_l1" => $state);
|
||||
$device->payload = $msg;
|
||||
$device->set("state_l1", $method);
|
||||
$device->set("state_l1");
|
||||
logger(INFO, sprintf(_("publishing message: %s to %s"), $state, $device->friendlyName), __FILE__ . ":" . __LINE__);
|
||||
|
||||
}
|
||||
}
|
||||
$hooks["rdc_sdb_eclairage"] = new rdc_sdb_eclairage();
|
||||
|
Reference in New Issue
Block a user