1
0

debugged notification of availability of devices

This commit is contained in:
2022-08-12 10:41:55 +02:00
parent 247d1fd17d
commit df94a6becf
18 changed files with 176 additions and 70 deletions

View File

@ -4,26 +4,33 @@ class rdc_temperature_int_ext extends hook
{
public $hookName = "rdc_wc_eclairage";
public $active = true; //enable/disable hook (true => enabled)
public $wantedTemp = 24;
protected $devicelist = array(
METEO=> "tempc",
);
function installHooks(&$indexDevices)
{
return $this->installHooksFunction($indexDevices);
}
// callback fonction. Is called with these 4 parameters
public function callBack(&$device, $property, $value)
{
global $indexDevices;
static $status = 0;
if ($device->properties["indoortempc"]["value"] > $value and $status === 1)
static $status = -1;
$indoorTemp = $device->properties["indoortempc"]["value"];
if ( (($value > $this->wantedTemp and $indoorTemp < $this->wantedTemp) or ( $value < $this->wantedTemp and $indoorTemp >= $this->wantedTemp)) and $status === 1)
{
$status = 0;
logger(ALERT, _("Indoor temperature is superior to outdoor one"));
}elseif ($device->properties["indoortempc"]["value"] < $value and $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, _("Indoor temperature is inferior to outdoor one"));
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__);
logger (INFO, sprintf(_("%s: notification received from MQTT from %s => parameter: %s value: %s"), $this->hookName, $device->friendlyName, $property, bool2string($value)), __FILE__ . ":" . __LINE__, $device);
}
}