1
0

récupération après crash

This commit is contained in:
2022-12-05 12:23:43 +01:00
parent 559039b5e3
commit a27db71327
22 changed files with 300 additions and 147 deletions

View File

@ -49,11 +49,6 @@ class radiateurs extends hook
// ETAGE_CHAMBRE_RADIATEUR => 0
);
function installHooks(&$indexDevices)
{
return $this->installHooksFunction($indexDevices);
}
// callback fonction. Is called with these 3 parameters
public function callBack(&$device, $property, $value)
{
@ -61,6 +56,7 @@ class radiateurs extends hook
logger(DEBUG, "Callback : " . $this->hookName, __FILE__ . ":" . __LINE__);
if ($this->active === true)
{
// test mois entre mai et octobre
$now = date("MM");
if ($now <= 5 or $now >= 11)
{
@ -98,17 +94,22 @@ class radiateurs extends hook
}
}
// state = true when a door or window is open
function send($device, $state)
{
global $indexDevices;
$flag = false;
if ($state === false)
$setTo = 0;
if ($state === true)
{
$t = getValue($device->ieeeAddress, "current_heating_setpoint");
if ($t != $this->minTemp)
{
$this->prevTemp[$device->ieeeAddress] = getValue($device->ieeeAddress, "current_heating_setpoint");
}
$setTo = $minTemp;
}else
{
$r = array_keys($this->hvac, $device->ieeeAddress);
@ -123,13 +124,18 @@ class radiateurs extends hook
}
if ($flag === false)
{
$msg = array("current_heating_setpoint" => (!empty($this->prevTemp[$device->ieeeAddress])?$this->prevTemp[$device->ieeeAddress]:19));
logger(INFO, sprintf(_("publishing message: %s to %s"), json_encode($msg), $device->friendlyName), __FILE__ . ":" . __LINE__);
$device->payload = $msg;
$device->set("current_heating_setpoint", AUTO);
$device->properties["current_heating_setpoint"]["method"] = AUTO;
$setTo = (!empty($this->prevTemp[$device->ieeeAddress])?$this->prevTemp[$device->ieeeAddress]:19);
}
}
if ($setTo <> 0)
{
$msg = array("current_heating_setpoint" => $setTo );
logger(INFO, sprintf(_("publishing message: %s to %s"), json_encode($msg), $device->friendlyName), __FILE__ . ":" . __LINE__);
$device->payload = $msg;
$device->set("current_heating_setpoint", AUTO);
//$device->properties["current_heating_setpoint"]["method"] = AUTO;
}
}
}
$hooks["radiateurs"] = new radiateurs();