Mips m’a indiqué ce matin que j’utilisais une image de jeedom/jeedom:latest deb 12 + jeedom 4.4, du coup cela n’était pas supporté officiellement.
J’ai donc fait marche arrière et j’allais clôturer tous les sujet que j’ai ouvert mais après être passé sur l’image : jeedom/jeedom:4.4-bullseye
deb 11 + jeedom 4.4, j’ai de nouveaux des anomalies qui remontent correspondant aux mêmes lignes.
Dans le fichier de log listerner_execution
:
0624|PHP Warning: A non-numeric value encountered in /var/www/html/plugins/energy3/core/class/energy3.class.php on line 175
0625|PHP Warning: Division by zero in /var/www/html/plugins/energy3/core/class/energy3.class.php on line 175
0626|PHP Warning: A non-numeric value encountered in /var/www/html/plugins/energy3/core/class/energy3.class.php on line 182
En attendant une solution officiel, j’ai mis ces corrections :
Dans la fonction calculPerformance()
, j’ai donc caster en float les valeurs + ajout de test pour les divisions par 0:
public function calculPerformance() {
//$production = $this->getCmd('info', 'elec::production')->execCmd();
//$export = $this->getCmd('info', 'elec::export')->execCmd();
//$consumption = $this->getCmd('info', 'elec::consumption')->execCmd();
$production = (float)$this->getCmd('info', 'elec::production')->execCmd();
$export = (float)$this->getCmd('info', 'elec::export')->execCmd();
$consumption = (float)$this->getCmd('info', 'elec::consumption')->execCmd();
//$autoconsumption = round((($production - $export) / $production) * 100, 1);
if ($production > 0) {
$autoconsumption = round((($production - $export) / $production) * 100, 1);
}
else {
$autoconsumption = 0;
}
if ($autoconsumption < 0) {
$autoconsumption = 0;
} elseif ($autoconsumption > 100) {
$autoconsumption = 100;
}
$this->checkAndUpdateCmd('elec::autoconsumption', $autoconsumption);
//$selfsufficiency = round((($production - $export) / $consumption) * 100, 1);
if ($consumption > 0) {
$selfsufficiency = round((($production - $export) / $consumption) * 100, 1);
}
else {
$selfsufficiency = 0;
}
if ($selfsufficiency < 0) {
$selfsufficiency = 0;
} elseif ($selfsufficiency > 100) {
$selfsufficiency = 100;
}
$this->checkAndUpdateCmd('elec::selfsufficiency', $selfsufficiency);
}
Dans la fonction calculImportExport()
j’ai l’ano suivante qui remonte après avoir appliqué la première correction 0005|PHP Warning: A non-numeric value encountered in /var/www/html/plugins/energy3/core/class/energy3.class.php on line 168
du coup un test que la valeur est bien numérique avant de l’utiliser :
public function calculImportExport() {
$net_power = jeedom::evaluateExpression($this->getConfiguration('elec::net::power'));
$elec_production = jeedom::evaluateExpression($this->getConfiguration('elec::production::instant'));
if ($net_power > 0) {
$this->checkAndUpdateCmd('elec::import::instant', $net_power);
$this->checkAndUpdateCmd('elec::export::instant', 0);
} else {
$this->checkAndUpdateCmd('elec::import::instant', 0);
$this->checkAndUpdateCmd('elec::export::instant', -$net_power);
}
if ($elec_production > 0) {
if ($net_power > 0) {
$this->checkAndUpdateCmd('elec::production::consumption::instant', $elec_production);
} else {
$this->checkAndUpdateCmd('elec::production::consumption::instant', $elec_production + $net_power);
}
} else {
$this->checkAndUpdateCmd('elec::production::consumption::instant', 0);
}
// Test valeur numérique sinon application de 0 par défaut
if (!is_numeric($net_power)) {
$net_power = 0;
}
if (!is_numeric($elec_production)) {
$elec_production = 0;
}
$this->checkAndUpdateCmd('elec::consumption::instant', $elec_production + $net_power);
}
Ma page de santé