1
0

debugging

This commit is contained in:
2022-01-29 19:58:01 +01:00
parent 425107cec7
commit 719a45fa4e
8 changed files with 41 additions and 29 deletions

View File

@ -3,14 +3,14 @@
class rdc_chambre_eclairage extends hook
{
public $hookName = "rdc_chambre_eclairage";
public $active = false; //enable/disable hook (true => enabled)
public $active = true; //enable/disable hook (true => enabled)
public $delay = 5; // amount of time in $timeunit
public $timeUnit = "minute"; // unit of time for delay, second, minute, hour, day, week, month, year
public $luminance_min = 60;
public $luminance_max = 3000;
protected $devicelist = array(
"RDC_CHAMBRE_AMBIANCE" => array("state", false),
"RDC_CHAMBRE_ECLAIRAGE" => array("state_l1", false),
"RDC_CHAMBRE_AMBIANCE" => array("state", false), // "ON"/"OFF"
"RDC_CHAMBRE_ECLAIRAGE" => array("state_l1", false), // "ON"/"OFF"
"RDC_CHAMBRE_MVMT" => array("occupancy", false),
"RDC_CHAMBRE_ARMOIRE_GAUCHE" => array("contact", false)
);
@ -25,7 +25,10 @@ class rdc_chambre_eclairage extends hook
$lux = $indexDevices[RDC_CHAMBRE_LUMINOSITE]->illuminance_lux;
if ($property == "occupancy" and $value == "ON")
{
$this->send(RDC_CHAMBRE_LUMINOSITE, "ON", "OFF", AUTO);
$this->send(RDC_CHAMBRE_AMBIANCE, "ON", "OFF", AUTO);
}elseif ($property == "contact" and $value = true and getValue(RDC_CHAMBRE_ECLAIRAGE) == "OFF")
{
$this->send(RDC_CHAMBRE_ECLAIRAGE, "ON", "OFF", AUTO);
}
logger (INFO, sprintf(_("%s: notification received from MQTT from %s => parameter: %s value: %s"), $this->hookName, $device->friendlyName, $property, $value), __FILE__ . ":" . __LINE__);
}

View File

@ -13,7 +13,7 @@ class rdc_salon_eclairage extends hook
public $delay = 3; // amount of time in $timeunit
public $timeUnit = "minute"; // unit of time for delay, second, minute, hour, day, week, month, year
public $luminance_min = 60;
public $luminance_min = 70;
public $luminance_max = 3000;
@ -26,7 +26,7 @@ class rdc_salon_eclairage extends hook
{
case "occupancy":
logger(DEBUG, _("CASE: Occupancy => ") . bool2string($value), __FILE__ . ":" . __LINE__);
//print_r($indexDevices[RDC_SALON_LUMINOSITE]);
//print_r(getValue(RDC_SALON_LUMINOSITE, "illuminance_lux"));
if ($value == ON and getValue(RDC_SALON_LUMINOSITE, "illuminance_lux") <= $this->luminance_min)
{
logger(DEBUG, _("setting to ON"), __FILE__ . ":" . __LINE__);
@ -35,23 +35,26 @@ class rdc_salon_eclairage extends hook
}elseif ($value == OFF)
{
logger(DEBUG, _("Value is OFF"), __FILE__ . ":" . __LINE__);
if (getValue(RDC_SALON_MVMT, "occupancy") == OFF)
if (getValue(RDC_SALON_MVMT, "occupancy") == OFF and (getValue(RDC_SALON_MVMT2, "occupancy") == OFF))
{
if (getValue(RDC_SALON_MVMT2, "occupancy") == OFF)
{
logger(DEBUG, _("Setting to OFF"), __FILE__ . ":" . __LINE__);
setDelay($indexDevices[RDC_SALON_ECLAIRAGE_PANNEAU], $this->delay, $this->timeUnit, "state", "OFF", true);
//$this->send("ON", "OFF", AUTO);
}
logger(DEBUG, _("Setting to OFF"), __FILE__ . ":" . __LINE__);
setDelay($indexDevices[RDC_SALON_ECLAIRAGE_PANNEAU], $this->delay, $this->timeUnit, "state", "OFF", true);
//$this->send("ON", "OFF", AUTO);
}
}
break;
case "contact":
logger(DEBUG, _("CASE: Contact Door"), __FILE__ . ":" . __LINE__);
if ($value == false and getValue(RDC_SALON_LUMINOSITE, "illuminance_lux") <= $this->luminance_min)
if ($value == false and getValue(RDC_SALON_LUMINOSITE, "illuminance_lux") <= $this->luminance_min and getValue(RDC_SALON_ECLAIRAGE_PANNEAU, "state") == "OFF")
{
logger(DEBUG, _("Door is open and illumance < min"), __FILE__ . ":" . __LINE__);
$this->send("ON", "OFF", AUTO);
if (getValue(RDC_SALON_MVMT, "occupancy") == ON or getValue(RDC_SALON_MVMT2, "occupancy") == ON)
{
$this->send("ON", null, AUTO);
}else
{
$this->send("ON", "OFF", AUTO);
}
}
break;
case "illuminance_lux":
@ -60,7 +63,8 @@ class rdc_salon_eclairage extends hook
{
logger(DEBUG, _("illuminace is > to max"), __FILE__ . ":" . __LINE__);
//$this->send("OFF", null, AUTO);
removeEvent($indexDevices[RDC_SALON_ECLAIRAGE_PANNEAU], "state", "OFF");
//removeEvent($indexDevices[RDC_SALON_ECLAIRAGE_PANNEAU], "state", "OFF");
setDelay($indexDevices[RDC_SALON_ECLAIRAGE_PANNEAU], $this->delay, $this->timeUnit, "state", "OFF", true);
}elseif ($value <= $this->luminance_min and (getValue(RDC_SALON_MVMT, "occupancy") == ON OR getValue(RDC_SALON_MVMT2,"occupancy") == ON))
{
logger(DEBUG, _("illuminance < min and movement detected"), __FILE__ . ":" . __LINE__);

View File

@ -23,7 +23,7 @@ class rdc_sdb_eclairage extends hook
RDC_SDB_WC_ECLAIRAGE => array("state_l1", false)
);
// callback fonction. Is called with these 4 parameters
// callback fonction. Is called with these 3 parameters
public function callBack(&$device, $property, $value)
{
global $devices, $indexDevices;
@ -33,19 +33,22 @@ class rdc_sdb_eclairage extends hook
case "occupancy":
if ($value == ON)
{
$this->send("ON");
setDelay($device, $this->delay, $this->timeUnit, "state_l1", "OFF", true);
if (getValue(RDC_SDB_WC_ECLAIRAGE, "state_l1") != "ON")
{
$this->send("ON");
}
//setDelay($indexDevices[RDC_SDB_WC_ECLAIRAGE], $this->delay, $this->timeUnit, "state_l1", "OFF", true);
$device->method = AUTO;
}
break;
case "state_l1":
if ($value == ON)
{
setDelay($device, $this->delayManual, $this->timeUnit, "state_l1", "OFF", true);
setDelay($indexDevices[RDC_SDB_WC_ECLAIRAGE], $this->delayManual, $this->timeUnit, "state_l1", "OFF", true);
$device->method = MANUAL;
}elseif ($value = OFF)
{
deleteEvent(searchEvent($device, "state_l1", "OFF"));
removeEvent($indexDevices[RDC_SDB_WC_ECLAIRAGE], "state_l1", "OFF");
}
break;
}