J’ai amélioré mon widget pour utiliser directement l’historique MariaDB.
Voila mon virtuel [Douche][Conso Douche]
qui utilise la présence bluetooth du pommeau (j’étais sur Blea, je viens de passer sur tgw, ca ne change rien):
Mon scénario (bloc code) qui déclenche sur #[Douche][Conso Douche][Présent]#
$cmd = cmd::byString('#[Douche][Conso Douche][Présent]#');
$present =$cmd->execCmd();
// $scenario->setLog(">>> statistiques douche, pommeau présent: " . $present);
if ($present == false) {
// $scenario->setLog("cmd id: ". $cmd->getId());
$t = history::lastChangeStateDuration($cmd->getId(),1);
// $scenario->setLog("durée douche en s: ". $t);
if ($t > 0)
{
$debit = 5; // débit en L/min
$d = date_format(new DateTime('NOW'), 'd/m H:i');
// $scenario->setLog("date: ". $d);
cmd::byString('#[Douche][Conso Douche][Date]#')->event($d);
$duree = (abs($t) -90)/60; // timeout
//$duree = round((abs($t) -90)/60); // timeout
$volume = round($duree * $debit);
$duree = round($duree,1);
// $scenario->setLog("duree en mins: ". $duree);
// $scenario->setLog("volume en L: ". $volume);
cmd::byString('#[Douche][Conso Douche][Durée]#')->event($duree);
cmd::byString('#[Douche][Conso Douche][Volume]#')->event($volume);
}
}
Et mon widget BarChart