2022-03-13 22:33:26 +01:00
|
|
|
<?php
|
|
|
|
class radiateurs extends hook
|
|
|
|
{
|
|
|
|
public $hookName = "radiateurs";
|
|
|
|
public $active = false;
|
|
|
|
|
|
|
|
/* already defined in hook class */
|
|
|
|
// public $active = true;
|
|
|
|
//public $initlialized = false;
|
|
|
|
public $minTemp = 5;
|
|
|
|
public $delay = 3; // amount of time in $timeunit
|
|
|
|
public $delayManual = 15; // amount of time in $timeunit for manual mode
|
|
|
|
public $timeUnit = "minute"; // unit of time for delay, second, minute, day, week, month, year
|
|
|
|
|
2022-03-28 00:40:34 +02:00
|
|
|
// list of devices we are listening to: ieeeAddress => property to watch
|
2022-03-13 22:33:26 +01:00
|
|
|
protected $devicelist = array(
|
|
|
|
RDC_CHAMBRE_BAIE => "contact",
|
2022-03-28 00:40:34 +02:00
|
|
|
// RDC_SALON_BAIE => "contact",
|
|
|
|
// RDC_ENTREE_PORTE => "contact",
|
|
|
|
ETAGE_PORTE_ENTREE => "contact",
|
2022-03-13 22:33:26 +01:00
|
|
|
ETAGE_CUISINE_FENETRE => "contact",
|
|
|
|
ETAGE_SALON_FENETRE => "contact",
|
2022-03-28 00:40:34 +02:00
|
|
|
ETAGE_PORTE_FENETRE => "contact",
|
|
|
|
// ETAGE_CHAMBRE_FENETRE => "contact",
|
|
|
|
// ETAGE_BUREAU_FENETRE => "contact"
|
2022-03-13 22:33:26 +01:00
|
|
|
);
|
|
|
|
|
2022-03-28 00:40:34 +02:00
|
|
|
protected $hvac = array(
|
2022-03-13 22:33:26 +01:00
|
|
|
RDC_CHAMBRE_BAIE => RDC_CHAMBRE_RADIATEUR,
|
|
|
|
RDC_SALON_BAIE => RDC_SALON_RADIATEUR,
|
|
|
|
RDC_ENTREE_PORTE => RDC_SALON_RADIATEUR,
|
2022-03-28 00:40:34 +02:00
|
|
|
GARAGE_PORTE => RDC_SDB_RADIATEUR,
|
|
|
|
ETAGE_PORTE_ENTREE => ETAGE_SALON_RADIATEUR,
|
2022-03-13 22:33:26 +01:00
|
|
|
ETAGE_CUISINE_FENETRE => ETAGE_SALON_RADIATEUR,
|
|
|
|
ETAGE_SALON_FENETRE => ETAGE_SALON_RADIATEUR,
|
2022-03-28 00:40:34 +02:00
|
|
|
ETAGE_PORTE_FENETRE => ETAGE_SALON_RADIATEUR,
|
2022-03-13 22:33:26 +01:00
|
|
|
// ETAGE_CHAMBRE_FENETRE => ETAGE_CHAMBRE_RADIATEUR,
|
2022-03-28 00:40:34 +02:00
|
|
|
// ETAGE_BUREAU_FENETRE => ETAGE_BUREAU_RADIATEUR,
|
2022-03-13 22:33:26 +01:00
|
|
|
// ETAGE_SDB_FENETRE => ETAGE_SDB_RADIATEUR
|
|
|
|
);
|
|
|
|
|
|
|
|
protected $prevTemp = array(
|
|
|
|
RDC_CHAMBRE_RADIATEUR => 0,
|
|
|
|
RDC_SALON_RADIATEUR => 0,
|
|
|
|
RDC_SDB_RADIATEUR => 0,
|
|
|
|
ETAGE_SALON_RADIATEUR => 0,
|
|
|
|
ETAGE_BUREAU_RADIATEUR => 0
|
|
|
|
// ETAGE_SDB_RADIATEUR => 0,
|
|
|
|
// ETAGE_CHAMBRE_RADIATEUR => 0
|
|
|
|
);
|
|
|
|
|
|
|
|
// callback fonction. Is called with these 3 parameters
|
|
|
|
public function callBack(&$device, $property, $value)
|
|
|
|
{
|
|
|
|
global $indexDevices;
|
2022-03-28 00:40:34 +02:00
|
|
|
logger(DEBUG, "Callback : " . $this->hookName, __FILE__ . ":" . __LINE__);
|
|
|
|
if ($this->active === true)
|
2022-03-13 22:33:26 +01:00
|
|
|
{
|
2022-03-28 00:40:34 +02:00
|
|
|
$now = date("MM");
|
|
|
|
if ($now <= 5 or $now >= 11)
|
2022-03-13 22:33:26 +01:00
|
|
|
{
|
2022-03-28 00:40:34 +02:00
|
|
|
if ($value === false)
|
2022-03-13 22:33:26 +01:00
|
|
|
{
|
2022-03-28 00:40:34 +02:00
|
|
|
$this->send($indexDevices[$this->hvac[$device->ieeeAddress]], true);
|
|
|
|
/* switch ($device->$ieeeAddress)
|
|
|
|
{
|
|
|
|
send($indexDevices[$hvac[$device->ieeeAddress]], false);
|
|
|
|
case RDC_CHAMBRE_BAIE:
|
|
|
|
break;
|
|
|
|
case RDC_SALON_BAIE:
|
|
|
|
case RDC_ENTREE_PORTE:
|
|
|
|
break;
|
|
|
|
case RDC_GARAGE_PORTE:
|
|
|
|
break;
|
|
|
|
case ETAGE_CUISINE_FENETRE:
|
|
|
|
case ETAGE_SALON_FENETRE:
|
|
|
|
case ETAGE_SALON_PORTE_FENETRE:
|
|
|
|
case ETAGE_ENTREE_PORTE:
|
2022-03-13 22:33:26 +01:00
|
|
|
|
2022-03-28 00:40:34 +02:00
|
|
|
break;
|
|
|
|
case ETAGE_CHAMBRE_FENETRE:
|
2022-03-13 22:33:26 +01:00
|
|
|
|
2022-03-28 00:40:34 +02:00
|
|
|
break;
|
|
|
|
case ETAGE_BUREAU_FENETRE:
|
2022-03-13 22:33:26 +01:00
|
|
|
|
2022-03-28 00:40:34 +02:00
|
|
|
break;
|
|
|
|
}*/
|
|
|
|
}else
|
|
|
|
{
|
|
|
|
$this->send($indexDevices[$this->hvac[$device->ieeeAddress]], false);
|
|
|
|
}
|
2022-03-13 22:33:26 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function send($device, $state)
|
|
|
|
{
|
|
|
|
global $indexDevices;
|
2022-03-28 00:40:34 +02:00
|
|
|
$flag = false;
|
2022-03-13 22:33:26 +01:00
|
|
|
if ($state === false)
|
|
|
|
{
|
2022-03-28 00:40:34 +02:00
|
|
|
$t = getValue($device->ieeeAddress, "current_heating_setpoint");
|
|
|
|
if ($t != $this->minTemp)
|
2022-03-13 22:33:26 +01:00
|
|
|
{
|
2022-03-28 00:40:34 +02:00
|
|
|
$this->prevTemp[$device->ieeeAddress] = getValue($device->ieeeAddress, "current_heating_setpoint");
|
2022-03-13 22:33:26 +01:00
|
|
|
}
|
|
|
|
}else
|
|
|
|
{
|
2022-03-28 00:40:34 +02:00
|
|
|
$r = array_keys($this->hvac, $device->ieeeAddress);
|
2022-03-13 22:33:26 +01:00
|
|
|
foreach($r as $value)
|
|
|
|
{
|
2022-03-28 00:40:34 +02:00
|
|
|
logger(DEBUG, "Device to test for contact " . $value, __FILE__ . ":" . __LINE__);
|
|
|
|
if (getValue($device->ieeeAddress, "contact") === true)
|
2022-03-13 22:33:26 +01:00
|
|
|
{
|
2022-03-28 00:40:34 +02:00
|
|
|
$flag &= true;
|
2022-03-13 22:33:26 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if ($flag === false)
|
|
|
|
{
|
2022-03-28 00:40:34 +02:00
|
|
|
$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;
|
2022-06-20 10:34:55 +02:00
|
|
|
$device->set("current_heating_setpoint", AUTO);
|
2022-04-07 01:44:17 +02:00
|
|
|
$device->properties["current_heating_setpoint"]["method"] = AUTO;
|
2022-03-13 22:33:26 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$hooks["radiateurs"] = new radiateurs();
|
|
|
|
|
|
|
|
?>
|