Bonsoir,
Ma petite contribution.
Pas besoin d’historiser, il suffit seulement de mettre la commande Info Maintenant timestamp
en déclencheur :
Scénario :
Le contenu du bloc code
/////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////// NE PAS MODIFIER /////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////
$tags['#valueNow#'] = -1; // initialisation tag valueNow.
$tags['#txtValueNextTS#'] = -1; // initialisation tag txtValueNextTS.
$tags['#nextAlertValue#'] = -1; // initialisation tag nextAlertValue.
$versionScenario = '2022-11-04 21:05:00';
$trigger = str_replace('#','',$scenario->getRealTrigger()); // récupération du trigger.
$cmd = cmd::byId($trigger);
$scenario->setLog('┌──────────── Lancement du bloc code (version scénario : ' . $versionScenario . ')'); //log
if (is_object($cmd)) { // si trigger est une commande.
$eqlogicId = $cmd->getEqLogic(); // on récupère Eqlogic.
$cmd_valueNow = $eqlogicId->getCmd('info', 'valueNow'); // recherche de la cmd ayant logicalId = valueNow.
$cmd_nextAlertTS = $eqlogicId->getCmd('info', 'nextAlertTS'); // recherche de la cmd ayant logicalId = nextAlertTS.
$cmd_nextAlertValue = $eqlogicId->getCmd('info', 'nextAlertValue'); // recherche de la cmd ayant logicalId = nextAlertValue.
if (is_object($cmd_valueNow)) $tags['#valueNow#'] = $cmd_valueNow->execCmd(); // si logicalId valueNow existe, modification du tag.
if (is_object($cmd_nextAlertTS) && is_object($cmd_nextAlertValue)) { // si logicalId nextAlertTS & $cmd_nextAlertValue existent, modification des tags.
$tags['#nextAlertValue#'] = $cmd_nextAlertValue->execCmd(); // Récupération de la valeur de la prochaine alerte.
if ($cmd_nextAlertTS->execCmd() > 0) $tags['#txtValueNextTS#'] = rteEcowatt::myStrftime('%A %e %B à %Hh',$cmd_nextAlertTS->execCmd()); // Récupération & transformation de la valeur du timestamp de la prochaine alerte.
}
//////// Log scénario /////////////
$scenario->setLog('| Valeur Actuelle : ' . $tags['#valueNow#']);
$scenario->setLog('| Valeur Prochaine alerte : ' . $tags['#nextAlertValue#']);
$scenario->setLog('| Date Prochaine alerte : ' . $tags['#txtValueNextTS#']);
//////////////////////////////////
}
else $scenario->setLog('| ERREUR : Déclencheur inconnu !!!'); //log
$scenario->setLog('└───────────────────────────'); //log
$scenario->setTags($tags); // envoi des tags
Template scénario a télécharger et remplacer l’extension en .json :
Alerte Ecowatt.txt (23,7 Ko)
Bonne soirée.