1
0

debuggage

This commit is contained in:
2022-06-20 10:34:55 +02:00
parent da3f4ab51f
commit 58812c442f
13 changed files with 130 additions and 87 deletions

View File

@ -17,12 +17,16 @@ class rdc_sdb_eclairage extends hook
// devicelist[$ieeAddress][0] => property to watch
// devicelist[$ieeAddress][1] => initialized = true
protected $devicelist = array(
//RDC_SDB_DOUCHE_MVMT => "occupancy",
RDC_SDB_DOUCHE_MVMT => "occupancy",
RDC_SDB_PLAFOND_MVMT => "occupancy",
RDC_SDB_MVMT => "occupancy",
RDC_SDB_WC_ECLAIRAGE => "state_l1"
);
protected $actionneurs = array(
array(RDC_SDB_DOUCHE_MVMT, "occupancy", 1),
array(RDC_SDB_PLAFOND_MVMT, "occupancy", 1),
array(RDC_SDB_MVMT, "occupancy", 1)
);
// callback fonction. Is called with these 3 parameters
public function callBack(&$device, $property, $value)
{
@ -36,42 +40,40 @@ class rdc_sdb_eclairage extends hook
{
case "occupancy":
logger(DEBUG, _("CASE: occupancy"), __FILE__ . ":" . __LINE__);
if ($value == ON )
if ($value == ON)
{
$this->send("ON");
$deviceTarget->properties["state_l1"]["method"] = AUTO;
}else
{
//$delay = $this->delay;
//setDelay($deviceTarget, $delay, $this->timeUnit, "state_l1", "OFF", true, IDLE);
if ($deviceTarget->properties["state_l1"]["method"] != AUTO)
if($deviceTarget->properties["state_l1"]["method"] == IDLE)
{
$delay = $this->delayManual;
$deviceTarget->properties["state_l1"]["method"] = MANUAL;
}else
{
$delay = $this->delay;
$deviceTarget->properties["state_l1"]["method"] = MANUAL;
}
setDelay($deviceTarget, $delay, $this->timeUnit, "state_l1", "OFF", true, IDLE);
}
logger(DEBUG, _("lighting with method auto"), __FILE__ . ":" . __LINE__);
//$deviceTarget->properties["state_l1"]["method"] = AUTO;
$this->send("ON", AUTO);
}
}elseif (testActionneurs($this->actionneurs))
{
logger(DEBUG, _("Actionneurs are all false"), __FILE__ . ":" . __LINE__);
setDelay($deviceTarget, $this->delay, $this->timeUnit, "state_l1", "OFF", true, IDLE);
}
break;
case "state_l1":
logger(DEBUG, _("CASE: state_l1"), __FILE__ . ":" . __LINE__);
/*if ($value == "ON")
if ($value == "ON")
{
}else*/
if ($value == "OFF")
if ($deviceTarget->properties["state_l1"]["method"] == IDLE)
{
logger(DEBUG, _("State_l1 is IDLE"), __FILE__ . ":" . __LINE__);
$deviceTarget->properties["state_l1"]["method"] = MANUAL;
setDelay($deviceTarget, $this->delayManual, $this->timeUnit, "state_l1", "OFF", true, IDLE);
}
}elseif ($value == "OFF")
{
removeEvent($deviceTarget, "state_l1", "OFF");
removeEvent($deviceTarget, "state_l1", "OFF", IDLE);
$deviceTarget->properties["state_l1"]["method"] = IDLE;
logger(DEBUG, _("State_l1 is false light is off and method is ") . $deviceTarget->properties["state_l1"]["method"], __FILE__ . ":" . __LINE__);
}
break;
}
logger (INFO, sprintf(_("%s: notification received from MQTT from %s => parameter: %s value: %s"), $this->hookName, $device->friendlyName, $property, ($value == 0 ? "OFF" : "ON")), __FILE__ . ":" . __LINE__);
logger (INFO, sprintf(_("%s: notification received from MQTT from %s => parameter: %s value: %s"), $this->hookName, $device->friendlyName, $property, bool2string($value)), __FILE__ . ":" . __LINE__);
}else
{
logger (ERROR, RDC_SDB_WC_ECLAIRAGE . _(" does not exists"), __FILE__ . ":" . __LINE__);
@ -79,14 +81,14 @@ class rdc_sdb_eclairage extends hook
}
private function send($state)
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->payload = $msg;
$device->set(null);
$device->set("state_l1", $method);
}
}
$hooks["rdc_sdb_eclairage"] = new rdc_sdb_eclairage();