il y a la fonction « union all » en sql
afin de cumulé history et historyarch
enfin je mets brut la base de l’autre methode
//$cmdId= cmd::byString("##")->getId();
$cmdId= cmd::byString("#[Dehors][Sondes Serres][Température]#")->getId();
$debut = date("Y-m-d H:i:s", strtotime("yesterday"));
// $fin = date("Y-m-d H:i:s", strtotime("-9 hour 15 min"));
$fin = date("Y-m-d H:i:s", strtotime("-10 min"));
$value = history::getStatistique($cmdId, $debut, $fin)["min"];
// $value = history::getStatistique($cmdId, $debut, $fin)["last"];
$scenario->setLog($value);
$all = history::all($cmdId, $debut, $fin);
$first = $all[0]->getValue();
$firstdate = $all[0]->getDatetime();
for ($i = 0; $i < count($all); $i++) {
$v = $all[$i];
// recherche
if($v->getValue() == '19.5' ) {
// if($v->getValue() == $value ) {
$current = $v->getDatetime();
$valeur = $v->getValue();
$scenario->setLog( "recherche : $current valeur : $valeur ");
}
if($v->getValue() == $value ) {
$current2 = $v->getDatetime();
}
}
$scenario->setLog("premier $first à $firstdate");
$scenario->setLog("mini $value à $current2");
//$date= date ("Y-m-d H:i:s", strtotime($current));
// $scenario->setLog($date);
son log
[2020-05-10 09:01:29][SCENARIO] Start : Scenario lance manuellement.
[2020-05-10 09:01:29][SCENARIO] Exécution du sous-élément de type [action] : code
[2020-05-10 09:01:29][SCENARIO] Exécution d’un bloc code
[2020-05-10 09:01:30][SCENARIO] 9.50
[2020-05-10 09:01:30][SCENARIO] recherche : 2020-05-09 18:00:00 valeur : 19.5
[2020-05-10 09:01:30][SCENARIO] premier 12.5 à 2020-05-09 00:00:00
[2020-05-10 09:01:30][SCENARIO] mini 9.50 à 2020-05-09 06:00:00
[2020-05-10 09:01:30][SCENARIO] Fin correcte du scénario