1
0
This commit is contained in:
Daniel Tartavel 2022-10-05 20:37:01 +02:00
parent 9d20399d76
commit 559039b5e3

View File

@ -10,8 +10,8 @@ class rdc_temperature_int_ext extends hook
protected $devicelist = array(
METEO => "tempc",
RDC_CHAMBRE_TEMPERATURE => "temperature",
RDC_SALON_TEMPERATURE => "temperature"
//RDC_CHAMBRE_TEMPERATURE => "temperature",
//RDC_SALON_TEMPERATURE => "temperature"
);
protected $portesList = array(
@ -43,57 +43,61 @@ class rdc_temperature_int_ext extends hook
if ((now()->format("U") - $time->format("U")) > 300)
{
$indoorTemp = $device->properties["indoortempc"]["value"];
if ($property == "tempc")
{
$indoorTemp = $device->properties["indoortempc"]["value"];
if ( $value > $indoorTemp)
{
if( ($indoorTemp <= $this->tempSup) and empty($portes))
if ( $value > $indoorTemp)
{
$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);
}
print_r($portes);
if ($status == 1)
{
$portes = $hooks["test_portes"]->testPortes($this->portesList, false, false);
if (empty($portes))
{
$time = now();
foreach($portes as $porte)
if( ($indoorTemp <= $this->tempSup) and empty($portes))
{
$msg .= $porte . "\n";
}
logger(ALERT, _("Open doors to climate") . $msg, null, $device);
}
}else
{
$portes = $hooks["test_portes"]->testPortes($this->portesList, false, true);
if (!empty($portes))
{
$time = now();
foreach($portes as $porte)
$status = 1;
//logger(ALERT, _("Open doors to climate"), null ,$device);
}elseif($indoorTemp >= $this -> tempSup and ! empty($portes))
{
$msg .= $porte . "\n";
$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);
}
//print_r($portes);
if ($status == 1)
{
$portes = $hooks["test_portes"]->testPortes($this->portesList, false, false);
if (empty($portes))
{
$time = now();
foreach($portes as $porte)
{
$msg .= $porte . "\n";
}
logger(ALERT, _("Open doors to climate") . $msg, null, $device);
}
}else
{
$portes = $hooks["test_portes"]->testPortes($this->portesList, false, true);
if (!empty($portes))
{
$time = now();
foreach($portes as $porte)
{
$msg .= $porte . "\n";
}
logger(ALERT, _("Close doors to climate\n") . $msg, null, $device);
}
logger(ALERT, _("Close doors to climate\n") . $msg, null, $device);
}
}
}