1
0
This commit is contained in:
Daniel Tartavel 2023-01-26 18:30:51 +01:00
parent ad73b91cc5
commit 098ecdbecb
4 changed files with 20 additions and 15 deletions

View File

@ -1 +0,0 @@
a:0:{}

View File

@ -2,7 +2,7 @@
class radiateurs extends hook class radiateurs extends hook
{ {
public $hookName = "radiateurs"; public $hookName = "radiateurs";
public $active = false; public $active = true;
/* already defined in hook class */ /* already defined in hook class */
// public $active = true; // public $active = true;
@ -25,6 +25,7 @@ class radiateurs extends hook
// ETAGE_BUREAU_FENETRE => "contact" // ETAGE_BUREAU_FENETRE => "contact"
); );
// list of actions (sensor => hvac)
protected $hvac = array( protected $hvac = array(
RDC_CHAMBRE_BAIE => RDC_CHAMBRE_RADIATEUR, RDC_CHAMBRE_BAIE => RDC_CHAMBRE_RADIATEUR,
RDC_SALON_BAIE => RDC_SALON_RADIATEUR, RDC_SALON_BAIE => RDC_SALON_RADIATEUR,
@ -49,6 +50,11 @@ class radiateurs extends hook
// ETAGE_CHAMBRE_RADIATEUR => 0 // ETAGE_CHAMBRE_RADIATEUR => 0
); );
function installHooks(&$indexDevices)
{
return $this->installHooksFunction($indexDevices);
}
// callback fonction. Is called with these 3 parameters // callback fonction. Is called with these 3 parameters
public function callBack(&$device, $property, $value) public function callBack(&$device, $property, $value)
{ {
@ -107,7 +113,7 @@ class radiateurs extends hook
$t = getValue($device->ieeeAddress, "current_heating_setpoint"); $t = getValue($device->ieeeAddress, "current_heating_setpoint");
if ($t != $this->minTemp) if ($t != $this->minTemp)
{ {
$this->prevTemp[$device->ieeeAddress] = getValue($device->ieeeAddress, "current_heating_setpoint"); $this->prevTemp[$device->ieeeAddress] = $t;
} }
$setTo = $minTemp; $setTo = $minTemp;
}else }else
@ -125,7 +131,6 @@ class radiateurs extends hook
if ($flag === false) if ($flag === false)
{ {
$setTo = (!empty($this->prevTemp[$device->ieeeAddress])?$this->prevTemp[$device->ieeeAddress]:19); $setTo = (!empty($this->prevTemp[$device->ieeeAddress])?$this->prevTemp[$device->ieeeAddress]:19);
} }
} }
if ($setTo <> 0) if ($setTo <> 0)

View File

@ -272,6 +272,7 @@ if (file_exists($dataPath . "events.db"))
} }
} }
// topics definition // topics definition
listHooks("./topics_callbacks", $topicsCallbacks); listHooks("./topics_callbacks", $topicsCallbacks);
if (!empty($topicsCallbacks)) if (!empty($topicsCallbacks))
@ -341,8 +342,6 @@ if (file_exists($dataPath . "devices.db"))
} }
} }
// Program start // Program start
logger(DEBUG, _("Program start"), __FILE__ . ":" . __LINE__); logger(DEBUG, _("Program start"), __FILE__ . ":" . __LINE__);
$client = new Mosquitto\Client(); $client = new Mosquitto\Client();
@ -387,7 +386,7 @@ configWatchInit();
while (true) while (true)
{ {
// test if looping is more then 5 second and send and alert // test if looping is more then 5 second and send and alert
echo date("c") . " début"; // echo date("c") . " début";
$now = new datetime("now"); $now = new datetime("now");
$testTime = clone $now; $testTime = clone $now;
$testTime->modify("-5 second"); $testTime->modify("-5 second");
@ -398,14 +397,15 @@ while (true)
$timeLoop = $now; $timeLoop = $now;
$client->loop(); // mqtt server loop() $client->loop(); // mqtt server loop()
echo date("c") . " One shot";
if ($oneshot === false) // execute while the first loop :WARNING hooks may not be initialized if ($oneshot === false) // execute while the first loop :WARNING all hooks may not be initialized
{ {
echo date("c") . " One shot";
logger(DEBUG, _("Oneshot part of loop"), __FILE__ . ":" . __LINE__, false); logger(DEBUG, _("Oneshot part of loop"), __FILE__ . ":" . __LINE__, false);
pws2mqttGetList(); pws2mqttGetList();
$oneshot = true; $oneshot = true;
} }
echo date("c") . " initialisation des hooks"; //echo date("c") . " initialisation des hooks";
if($hooksInitialized == 0) // all hooks are not initialized if($hooksInitialized == 0) // all hooks are not initialized
{ {
$i = 1; $i = 1;
@ -432,13 +432,13 @@ echo date("c") . " initialisation des hooks";
{ {
//logger(DEBUG, _("looping"), __FILE__ . ":" . __LINE__); //logger(DEBUG, _("looping"), __FILE__ . ":" . __LINE__);
} }
echo date("c") . " chech events"; // echo date("c") . " chech events";
checkEvents(); checkEvents();
echo date("c") . " topics availabiblity"; // echo date("c") . " topics availabiblity";
checkTopicsAvailability(); checkTopicsAvailability();
echo date("c") . " apiserver"; //echo date("c") . " apiserver";
if ($apiServerIsActive) apiServer($read); if ($apiServerIsActive) apiServer($read);
echo date("c") . " surveillance Configuration"; //echo date("c") . " surveillance Configuration";
// surveillance du dossier de configuration // surveillance du dossier de configuration
if ($cwfd !== false) if ($cwfd !== false)
{ {
@ -458,7 +458,7 @@ echo date("c") . " surveillance Configuration";
} }
} }
} }
echo date("c") . " fin"; //echo date("c") . " fin";
} }
endMoha(); endMoha();

View File

@ -14,6 +14,7 @@ StandardError=inherit
Restart=always Restart=always
User=domotique User=domotique
Group=domotique Group=domotique
Nice=15
[Install] [Install]
WantedBy=multi-user.target WantedBy=multi-user.target