1
0

debbuging hooks

This commit is contained in:
Daniel Tartavel 2022-09-09 16:53:19 +02:00
parent 7eaaad0911
commit 918a571b5c
7 changed files with 304 additions and 289 deletions

View File

@ -19,6 +19,7 @@ class notificationFreemobile
function send($message, $destinataire=NOTIF_DEFAULT_DEST) function send($message, $destinataire=NOTIF_DEFAULT_DEST)
{ {
logger(DEBUG, _("Function send SMS (with Curl)"), __FILE__ . ":" . __LINE__);
$error = false; $error = false;
if ($this->active === true) if ($this->active === true)
{ {

View File

@ -13,10 +13,18 @@ class etage_temperature_int_ext extends hook
); );
protected $portesList = array( protected $portesList = array(
ENTREE_PORTE => "contact", ETAGE_BUREAU_FENETRE => "contact",
//GARAGE_PORTE => "contact", ETAGE_CHAMBRE_FENETRE => "contact",
RDC_CHAMBRE_BAIE => "contact", ETAGE_SALON_FENETRE => "contact",
RDC_SALON_BAIE => "contact" ETAGE_CUISINE_FENETRE => "contact",
ETAGE_PORTE_FENETRE => "contact"
);
protected $paires = array(
ETAGE_BUREAU_TEMP => ETAGE_BUREAU_FENETRE,
ETAGE_SALON_TEMP => ETAGE_SALON_FENETRE,
ETAGE_SALON_TEMP => ETAGE_PORTE_FENETRE,
ETAGE_CHAMBRE_TEMP => ETAGE_CHAMBRE_FENETRE
); );
function installHooks(&$indexDevices) function installHooks(&$indexDevices)
@ -37,8 +45,6 @@ class etage_temperature_int_ext extends hook
logger(DEBUG, _("etage_temperature_int_ext hook"), null ,$device); logger(DEBUG, _("etage_temperature_int_ext hook"), null ,$device);
if (empty($time)) $time = now(); if (empty($time)) $time = now();
//echo "Time is " . var_dump($time) . EOL;
//echo "minutes since time :" . now()->format("U") - $time->format("U");
if ((now()->format("U") - $time->format("U")) > 300) if ((now()->format("U") - $time->format("U")) > 300)
{ {

View File

@ -71,15 +71,15 @@ class rdc_chambre_eclairage extends hook
{ {
logger(DEBUG, _("CASE: state => value = 'OFF'"), __FILE__ . ":" . __LINE__); logger(DEBUG, _("CASE: state => value = 'OFF'"), __FILE__ . ":" . __LINE__);
$targetAmbiance->properties[$property]["method"] = IDLE; $targetAmbiance->properties[$property]["method"] = IDLE;
removeEvent($targetAmbiance, $property, "OFF", IDLE); removeEvent($targetAmbiance, $property, "OFF");
} }
}elseif ($property == "state_l1") }elseif ($property == "state_l1")
{ {
if ($value == "OFF") if ($value == "OFF")
{ {
logger(DEBUG, _("CASE: state_l1 => value = 'OFF'"), __FILE__ . ":" . __LINE__); logger(DEBUG, _("CASE: state_l1 => value = 'OFF'"), __FILE__ . ":" . __LINE__);
//$targetEclairage->properties[$property]["method"] = IDLE; $targetEclairage->properties[$property]["method"] = IDLE;
removeEvent($targetAmbiance, $property, "OFF", IDLE); removeEvent($targetAmbiance, $property, "OFF");
} }
}elseif ($property == "action") }elseif ($property == "action")
{ {

View File

@ -44,10 +44,9 @@ class rdc_salon_eclairage extends hook
switch($param) switch($param)
{ {
case "presence": case "presence":
logger(INFO, _("CASE: Présence => ") . bool2string($value), __FILE__ . ":" . __LINE__);
case "occupancy": case "occupancy":
$method = $deviceTarget->properties["state"]["method"]; $method = $deviceTarget->properties["state"]["method"];
logger(INFO, _("CASE: Occupancy => ") . bool2string($value), __FILE__ . ":" . __LINE__); logger(INFO, sprintf (_("CASE: %s => "), $param) . bool2string($value), __FILE__ . ":" . __LINE__);
//print_r(getValue(RDC_SALON_LUMINOSITE, "illuminance_lux")); //print_r(getValue(RDC_SALON_LUMINOSITE, "illuminance_lux"));
if ($value == ON and $method == IDLE) if ($value == ON and $method == IDLE)
{ {
@ -60,8 +59,8 @@ class rdc_salon_eclairage extends hook
} }
}else }else
{ {
logger(INFO, _("Value is OFF"), __FILE__ . ":" . __LINE__); logger(INFO, _("Value is OFF and method is ") . $method, __FILE__ . ":" . __LINE__);
if (testActionneurs($this->actionneurs) === false and $method == AUTO) if ((testActionneurs($this->actionneurs) == false) and ($method == AUTO))
//if ((getValue(RDC_SALON_MVMT, "occupancy") == OFF) and (getValue(RDC_SALON_MVMT2, "occupancy") == OFF) and $method == AUTO) //if ((getValue(RDC_SALON_MVMT, "occupancy") == OFF) and (getValue(RDC_SALON_MVMT2, "occupancy") == OFF) and $method == AUTO)
{ {
logger(INFO, _("Setting to OFF"), __FILE__ . ":" . __LINE__); logger(INFO, _("Setting to OFF"), __FILE__ . ":" . __LINE__);

View File

@ -71,23 +71,24 @@ class rdc_sdb_eclairage extends hook
if ($method == IDLE) if ($method == IDLE)
{ {
logger(DEBUG, _("State_l1 is IDLE"), __FILE__ . ":" . __LINE__); logger(DEBUG, _("State_l1 is IDLE"), __FILE__ . ":" . __LINE__);
removeEvent($deviceTarget, "state_l1", "OFF", MANUAL); 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") }elseif ($value == "OFF")
{ {
removeEvent($deviceTarget, "state_l1", "OFF", IDLE); $deviceTarget->properties["state_l1"]["method"] = IDLE;
removeEvent($deviceTarget, "state_l1", "OFF");
//$deviceTarget->properties["state_l1"]["method"] = IDLE; //$deviceTarget->properties["state_l1"]["method"] = IDLE;
logger(DEBUG, _("State_l1 is false light is off and method is ") . $method, __FILE__ . ":" . __LINE__); 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"), $this->hookName, $device->friendlyName, $property, bool2string($value)), __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 }else
{ {
logger (ERROR, RDC_SDB_WC_ECLAIRAGE . _(" does not exists"), __FILE__ . ":" . __LINE__); logger (ERROR, RDC_SDB_WC_ECLAIRAGE . _(" does not exists"), __FILE__ . ":" . __LINE__);
} }
} }
private function send($state, $method) private function send($state, $method)

View File

@ -45,7 +45,6 @@ class rdc_store extends hook
$rafale = 0; $rafale = 0;
$soleil = 0; $soleil = 0;
$storeDevice = $indexDevices[RDC_STORE]; $storeDevice = $indexDevices[RDC_STORE];
//$this->maxLevel = 100;
$r = 100; $r = 100;
$moving = "STOP"; $moving = "STOP";
$store2level = false; $store2level = false;
@ -67,24 +66,6 @@ class rdc_store extends hook
logger(DEBUG, "Motor reversal =" . bool2string($this->motorReversal), __FILE__ . ":" . __LINE__); logger(DEBUG, "Motor reversal =" . bool2string($this->motorReversal), __FILE__ . ":" . __LINE__);
} }
if ($moving == "STOP" or $moving == null)
{
if (array_key_exists("position", $storeDevice->properties))
{
if ($this->motorReversal)
{
$this->storeLevel = $storeDevice->properties["position"]["value"];
}else
{
$this->storeLevel = 100 - $storeDevice->properties["position"]["value"];
}
logger(DEBUG, "storeLevel=" . $this->storeLevel, __FILE__ . ":" . __LINE__);
}else
{
$this->storeLevel = 0;
//return true;
}
if (array_key_exists(METEO, $indexDevices)) if (array_key_exists(METEO, $indexDevices))
{ {
if (array_key_exists("rainin", $indexDevices[METEO]->properties)) if (array_key_exists("rainin", $indexDevices[METEO]->properties))
@ -130,6 +111,32 @@ class rdc_store extends hook
logger(DEBUG, "soleil=" . $soleil, __FILE__ . ":" . __LINE__); logger(DEBUG, "soleil=" . $soleil, __FILE__ . ":" . __LINE__);
} }
} }
if (array_key_exists("position", $storeDevice->properties))
{
if ($this->motorReversal)
{
$this->storeLevel = 100 - $storeDevice->properties["position"]["value"];
}else
{
$this->storeLevel = $storeDevice->properties["position"]["value"];
}
logger(DEBUG, "storeLevel=" . $this->storeLevel, __FILE__ . ":" . __LINE__);
}else
{
$this->storeLevel = 0;
//return true;
}
if (array_key_exists("illuminance_lux", $indexDevices[RDC_FACADE_LUMINOSITE]->properties))
{
$facade_lux = $indexDevices[RDC_FACADE_LUMINOSITE]->properties["illuminance_lux"]["value"];
$facadeLuxMoyen = $mohaDB->moyenne($indexDevices[RDC_FACADE_LUMINOSITE], "illuminance_lux", 5);
if ($facadeLuxMoyen == 0)
{
$facadeLuxMoyen = $facade_lux;
}
logger(DEBUG, "facade_lux=" . $facade_lux . " et facadeLuxMoyen=" . $facadeLuxMoyen, __FILE__ . ":" . __LINE__);
}
if (array_key_exists("illuminance_lux", $indexDevices[RDC_EXTERIEUR_LUMINOSITE]->properties)) if (array_key_exists("illuminance_lux", $indexDevices[RDC_EXTERIEUR_LUMINOSITE]->properties))
{ {
@ -157,7 +164,7 @@ class rdc_store extends hook
{ {
$store2level = $this->storeLevel + 20; $store2level = $this->storeLevel + 20;
} }
}elseif ($exterieurLuxMoyen < 5000 and $salon_lux < 200 and $soleil < 100) }elseif ($exterieurLuxMoyen < 5000 and $salon_lux < 200 and $soleil < 100 and $facadeLuxMoyen < 8000)
{ {
logger(DEBUG, "exterieurLuxMoyen < 5000 and salon_lux < 200 and soleil < 100", __FILE__ . ":" . __LINE__); logger(DEBUG, "exterieurLuxMoyen < 5000 and salon_lux < 200 and soleil < 100", __FILE__ . ":" . __LINE__);
$this->close("Luminosité faible"); $this->close("Luminosité faible");
@ -196,6 +203,7 @@ class rdc_store extends hook
$this->setTo($store2level, AUTO); $this->setTo($store2level, AUTO);
} }
default: default:
break;
} }
logger(DEBUG, "maxLevel = " . $this->maxLevel . ' result => $r = ' . $r, __FILE__ . ":" . __LINE__); logger(DEBUG, "maxLevel = " . $this->maxLevel . ' result => $r = ' . $r, __FILE__ . ":" . __LINE__);
if ($this->storeLevel > $this->maxLevel) if ($this->storeLevel > $this->maxLevel)
@ -212,7 +220,6 @@ class rdc_store extends hook
logger(DEBUG, "store2level <= maxLevel", __FILE__ . ":" . __LINE__); logger(DEBUG, "store2level <= maxLevel", __FILE__ . ":" . __LINE__);
$this->setTo($store2level, AUTO); $this->setTo($store2level, AUTO);
} }
}
}else }else
{ {
logger(DEBUG, _("Store is Moving ") . $moving, __FILE__ . ":" . __LINE__); logger(DEBUG, _("Store is Moving ") . $moving, __FILE__ . ":" . __LINE__);
@ -223,10 +230,6 @@ class rdc_store extends hook
private function setTo($level, $method) private function setTo($level, $method)
{ {
logger(DEBUG, "function 'set' to level : " . $level, __FILE__ . ":" . __LINE__); logger(DEBUG, "function 'set' to level : " . $level, __FILE__ . ":" . __LINE__);
if (!$this->motorReversal)
{
$level = 100 - $level;
}
if ($level <= 100) if ($level <= 100)
{ {
logger(DEBUG, "Open store :" . $level, __FILE__ . ":" . __LINE__); logger(DEBUG, "Open store :" . $level, __FILE__ . ":" . __LINE__);
@ -243,7 +246,7 @@ class rdc_store extends hook
if ($this->storeLevel > 0) if ($this->storeLevel > 0)
{ {
logger(DEBUG, "Close store :" . $reason, __FILE__ . ":" . __LINE__); logger(DEBUG, "Close store :" . $reason, __FILE__ . ":" . __LINE__);
$this->send(100, IDLE); $this->send(0, IDLE);
} }
} }
@ -251,6 +254,8 @@ class rdc_store extends hook
{ {
global $indexDevices; global $indexDevices;
$deviceObject = $indexDevices[RDC_STORE]; $deviceObject = $indexDevices[RDC_STORE];
$level = 100 - $level;
$msg = array("position" => $level); $msg = array("position" => $level);
logger(INFO, sprintf(_("publishing message: %s to %s"), json_encode($msg), $deviceObject->friendlyName), __FILE__ . ":" . __LINE__); logger(INFO, sprintf(_("publishing message: %s to %s"), json_encode($msg), $deviceObject->friendlyName), __FILE__ . ":" . __LINE__);
$deviceObject->payload = $msg; $deviceObject->payload = $msg;
@ -261,4 +266,3 @@ class rdc_store extends hook
$hooks["rdc_store"] = new rdc_store(); $hooks["rdc_store"] = new rdc_store();
?> ?>
print_r($function[0], true)

View File

@ -45,7 +45,6 @@ class rdc_store extends hook
$rafale = 0; $rafale = 0;
$soleil = 0; $soleil = 0;
$storeDevice = $indexDevices[RDC_STORE]; $storeDevice = $indexDevices[RDC_STORE];
//$this->maxLevel = 100;
$r = 100; $r = 100;
$moving = "STOP"; $moving = "STOP";
$store2level = false; $store2level = false;
@ -67,24 +66,6 @@ class rdc_store extends hook
logger(DEBUG, "Motor reversal =" . bool2string($this->motorReversal), __FILE__ . ":" . __LINE__); logger(DEBUG, "Motor reversal =" . bool2string($this->motorReversal), __FILE__ . ":" . __LINE__);
} }
if ($moving == "STOP" or $moving == null)
{
if (array_key_exists("position", $storeDevice->properties))
{
if ($this->motorReversal)
{
$this->storeLevel = $storeDevice->properties["position"]["value"];
}else
{
$this->storeLevel = 100 - $storeDevice->properties["position"]["value"];
}
logger(DEBUG, "storeLevel=" . $this->storeLevel, __FILE__ . ":" . __LINE__);
}else
{
$this->storeLevel = 0;
//return true;
}
if (array_key_exists(METEO, $indexDevices)) if (array_key_exists(METEO, $indexDevices))
{ {
if (array_key_exists("rainin", $indexDevices[METEO]->properties)) if (array_key_exists("rainin", $indexDevices[METEO]->properties))
@ -98,7 +79,7 @@ class rdc_store extends hook
{ {
if ($indexDevices[METEO]->properties["windgustkmh"]["value"] > 50) if ($indexDevices[METEO]->properties["windgustkmh"]["value"] > 50)
{ {
logger(ALERT, "Vent fort :" . $indexDevices[METEO]->properties["windgustkmh"]["value"], __FILE__ . ":" . __LINE__); logger(ALERT, "Vent fort :" . $indexDevices[METEO]->properties["windgustkmh"]["value"], __FILE__ . ":" . __LINE__, $device);
} }
$rafale = $mohaDB->moyenne($indexDevices[METEO], "windgustkmh", 6); $rafale = $mohaDB->moyenne($indexDevices[METEO], "windgustkmh", 6);
if ($rafale == 0) if ($rafale == 0)
@ -111,7 +92,7 @@ class rdc_store extends hook
{ {
if ($indexDevices[METEO]->properties["windspeedkmh"]["value"] > 50) if ($indexDevices[METEO]->properties["windspeedkmh"]["value"] > 50)
{ {
logger(ALERT, "Vent fort :" . $indexDevices[METEO]->properties["windspeedkmh"]["value"], __FILE__ . ":" . __LINE__); logger(ALERT, "Vent fort :" . $indexDevices[METEO]->properties["windspeedkmh"]["value"], __FILE__ . ":" . __LINE__, $device);
} }
$vent = $mohaDB->moyenne($indexDevices[METEO], "windspeedkmh", 6); $vent = $mohaDB->moyenne($indexDevices[METEO], "windspeedkmh", 6);
if ($vent == 0) if ($vent == 0)
@ -130,6 +111,32 @@ class rdc_store extends hook
logger(DEBUG, "soleil=" . $soleil, __FILE__ . ":" . __LINE__); logger(DEBUG, "soleil=" . $soleil, __FILE__ . ":" . __LINE__);
} }
} }
if (array_key_exists("position", $storeDevice->properties))
{
if ($this->motorReversal)
{
$this->storeLevel = 100 - $storeDevice->properties["position"]["value"];
}else
{
$this->storeLevel = $storeDevice->properties["position"]["value"];
}
logger(DEBUG, "storeLevel=" . $this->storeLevel, __FILE__ . ":" . __LINE__);
}else
{
$this->storeLevel = 0;
//return true;
}
if (array_key_exists("illuminance_lux", $indexDevices[RDC_FACADE_LUMINOSITE]->properties))
{
$facade_lux = $indexDevices[RDC_FACADE_LUMINOSITE]->properties["illuminance_lux"]["value"];
$facadeLuxMoyen = $mohaDB->moyenne($indexDevices[RDC_FACADE_LUMINOSITE], "illuminance_lux", 5);
if ($facadeLuxMoyen == 0)
{
$facadeLuxMoyen = $facade_lux;
}
logger(DEBUG, "facade_lux=" . $facade_lux . " et facadeLuxMoyen=" . $facadeLuxMoyen, __FILE__ . ":" . __LINE__);
}
if (array_key_exists("illuminance_lux", $indexDevices[RDC_EXTERIEUR_LUMINOSITE]->properties)) if (array_key_exists("illuminance_lux", $indexDevices[RDC_EXTERIEUR_LUMINOSITE]->properties))
{ {
@ -157,7 +164,7 @@ class rdc_store extends hook
{ {
$store2level = $this->storeLevel + 20; $store2level = $this->storeLevel + 20;
} }
}elseif ($exterieurLuxMoyen < 5000 and $salon_lux < 200 and $soleil < 100) }elseif ($exterieurLuxMoyen < 5000 and $salon_lux < 200 and $soleil < 100 and $facadeLuxMoyen < 5000)
{ {
logger(DEBUG, "exterieurLuxMoyen < 5000 and salon_lux < 200 and soleil < 100", __FILE__ . ":" . __LINE__); logger(DEBUG, "exterieurLuxMoyen < 5000 and salon_lux < 200 and soleil < 100", __FILE__ . ":" . __LINE__);
$this->close("Luminosité faible"); $this->close("Luminosité faible");
@ -196,6 +203,7 @@ class rdc_store extends hook
$this->setTo($store2level, AUTO); $this->setTo($store2level, AUTO);
} }
default: default:
break;
} }
logger(DEBUG, "maxLevel = " . $this->maxLevel . ' result => $r = ' . $r, __FILE__ . ":" . __LINE__); logger(DEBUG, "maxLevel = " . $this->maxLevel . ' result => $r = ' . $r, __FILE__ . ":" . __LINE__);
if ($this->storeLevel > $this->maxLevel) if ($this->storeLevel > $this->maxLevel)
@ -212,7 +220,6 @@ class rdc_store extends hook
logger(DEBUG, "store2level <= maxLevel", __FILE__ . ":" . __LINE__); logger(DEBUG, "store2level <= maxLevel", __FILE__ . ":" . __LINE__);
$this->setTo($store2level, AUTO); $this->setTo($store2level, AUTO);
} }
}
}else }else
{ {
logger(DEBUG, _("Store is Moving ") . $moving, __FILE__ . ":" . __LINE__); logger(DEBUG, _("Store is Moving ") . $moving, __FILE__ . ":" . __LINE__);
@ -223,10 +230,6 @@ class rdc_store extends hook
private function setTo($level, $method) private function setTo($level, $method)
{ {
logger(DEBUG, "function 'set' to level : " . $level, __FILE__ . ":" . __LINE__); logger(DEBUG, "function 'set' to level : " . $level, __FILE__ . ":" . __LINE__);
if (!$this->motorReversal)
{
$level = 100 - $level;
}
if ($level <= 100) if ($level <= 100)
{ {
logger(DEBUG, "Open store :" . $level, __FILE__ . ":" . __LINE__); logger(DEBUG, "Open store :" . $level, __FILE__ . ":" . __LINE__);
@ -243,7 +246,7 @@ class rdc_store extends hook
if ($this->storeLevel > 0) if ($this->storeLevel > 0)
{ {
logger(DEBUG, "Close store :" . $reason, __FILE__ . ":" . __LINE__); logger(DEBUG, "Close store :" . $reason, __FILE__ . ":" . __LINE__);
$this->send(100, IDLE); $this->send(0, IDLE);
} }
} }
@ -251,6 +254,8 @@ class rdc_store extends hook
{ {
global $indexDevices; global $indexDevices;
$deviceObject = $indexDevices[RDC_STORE]; $deviceObject = $indexDevices[RDC_STORE];
$level = 100 - $level;
$msg = array("position" => $level); $msg = array("position" => $level);
logger(INFO, sprintf(_("publishing message: %s to %s"), json_encode($msg), $deviceObject->friendlyName), __FILE__ . ":" . __LINE__); logger(INFO, sprintf(_("publishing message: %s to %s"), json_encode($msg), $deviceObject->friendlyName), __FILE__ . ":" . __LINE__);
$deviceObject->payload = $msg; $deviceObject->payload = $msg;
@ -261,4 +266,3 @@ class rdc_store extends hook
$hooks["rdc_store"] = new rdc_store(); $hooks["rdc_store"] = new rdc_store();
?> ?>
print_r($function[0], true)