1
0

a lot of debug

This commit is contained in:
2022-04-23 02:00:52 +02:00
parent f8fc3f63ec
commit d1f1065e44
21 changed files with 544 additions and 217 deletions

View File

@ -6,7 +6,7 @@ class notificationFreemobile
public $active = true;
public $level;
private $dest = array(
"32886706&pass=JTGUY6l5OG73zX", //daniel
"daniel" => "32886706&pass=JTGUY6l5OG73zX",
);
function __construct()
@ -14,7 +14,7 @@ class notificationFreemobile
$this->level = ALERT | ERROR;
}
function send($message, $destinataire=0)
function send($message, $destinataire=NOTIF_DEFAULT_DEST)
{
global $curlErr;
$result = false;
@ -22,7 +22,7 @@ class notificationFreemobile
{
$ch = curl_init();
// set url
curl_setopt($ch, CURLOPT_URL, $this->url . $this->dest["destinataire"] . "&msg=" . urlencode(trim($message)));
curl_setopt($ch, CURLOPT_URL, $this->url . $this->dest[$destinataire] . "&msg=" . urlencode(trim($message)));
echo $this->url . urlencode(trim($message)) . EOL;
//return the transfer as a string
//curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

View File

@ -26,8 +26,9 @@ class rdc_salon_eclairage extends hook
$lux = $indexDevices[RDC_SALON_LUMINOSITE];
$mvmt = $indexDevices[RDC_SALON_MVMT];
$mvmt2 = $indexDevices[RDC_SALON_MVMT2];
logger (INFO, _("property => ") . $param . _("value =>") . bool2string($value), __FILE__ . ":" . __LINE__);
$illuminance = getValue(RDC_SALON_LUMINOSITE, "illuminance_lux");
logger (INFO, _("property => ") . $param . _("value =>") . bool2string($value), __FILE__ . ":" . __LINE__);
switch($param)
{
case "occupancy":
@ -35,7 +36,6 @@ class rdc_salon_eclairage extends hook
//print_r(getValue(RDC_SALON_LUMINOSITE, "illuminance_lux"));
if ($value == ON)
{
$illuminance = getValue(RDC_SALON_LUMINOSITE, "illuminance_lux");
logger(INFO, _("illuminance value : ") . $illuminance, __FILE__ . ":" . __LINE__);
if ($illuminance <= $this->luminance_min)
{
@ -49,14 +49,14 @@ class rdc_salon_eclairage extends hook
if (getValue(RDC_SALON_MVMT, "occupancy") == OFF and (getValue(RDC_SALON_MVMT2, "occupancy") == OFF))
{
logger(INFO, _("Setting to OFF"), __FILE__ . ":" . __LINE__);
//setDelay($deviceTarget, $this->delay, $this->timeUnit, "state", "OFF", true);
$this->send($deviceTarget, "OFF", false, IDLE);
setDelay($deviceTarget, $this->delay, $this->timeUnit, "state", "OFF", true);
//$this->send($deviceTarget, "OFF", false, IDLE);
}
}
break;
case "contact":
logger(INFO, _("CASE: Contact Door"), __FILE__ . ":" . __LINE__);
if ($value == false and getValue(RDC_SALON_LUMINOSITE, "illuminance_lux") <= $this->luminance_min)
if ($value == false and $illuminance <= $this->luminance_min)
{
logger(INFO, _("Door is open and illumance < min"), __FILE__ . ":" . __LINE__);
if ($deviceTarget->properties["state"]["method"] !== MANUAL)

View File

@ -14,8 +14,9 @@ class rdc_store extends hook
protected $propertyInitialized =array();
protected $devicelist = array(
RDC_EXTERIEUR_LUMINOSITE => "illuminance_lux",
RDC_SALON_LUMINOSITE => "illuminance_lux",
METEO => "rainin",
//METEO => "solarradiation",
METEO => "solarradiation",
METEO => "windspeedkmh",
METEO => "windgustkmh"
);
@ -35,7 +36,7 @@ class rdc_store extends hook
$rafale = 0;
$soleil = 0;
$storeDevice = $indexDevices[RDC_STORE];
$maxLevel = 100;
$this->maxLevel = 100;
$r = 100;
if (array_key_exists("position", $storeDevice->properties))
@ -50,11 +51,19 @@ class rdc_store extends hook
if (array_key_exists("illuminance_lux", $indexDevices[RDC_EXTERIEUR_LUMINOSITE]->properties))
{
$exterieur_lux = $mohaDB->moyenne($indexDevices[RDC_EXTERIEUR_LUMINOSITE], "illuminance_lux", 15);
if ($exterieur_lux == 0)
{
$exterieur_lux = $indexDevices[RDC_EXTERIEUR_LUMINOSITE]->properties["illuminance_lux"]["value"];
}
logger(DEBUG, "exterieur_lux=" . $exterieur_lux, __FILE__ . ":" . __LINE__);
}
if (array_key_exists("illuminance_lux", $indexDevices[RDC_SALON_LUMINOSITE]->properties))
{
$salon_lux = $mohaDB->moyenne($indexDevices[RDC_SALON_LUMINOSITE], "illuminance_lux", 10);
if ($salon_lux == 0)
{
$salon_lux = $indexDevices[RDC_SALON_LUMINOSITE]->properties["illuminance_lux"]["value"];
}
logger(DEBUG, "salon_lux=" . $salon_lux, __FILE__ . ":" . __LINE__);
}
if (array_key_exists(METEO, $indexDevices))
@ -66,13 +75,17 @@ class rdc_store extends hook
}
if (array_key_exists("windgustkmh", $indexDevices[METEO]->properties))
{
$rafale = $mohaDB->moyenne($indexDevices[METEO], "windgustkmh", 12);
if ($indexDevices[METEO]->properties["windgustkmh"]["value"] > 50)
{
logger(ALERT, "Vent fort :" . $indexDevices[METEO]->properties["windgustkmh"]["value"], __FILE__ . ":" . __LINE__);
}
$rafale = $mohaDB->moyenne($indexDevices[METEO], "windgustkmh", 7);
logger(DEBUG, "rafale=" . $rafale, __FILE__ . ":" . __LINE__);
}
if (array_key_exists("solarradiation", $indexDevices[METEO]->properties))
{
$soleil = $mohaDB->moyenne($indexDevices[METEO], "solarradiation", 12);
logger(DEBUG, "soleil=" . $exterieur_lux, __FILE__ . ":" . __LINE__);
logger(DEBUG, "soleil=" . $soleil, __FILE__ . ":" . __LINE__);
}
}
logger(DEBUG, sprintf(_("property=%s, value=%s"), $property, $value), __FILE__ . ":" . __LINE__);
@ -94,10 +107,10 @@ class rdc_store extends hook
{
case "illuminance_lux":
logger(DEBUG, "CASE: illuminance_lux:" . $value, __FILE__ . ":" . __LINE__);
if ($exterieur_lux > 40000)
if ($exterieur_lux > 30000)
{
logger(DEBUG, "exterieur_lux > 40000", __FILE__ . ":" . __LINE__);
if ($this->maxLevel != 0 and $salon_lux > 150)
logger(DEBUG, "exterieur_lux > 30000", __FILE__ . ":" . __LINE__);
if ($this->maxLevel != 0 and $salon_lux > 100)
{
$store2level = $this->storeLevel + 15;
if ( $store2level > $this->maxLevel )
@ -110,9 +123,9 @@ class rdc_store extends hook
$this->set($store2level);
}
}
}elseif ($exterieur_lux < 35000)
}elseif ($exterieur_lux < 15000 and $salon_lux < 300)
{
logger(DEBUG, "exterieur_lux < 35000", __FILE__ . ":" . __LINE__);
logger(DEBUG, "exterieur_lux < 15000", __FILE__ . ":" . __LINE__);
$this->close("Luminosité faible");
}
break;
@ -141,11 +154,16 @@ class rdc_store extends hook
private function set ($level)
{
if ($this->storeLevel < $level)
{
logger(DEBUG, "function 'set' to level : " . $level, __FILE__ . ":" . __LINE__);
//if ($this->storeLevel < $level)
//{
logger(DEBUG, "Open store :" . $level, __FILE__ . ":" . __LINE__);
$this->send(100 - $level);
}
//}else
/*{
logger(DEBUG, "store is already at level" . $this->storeLevel . " so < at " . $level, __FILE__ . ":" . __LINE__);
}*/
}
private function close ($reason)