diff --git a/.github/workflows/work.yml b/.github/workflows/work.yml new file mode 100644 index 0000000..345021e --- /dev/null +++ b/.github/workflows/work.yml @@ -0,0 +1,15 @@ +on: + # Workflows check plugin Jeedom + push: + branches: + - beta + pull_request: + branches: + - beta + - master + +name : 'Full Workflows Plugin Jeedom' + +jobs: + plugin: + uses: jeedom/workflows/.github/workflows/plugin.yml@main diff --git a/core/class/energy3.class.php b/core/class/energy3.class.php index 8b27840..d0cf1c8 100644 --- a/core/class/energy3.class.php +++ b/core/class/energy3.class.php @@ -147,8 +147,8 @@ public function calculSolarPrevision() { public function calculImportExport() { - $net_power = jeedom::evaluateExpression($this->getConfiguration('elec::net::power')); - $elec_production = jeedom::evaluateExpression($this->getConfiguration('elec::production::instant')); + $net_power = (float) jeedom::evaluateExpression($this->getConfiguration('elec::net::power')); + $elec_production = (float) jeedom::evaluateExpression($this->getConfiguration('elec::production::instant')); if ($net_power > 0) { $this->checkAndUpdateCmd('elec::import::instant', $net_power); $this->checkAndUpdateCmd('elec::export::instant', 0); @@ -165,14 +165,24 @@ public function calculImportExport() { } else { $this->checkAndUpdateCmd('elec::production::consumption::instant', 0); } + 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); } public function calculPerformance() { - $production = $this->getCmd('info', 'elec::production')->execCmd(); - $export = $this->getCmd('info', 'elec::export')->execCmd(); - $consumption = $this->getCmd('info', 'elec::consumption')->execCmd(); - $autoconsumption = round((($production - $export) / $production) * 100, 1); + $production = (float) $this->getCmd('info', 'elec::production')->execCmd(); + $export = (float) $this->getCmd('info', 'elec::export')->execCmd(); + $consumption = (float) $this->getCmd('info', 'elec::consumption')->execCmd(); + if ($production > 0) { + $autoconsumption = round((($production - $export) / $production) * 100, 1); + }else { + $autoconsumption = 0; + } if ($autoconsumption < 0) { $autoconsumption = 0; } elseif ($autoconsumption > 100) { diff --git a/desktop/php/energy3.php b/desktop/php/energy3.php index 4cfa67f..928b804 100644 --- a/desktop/php/energy3.php +++ b/desktop/php/energy3.php @@ -43,7 +43,7 @@ foreach ($eqLogics as $eqLogic) { $opacity = ($eqLogic->getIsEnable()) ? '' : 'disableCard'; echo '
'; - echo ''; + echo ''; echo '
'; echo '' . $eqLogic->getHumanName(true, true) . ''; echo '