some adjustments
This commit is contained in:
@@ -4,7 +4,9 @@ class rdc_temperature_int_ext extends hook
|
||||
{
|
||||
public $hookName = "rdc_wc_eclairage";
|
||||
public $active = true; //enable/disable hook (true => enabled)
|
||||
public $wantedTemp = 24;
|
||||
public $tempSup = 25;
|
||||
public $tempInf = 20;
|
||||
|
||||
|
||||
protected $devicelist = array(
|
||||
METEO=> "tempc",
|
||||
@@ -18,21 +20,52 @@ class rdc_temperature_int_ext extends hook
|
||||
// callback fonction. Is called with these 4 parameters
|
||||
public function callBack(&$device, $property, $value)
|
||||
{
|
||||
global $indexDevices;
|
||||
static $status = -1;
|
||||
global $indexDevices, $hooks;
|
||||
static $time;
|
||||
$portes = array();
|
||||
$state = -1;
|
||||
$msg = "";
|
||||
|
||||
$indoorTemp = $device->properties["indoortempc"]["value"];
|
||||
if ( (($value > $this->wantedTemp and $indoorTemp < $this->wantedTemp) or ( $value < $this->wantedTemp and $indoorTemp >= $this->wantedTemp)) and $status === 1)
|
||||
$portes = $hooks["alerte_intrusion"]->testPortes(false);
|
||||
foreach($portes as $value)
|
||||
{
|
||||
$status = 0;
|
||||
logger(ALERT, _("Open doors to climate"), null ,$device);
|
||||
}elseif ( (($value > $this->wantedTemp and $indoorTemp >= $this->wantedTemp) or ( $value < $this->wantedTemp and $indoorTemp <= $this->wantedTemp)) and $status === 0 )
|
||||
{
|
||||
$status = 1;
|
||||
logger(ALERT, _("Close doors to climate"), null, $device);
|
||||
$msg .= $value . "\n";
|
||||
}
|
||||
|
||||
if ( $value > $indoorTemp)
|
||||
{
|
||||
if( ($indoorTemp <= $this->tempSup) and empty($portes))
|
||||
{
|
||||
$status = 1;
|
||||
//logger(ALERT, _("Open doors to climate"), null ,$device);
|
||||
}elseif($indoorTemp >= $this -> tempSup and ! empty($portes))
|
||||
{
|
||||
$status = 0;
|
||||
//logger(ALERT, _("Close doors to climate"), null, $device);
|
||||
}
|
||||
}elseif ( $value < $indoorTemp )
|
||||
{
|
||||
if (($indoorTemp >= $this->tempSup) and empty($portes) )
|
||||
{
|
||||
$status = 1;
|
||||
//logger(ALERT, _("Open doors to climate"), null ,$device);
|
||||
}elseif ($indoorTemp <= $this->tempSup)
|
||||
{
|
||||
$status = 0;
|
||||
//logger(ALERT, _("Close doors to climate"), null, $device);
|
||||
}
|
||||
logger (INFO, sprintf(_("%s: notification received from MQTT from %s => parameter: %s value: %s"), $this->hookName, $device->friendlyName, $property, bool2string($value)), __FILE__ . ":" . __LINE__, $device);
|
||||
}
|
||||
if ($status == 1)
|
||||
{
|
||||
//if ($time - DateTime();
|
||||
//logger(ALERT, _("Open doors to climate"), null ,$device);
|
||||
}else
|
||||
{
|
||||
//logger(ALERT, _("Close doors to climate\n") . $msg, null, $device);
|
||||
}
|
||||
logger (INFO, sprintf(_("%s: notification received from MQTT from %s => parameter: %s value: %s"), $this->hookName, $device->friendlyName, $property, bool2string($value)), __FILE__ . ":" . __LINE__, $device);
|
||||
}
|
||||
}
|
||||
|
||||
$hooks["rdc_temperature_int_ext"] = new rdc_temperature_int_ext();
|
||||
?>
|
||||
|
Reference in New Issue
Block a user