some debbuging :-(
This commit is contained in:
@ -10,7 +10,7 @@ class rdc_store extends hook
|
||||
public $storeDownTime = 38;
|
||||
public $storeUpTime = 41;
|
||||
public $maxLevel;
|
||||
protected $storeLevel;
|
||||
public $storeLevel;
|
||||
protected $propertyInitialized =array();
|
||||
protected $devicelist = array(
|
||||
RDC_EXTERIEUR_LUMINOSITE => "illuminance_lux",
|
||||
@ -29,15 +29,17 @@ class rdc_store extends hook
|
||||
{
|
||||
global $mohaDB, $devices, $indexDevices;
|
||||
|
||||
if ($this->active)
|
||||
logger(DEBUG, "Callback : RDC_STORE", __FILE__ . ":" . __LINE__);
|
||||
$rain = 0;
|
||||
static $rainS;
|
||||
$exterieur_lux = 0;
|
||||
$exterieurLuxMoyen =0;
|
||||
$salon_lux = 0;
|
||||
$rafale = 0;
|
||||
$soleil = 0;
|
||||
$storeDevice = $indexDevices[RDC_STORE];
|
||||
$this->maxLevel = 100;
|
||||
//$this->maxLevel = 100;
|
||||
$r = 100;
|
||||
|
||||
if (array_key_exists("position", $storeDevice->properties))
|
||||
@ -51,12 +53,13 @@ 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);
|
||||
$exterieur_lux = $indexDevices[RDC_EXTERIEUR_LUMINOSITE]->properties["illuminance_lux"]["value"];
|
||||
$exterieurLuxMoyen = $mohaDB->moyenne($indexDevices[RDC_EXTERIEUR_LUMINOSITE], "illuminance_lux", 5);
|
||||
if ($exterieur_lux == 0)
|
||||
{
|
||||
$exterieur_lux = $indexDevices[RDC_EXTERIEUR_LUMINOSITE]->properties["illuminance_lux"]["value"];
|
||||
$exterieurLuxMoyen = $exterieur_lux;
|
||||
}
|
||||
logger(DEBUG, "exterieur_lux=" . $exterieur_lux, __FILE__ . ":" . __LINE__);
|
||||
logger(DEBUG, "exterieur_lux=" . $exterieur_lux . " et exterieurLuxMoyen=" . $exterieurLuxMoyen, __FILE__ . ":" . __LINE__);
|
||||
}
|
||||
if (array_key_exists("illuminance_lux", $indexDevices[RDC_SALON_LUMINOSITE]->properties))
|
||||
{
|
||||
@ -67,6 +70,27 @@ class rdc_store extends hook
|
||||
}
|
||||
logger(DEBUG, "salon_lux=" . $salon_lux, __FILE__ . ":" . __LINE__);
|
||||
}
|
||||
if ($exterieur_lux > 30000 or $salon_lux >600)
|
||||
{
|
||||
logger(DEBUG, "exterieur_lux > 30000 or salon_lux >600", __FILE__ . ":" . __LINE__);
|
||||
if ($this->maxLevel != 0 and $salon_lux > 100)
|
||||
{
|
||||
$store2level = $this->storeLevel + 15;
|
||||
if ( $store2level > $this->maxLevel )
|
||||
{
|
||||
logger(DEBUG, "store2level > maxLevel", __FILE__ . ":" . __LINE__);
|
||||
$this->set($this->maxLevel);
|
||||
}else
|
||||
{
|
||||
logger(DEBUG, "store2level <= maxLevel", __FILE__ . ":" . __LINE__);
|
||||
$this->set($store2level);
|
||||
}
|
||||
}
|
||||
}elseif ($exterieurLuxMoyen < 9000 and $salon_lux < 1000)
|
||||
{
|
||||
logger(DEBUG, "exterieurLuxMoyen < 9000 and salon_lux < 1000", __FILE__ . ":" . __LINE__);
|
||||
$this->close("Luminosité faible");
|
||||
}
|
||||
if (array_key_exists(METEO, $indexDevices))
|
||||
{
|
||||
if (array_key_exists("rainin", $indexDevices[METEO]->properties))
|
||||
@ -82,7 +106,11 @@ class rdc_store extends hook
|
||||
{
|
||||
logger(ALERT, "Vent fort :" . $indexDevices[METEO]->properties["windgustkmh"]["value"], __FILE__ . ":" . __LINE__);
|
||||
}
|
||||
$rafale = $indexDevices[METEO]->properties["windgustkmh"]["value"]; //$mohaDB->moyenne($indexDevices[METEO], "windgustkmh", 6);
|
||||
$rafale = $mohaDB->moyenne($indexDevices[METEO], "windgustkmh", 6);
|
||||
if ($rafale == 0)
|
||||
{
|
||||
$rafale = $indexDevices[METEO]->properties["windgustkmh"]["value"];
|
||||
}
|
||||
logger(DEBUG, "rafale=" . $rafale, __FILE__ . ":" . __LINE__);
|
||||
}
|
||||
if (array_key_exists("solarradiation", $indexDevices[METEO]->properties))
|
||||
@ -100,7 +128,7 @@ class rdc_store extends hook
|
||||
return 0;
|
||||
}elseif ($rafale != 0)
|
||||
{
|
||||
$this->maxLevel = ($r = 100 - round($rafale/5, 0, PHP_ROUND_HALF_UP)*10)<0 ? 0 : $r;
|
||||
$this->maxLevel = ($r = 120 - round($rafale/4, 0, PHP_ROUND_HALF_UP)*10)<0 ? 0 : $r;
|
||||
//$this->maxLevel = 100 / $rafale;
|
||||
logger(DEBUG, "rafale=" . $rafale, __FILE__ . ":" . __LINE__);
|
||||
}
|
||||
@ -108,30 +136,10 @@ class rdc_store extends hook
|
||||
//$store2level = $this->maxLevel;
|
||||
switch ($property)
|
||||
{
|
||||
case "illuminance_lux":
|
||||
/*case "illuminance_lux":
|
||||
logger(DEBUG, "CASE: illuminance_lux:" . $value, __FILE__ . ":" . __LINE__);
|
||||
if ($exterieur_lux > 30000 or $salon_lux >600)
|
||||
{
|
||||
logger(DEBUG, "exterieur_lux > 30000", __FILE__ . ":" . __LINE__);
|
||||
if ($this->maxLevel != 0 and $salon_lux > 100)
|
||||
{
|
||||
$store2level = $this->storeLevel + 15;
|
||||
if ( $store2level > $this->maxLevel )
|
||||
{
|
||||
logger(DEBUG, "store2level > maxLevel", __FILE__ . ":" . __LINE__);
|
||||
$this->set($this->maxLevel);
|
||||
}else
|
||||
{
|
||||
logger(DEBUG, "store2level <= maxLevel", __FILE__ . ":" . __LINE__);
|
||||
$this->set($store2level);
|
||||
}
|
||||
}
|
||||
}elseif ($exterieur_lux < 12000 and $salon_lux < 150)
|
||||
{
|
||||
logger(DEBUG, "exterieur_lux < 15000", __FILE__ . ":" . __LINE__);
|
||||
$this->close("Luminosité faible");
|
||||
}
|
||||
break;
|
||||
|
||||
break;*/
|
||||
case "rainin":
|
||||
logger(DEBUG, "CASE: rainin:" . $value, __FILE__ . ":" . __LINE__);
|
||||
$this->close("Pluie");
|
||||
@ -153,11 +161,11 @@ class rdc_store extends hook
|
||||
private function set ($level)
|
||||
{
|
||||
logger(DEBUG, "function 'set' to level : " . $level, __FILE__ . ":" . __LINE__);
|
||||
//if ($this->storeLevel < $level)
|
||||
//{
|
||||
if ($this->storeLevel < $level AND $level <=100)
|
||||
{
|
||||
logger(DEBUG, "Open store :" . $level, __FILE__ . ":" . __LINE__);
|
||||
$this->send(100 - $level);
|
||||
//}else
|
||||
}//else
|
||||
/*{
|
||||
logger(DEBUG, "store is already at level" . $this->storeLevel . " so < at " . $level, __FILE__ . ":" . __LINE__);
|
||||
}*/
|
||||
@ -166,7 +174,7 @@ class rdc_store extends hook
|
||||
|
||||
private function close ($reason)
|
||||
{
|
||||
if ($this->storeLevel != 0)
|
||||
if ($this->storeLevel > 0)
|
||||
{
|
||||
logger(DEBUG, "Close store :" . $reason, __FILE__ . ":" . __LINE__);
|
||||
$this->send(100);
|
||||
|
Reference in New Issue
Block a user