- lots of debugging
- beginning to add graphical stats - beginning to add device by type - added a dashboard "etage" - begining to add notification to multiple recipients in freemobile hook
This commit is contained in:
@ -9,12 +9,13 @@ class rdc_store extends hook
|
||||
public $luminance_max = 3000;
|
||||
public $storeDownTime = 38;
|
||||
public $storeUpTime = 41;
|
||||
public $maxLevel;
|
||||
protected $storeLevel;
|
||||
protected $propertyInitialized =array();
|
||||
protected $devicelist = array(
|
||||
RDC_EXTERIEUR_LUMINOSITE => "illuminance_lux", // "ON"/"OFF"
|
||||
RDC_EXTERIEUR_LUMINOSITE => "illuminance_lux",
|
||||
METEO => "rainin",
|
||||
//METEO => array("solarradiation", false),
|
||||
//METEO => "solarradiation",
|
||||
METEO => "windspeedkmh",
|
||||
METEO => "windgustkmh"
|
||||
);
|
||||
@ -30,62 +31,86 @@ class rdc_store extends hook
|
||||
logger(DEBUG, "Callback : RDC_STORE", __FILE__ . ":" . __LINE__);
|
||||
$rain = 0;
|
||||
$exterieur_lux = 0;
|
||||
$salon_lux = 0;
|
||||
$rafale = 0;
|
||||
$soleil = 0;
|
||||
$storeDevice = $indexDevices[RDC_STORE];
|
||||
|
||||
if (array_key_exists("position", $storeDevice->properties))
|
||||
{
|
||||
$storeLevel = $storeDevice->properties["position"];
|
||||
$this->storeLevel = 100 - $storeDevice->properties["position"]["value"];
|
||||
logger(DEBUG, "storeLevel=" . $this->storeLevel, __FILE__ . ":" . __LINE__);
|
||||
}else
|
||||
{
|
||||
return true;
|
||||
$this->storeLevel = 0;
|
||||
//return true;
|
||||
}
|
||||
if (array_key_exists("illuminance_lux", $indexDevices[RDC_EXTERIEUR_LUMINOSITE]->properties))
|
||||
{
|
||||
$exterieur_lux = $mohaDB->moyenne($indexDevices[RDC_EXTERIEUR_LUMINOSITE], "illuminance_lux", 15);
|
||||
logger(DEBUG, "exterieur_lux=" . $exterieur_lux, __FILE__ . ":" . __LINE__);
|
||||
}
|
||||
if (array_key_exists("rainin", $indexDevices[METEO]->properties))
|
||||
if (array_key_exists("illuminance_lux", $indexDevices[RDC_SALON_LUMINOSITE]->properties))
|
||||
{
|
||||
$rain = $indexDevices[METEO]->properties["rainin"];
|
||||
$salon_lux = $mohaDB->moyenne($indexDevices[RDC_SALON_LUMINOSITE], "illuminance_lux", 10);
|
||||
logger(DEBUG, "salon_lux=" . $salon_lux, __FILE__ . ":" . __LINE__);
|
||||
}
|
||||
if (array_key_exists("windgustkmh", $indexDevices[METEO]->properties))
|
||||
if (array_key_exists(METEO, $indexDevices))
|
||||
{
|
||||
$rafale = $mohaDB->moyenne($indexDevices[METEO], "windgustkmh", 12);
|
||||
}
|
||||
if (array_key_exists("solarradiation", $indexDevices[METEO]->properties))
|
||||
{
|
||||
$soleil = $mohaDB->moyenne($indexDevices[METEO], "solarradiation", 12);
|
||||
}
|
||||
logger(DEBUG, sprintf(_("property=%s, value=%s"), $property, $value), __FILE__ . ":" . __LINE__);
|
||||
if ($rafale >= 6 or $rain != 0)
|
||||
{
|
||||
$maxLevel = 0;
|
||||
}else
|
||||
{
|
||||
if ($rafale != 0)
|
||||
if (array_key_exists("rainin", $indexDevices[METEO]->properties))
|
||||
{
|
||||
$maxLevel = 100 / $rafale;
|
||||
$rain = $indexDevices[METEO]->properties["rainin"]["value"];
|
||||
logger(DEBUG, "rain=" . var_dump($rain), __FILE__ . ":" . __LINE__);
|
||||
}
|
||||
if (array_key_exists("windgustkmh", $indexDevices[METEO]->properties))
|
||||
{
|
||||
$rafale = $mohaDB->moyenne($indexDevices[METEO], "windgustkmh", 12);
|
||||
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, sprintf(_("property=%s, value=%s"), $property, $value), __FILE__ . ":" . __LINE__);
|
||||
if ($rafale >= 60 or $rain != 0)
|
||||
{
|
||||
$this->maxLevel = 0;
|
||||
logger(DEBUG, sprintf("rafale = %s and rain = %s",$rafale, $rain), __FILE__ . ":" . __LINE__);
|
||||
$this->close("vent trop fort ou pluie");
|
||||
return 0;
|
||||
}elseif ($rafale != 0)
|
||||
{
|
||||
$this->maxLevel = ($r = 100 - round(($rafale-10)/5, 0, PHP_ROUND_HALF_UP)*20)<0 ? 0 : $r;
|
||||
//$this->maxLevel = 100 / $rafale;
|
||||
logger(DEBUG, "rafale=" . $rafale, __FILE__ . ":" . __LINE__);
|
||||
}
|
||||
logger(DEBUG, "maxlevel=" . $this->maxLevel, __FILE__ . ":" . __LINE__);
|
||||
//$store2level = $this->maxLevel;
|
||||
switch ($property)
|
||||
{
|
||||
case "illuminance_lux":
|
||||
logger(DEBUG, "CASE: illuminance_lux:" . $value, __FILE__ . ":" . __LINE__);
|
||||
if ($exterieur_lux > 3000)
|
||||
if ($exterieur_lux > 40000)
|
||||
{
|
||||
if ($rain == 0 and $maxLevel != 0)
|
||||
logger(DEBUG, "exterieur_lux > 40000", __FILE__ . ":" . __LINE__);
|
||||
if ($this->maxLevel != 0 and $salon_lux > 150)
|
||||
{
|
||||
$store2level = storeLevel + 15;
|
||||
if ( $store2level > $maxLevel )
|
||||
$store2level = $this->storeLevel + 15;
|
||||
if ( $store2level > $this->maxLevel )
|
||||
{
|
||||
$this->open($maxLevel);
|
||||
logger(DEBUG, "store2level > maxLevel", __FILE__ . ":" . __LINE__);
|
||||
$this->set($this->maxLevel);
|
||||
}else
|
||||
{
|
||||
$this->open($max2level);
|
||||
logger(DEBUG, "store2level <= maxLevel", __FILE__ . ":" . __LINE__);
|
||||
$this->set($store2level);
|
||||
}
|
||||
}
|
||||
}elseif ($exterieur_lux < 25000)
|
||||
}elseif ($exterieur_lux < 35000)
|
||||
{
|
||||
logger(DEBUG, "exterieur_lux < 35000", __FILE__ . ":" . __LINE__);
|
||||
$this->close("Luminosité faible");
|
||||
}
|
||||
break;
|
||||
@ -94,40 +119,25 @@ class rdc_store extends hook
|
||||
$this->close("Pluie");
|
||||
break;
|
||||
case "windgustkmh";
|
||||
logger(DEBUG, "CASE: windgustkmh:" . $value, __FILE__ . ":" . __LINE__);
|
||||
case "windspeedkmh":
|
||||
logger(DEBUG, "CASE: windspeedkmh:" . $value, __FILE__ . ":" . __LINE__);
|
||||
if($value > 50)
|
||||
logger(DEBUG, "CASE: windgustkmh:" . $rafale, __FILE__ . ":" . __LINE__);
|
||||
//case "windspeedkmh":
|
||||
// logger(DEBUG, "CASE: windspeedkmh:" . $value, __FILE__ . ":" . __LINE__);
|
||||
|
||||
logger(DEBUG, "maxLevel = " . $this->maxLevel . ' result => $r = ' . $r, __FILE__ . ":" . __LINE__);
|
||||
if ($this->storeLevel > $this->maxLevel)
|
||||
{
|
||||
$this->close("Trop de vent");
|
||||
}elseif ($value > 40 and $this->storeLevel > 20)
|
||||
{
|
||||
$this->maxLevel = 20;
|
||||
$this->send(20);
|
||||
}elseif ($value > 30 and $this->storeLevel > 40)
|
||||
{
|
||||
$this->maxLevel = 40;
|
||||
$this->send(40);
|
||||
}elseif ($value >20 and $this->storeLevel > 60)
|
||||
{
|
||||
$this->maxLevel = 60;
|
||||
$this->send(60);
|
||||
}elseif ($value >10 and $this->storeLevel > 80)
|
||||
{
|
||||
$this->maxLevel = 80;
|
||||
$this->send(80);
|
||||
}else
|
||||
{
|
||||
$this->maxLevel = 100;
|
||||
$this->set($this->maxLevel);
|
||||
}
|
||||
$this->close("Fortes rafales de vent");
|
||||
break;
|
||||
default:
|
||||
|
||||
}
|
||||
if ($store2level <= $this->storeLevel)
|
||||
{
|
||||
$this->set($store2level);
|
||||
}
|
||||
}
|
||||
|
||||
private function open ($level)
|
||||
private function set ($level)
|
||||
{
|
||||
if ($this->storeLevel < $level)
|
||||
{
|
||||
@ -140,8 +150,7 @@ class rdc_store extends hook
|
||||
{
|
||||
if ($this->storeLevel != 0)
|
||||
{
|
||||
logger(DEBUG, "Close store :" . $level, __FILE__ . ":" . __LINE__);
|
||||
print ( "store fermé " . $reason);
|
||||
logger(DEBUG, "Close store :" . $reason, __FILE__ . ":" . __LINE__);
|
||||
$this->send(100);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user