1
0

récupération après crash

This commit is contained in:
2022-12-05 12:23:43 +01:00
parent 559039b5e3
commit a27db71327
22 changed files with 300 additions and 147 deletions

View File

@@ -9,9 +9,9 @@ class rdc_sdb_eclairage extends hook
// public $active = true;
//public $initlialized = false;
public $delay = 3; // amount of time in $timeunit
public $delayManual = 20; // amount of time in $timeunit for manual mode
public $timeUnit = "minute"; // unit of time for delay, second, minute, day, week, month, year
//public $delay = 3; // amount of time in $timeunit
public $delayManual = 2; // amount of time in $timeunit for manual mode
public $timeUnit = "hour"; // unit of time for delay, second, minute, day, week, month, year
// list of devices we are listening to
// devicelist[$ieeAddress][0] => property to watch
@@ -45,42 +45,42 @@ class rdc_sdb_eclairage extends hook
$deviceTarget = &$indexDevices[RDC_SDB_WC_ECLAIRAGE];
logger(DEBUG, "Callback : " . $this->hookName, __FILE__ . ":" . __LINE__);
$method = $deviceTarget->properties["state_l1"]["method"];
logger(DEBUG, "Method is " . $method, __FILE__ . ":" . __LINE__);
switch($property)
{
case "occupancy":
logger(DEBUG, _("CASE: occupancy"), __FILE__ . ":" . __LINE__);
if ($value == ON)
if ($value === ON)
{
if($method == IDLE)
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");
//removeEvent($deviceTarget, "state", "OFF");
}
}elseif (!testActionneurs($this->actionneurs))
}elseif ((testActionneurs($this->actionneurs) == 0) and ($method == AUTO))
{
logger(DEBUG, _("Actionneurs are all false"), __FILE__ . ":" . __LINE__);
$this->send("OFF", IDLE);
removeEvent($deviceTarget, "state", "OFF");
//removeEvent($deviceTarget, "state", "OFF");
}
break;
case "state_l1":
logger(DEBUG, _("CASE: state_l1"), __FILE__ . ":" . __LINE__);
if ($value == "ON")
{
if ($method == IDLE)
if ($method === IDLE)
{
logger(DEBUG, _("State_l1 is IDLE"), __FILE__ . ":" . __LINE__);
removeEvent($deviceTarget, "state_l1", "OFF");
//removeEvent($deviceTarget, "state_l1", "OFF");
$deviceTarget->properties["state_l1"]["method"] = MANUAL;
//setDelay($deviceTarget, $this->delayManual, $this->timeUnit, "state_l1", "OFF", true, IDLE);
setDelay($deviceTarget, $this->delayManual, $this->timeUnit, "state_l1", "OFF", true, IDLE);
}
}elseif ($value == "OFF" and $method == MANUAL)
}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;
@@ -93,17 +93,17 @@ class rdc_sdb_eclairage extends hook
}
}
private function send($state, $method)
public function send($state, $method)
{
global $indexDevices;
$device = &$indexDevices[RDC_SDB_WC_ECLAIRAGE];
$device->properties["state_l1"]["method"] = $method;
//$device->properties["state_l1"]["method"] = $method;
logger(DEBUG, "method = " . $device->properties["state_l1"]["method"], __FILE__ . ":" . __LINE__);
$msg = array("state_l1" => $state);
$device->payload = $msg;
$device->set("state_l1");
$device->set("state_l1", $method);
logger(INFO, sprintf(_("publishing message: %s to %s"), $state, $device->friendlyName), __FILE__ . ":" . __LINE__);
}
}
$hooks["rdc_sdb_eclairage"] = new rdc_sdb_eclairage();