From 1ab33fad80e566d9091afb929e9423fce54342ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc?= <1536036+zoic21@users.noreply.github.com> Date: Fri, 15 Mar 2024 15:32:42 +0100 Subject: [PATCH] fix for php8 --- core/class/thermostat.class.php | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/core/class/thermostat.class.php b/core/class/thermostat.class.php index 6907b6a..dee4be8 100644 --- a/core/class/thermostat.class.php +++ b/core/class/thermostat.class.php @@ -232,10 +232,10 @@ public static function temporal($_options) { return; } $thermostat->setCache('temp_threshold', 0); - if (($temp_in < ($thermostat->getCache('lastOrder') - $thermostat->getConfiguration('offsetHeatFaillure', 1)) && $temp_in < $thermostat->getCache('lastTempIn') && $thermostat->getCache('lastState') == 'heat' && $thermostat->getConfiguration('coeff_indoor_heat_autolearn') > 25) || - ($temp_in > ($thermostat->getCache('lastOrder') + $thermostat->getConfiguration('offsetColdFaillure', 1)) && $temp_in > $thermostat->getCache('lastTempIn') && $thermostat->getCache('lastState') == 'cool' && $thermostat->getConfiguration('coeff_indoor_cool_autolearn') > 25) + if (($temp_in < ($thermostat->getCache('lastOrder', 0) - $thermostat->getConfiguration('offsetHeatFaillure', 1)) && $temp_in < $thermostat->getCache('lastTempIn', 0) && $thermostat->getCache('lastState') == 'heat' && $thermostat->getConfiguration('coeff_indoor_heat_autolearn') > 25) || + ($temp_in > ($thermostat->getCache('lastOrder', 0) + $thermostat->getConfiguration('offsetColdFaillure', 1)) && $temp_in > $thermostat->getCache('lastTempIn', 0) && $thermostat->getCache('lastState') == 'cool' && $thermostat->getConfiguration('coeff_indoor_cool_autolearn') > 25) ) { - $thermostat->setCache('nbConsecutiveFaillure', $thermostat->getCache('nbConsecutiveFaillure') + 1); + $thermostat->setCache('nbConsecutiveFaillure', $thermostat->getCache('nbConsecutiveFaillure', 0) + 1); if ($thermostat->getCache('nbConsecutiveFaillure', 0) == 2) { log::add(__CLASS__, 'error', $thermostat->getHumanName() . ' ' . __('Attention une défaillance du chauffage est détectée', __FILE__)); $thermostat->failureActuator(); @@ -245,14 +245,14 @@ public static function temporal($_options) { } if ($thermostat->getCache('nbConsecutiveFaillure', 0) < 3 && $thermostat->getConfiguration('autolearn') == 1 && strtotime($thermostat->getConfiguration('endDate')) < strtotime('now')) { log::add(__CLASS__, 'debug', $thermostat->getHumanName() . ' ' . __('Démarre auto-apprentissage', __FILE__)); - if ($thermostat->getCache('last_power') < 100 && $thermostat->getCache('last_power') > 0) { + if ($thermostat->getCache('last_power', 0) < 100 && $thermostat->getCache('last_power', 0) > 0) { log::add(__CLASS__, 'debug', $thermostat->getHumanName() . ' Last power ok, check what I have to learn, last state : ' . $thermostat->getCache('lastState')); $learn_outdoor = false; if ($thermostat->getCache('lastState') == 'heat') { log::add(__CLASS__, 'debug', $thermostat->getHumanName() . ' Last state is heat'); - if ($temp_in > $thermostat->getCache('lastTempIn') && $thermostat->getCache('lastOrder') > $thermostat->getCache('lastTempIn')) { + if ($temp_in > $thermostat->getCache('lastTempIn', 0) && $thermostat->getCache('lastOrder', 0) > $thermostat->getCache('lastTempIn', 0)) { log::add(__CLASS__, 'debug', $thermostat->getHumanName() . ' Last temps in < at current temp in'); - $coeff_indoor_heat = $thermostat->getConfiguration('coeff_indoor_heat') * (($thermostat->getCache('lastOrder') - $thermostat->getCache('lastTempIn')) / ($temp_in - $thermostat->getCache('lastTempIn'))); + $coeff_indoor_heat = $thermostat->getConfiguration('coeff_indoor_heat') * (($thermostat->getCache('lastOrder', 0) - $thermostat->getCache('lastTempIn', 0)) / ($temp_in - $thermostat->getCache('lastTempIn', 0))); $coeff_indoor_heat = ($thermostat->getConfiguration('coeff_indoor_heat') * $thermostat->getConfiguration('coeff_indoor_heat_autolearn') + $coeff_indoor_heat) / ($thermostat->getConfiguration('coeff_indoor_heat_autolearn') + 1); $thermostat->setConfiguration('coeff_indoor_heat_autolearn', min($thermostat->getConfiguration('coeff_indoor_heat_autolearn') + 1, 50)); if ($coeff_indoor_heat < 0 || !is_numeric($coeff_indoor_heat)) { @@ -261,10 +261,10 @@ public static function temporal($_options) { $thermostat->setConfiguration('coeff_indoor_heat', round($coeff_indoor_heat, 2)); $thermostat->checkAndUpdateCmd('coeff_indoor_heat', round($coeff_indoor_heat, 2)); log::add(__CLASS__, 'debug', $thermostat->getHumanName() . ' New coeff heat indoor : ' . $coeff_indoor_heat); - } else if ($temp_out < $thermostat->getCache('lastOrder')) { + } else if ($temp_out < $thermostat->getCache('lastOrder', 0)) { log::add(__CLASS__, 'debug', $thermostat->getHumanName() . ' Learn outdoor heat'); $coeff_in = $thermostat->getConfiguration('coeff_indoor_heat'); - $coeff_outdoor = $coeff_in * (($thermostat->getCache('lastOrder') - $temp_in) / ($thermostat->getCache('lastOrder') - $temp_out)) + $thermostat->getConfiguration('coeff_outdoor_heat'); + $coeff_outdoor = $coeff_in * (($thermostat->getCache('lastOrder', 0) - $temp_in) / ($thermostat->getCache('lastOrder', 0) - $temp_out)) + $thermostat->getConfiguration('coeff_outdoor_heat'); $coeff_outdoor = ($thermostat->getConfiguration('coeff_outdoor_heat') * $thermostat->getConfiguration('coeff_outdoor_heat_autolearn') + $coeff_outdoor) / ($thermostat->getConfiguration('coeff_outdoor_heat_autolearn') + 1); $thermostat->setConfiguration('coeff_outdoor_heat_autolearn', min($thermostat->getConfiguration('coeff_outdoor_heat_autolearn') + 1, 50)); if ($coeff_outdoor < 0 || !is_numeric($coeff_outdoor)) { @@ -278,9 +278,9 @@ public static function temporal($_options) { if ($thermostat->getCache('lastState') == 'cool') { log::add(__CLASS__, 'debug', $thermostat->getHumanName() . ' Last state is cool'); - if ($temp_in < $thermostat->getCache('lastTempIn') && $thermostat->getCache('lastOrder') < $thermostat->getCache('lastTempIn')) { + if ($temp_in < $thermostat->getCache('lastTempIn', 0) && $thermostat->getCache('lastOrder', 0) < $thermostat->getCache('lastTempIn', 0)) { log::add(__CLASS__, 'debug', $thermostat->getHumanName() . ' Last temps in > at current temp in'); - $coeff_indoor_cool = $thermostat->getConfiguration('coeff_indoor_cool') * (($thermostat->getCache('lastTempIn') - $thermostat->getCache('lastOrder')) / ($thermostat->getCache('lastTempIn') - $temp_in)); + $coeff_indoor_cool = $thermostat->getConfiguration('coeff_indoor_cool') * (($thermostat->getCache('lastTempIn', 0) - $thermostat->getCache('lastOrder', 0)) / ($thermostat->getCache('lastTempIn', 0) - $temp_in)); $coeff_indoor_cool = ($thermostat->getConfiguration('coeff_indoor_cool') * $thermostat->getConfiguration('coeff_indoor_cool_autolearn') + $coeff_indoor_cool) / ($thermostat->getConfiguration('coeff_indoor_cool_autolearn') + 1); $thermostat->setConfiguration('coeff_indoor_cool_autolearn', min($thermostat->getConfiguration('coeff_indoor_cool_autolearn') + 1, 50)); if ($coeff_indoor_cool < 0 || !is_numeric($coeff_indoor_cool)) { @@ -289,10 +289,10 @@ public static function temporal($_options) { $thermostat->setConfiguration('coeff_indoor_cool', round($coeff_indoor_cool, 2)); $thermostat->checkAndUpdateCmd('coeff_indoor_cool', round($coeff_indoor_cool, 2)); log::add(__CLASS__, 'debug', $thermostat->getHumanName() . ' New coeff cool indoor : ' . $coeff_indoor_cool); - } else if ($temp_out > $thermostat->getCache('lastOrder')) { + } else if ($temp_out > $thermostat->getCache('lastOrder', 0)) { log::add(__CLASS__, 'debug', $thermostat->getHumanName() . ' Learn outdoor cool'); $coeff_in = $thermostat->getConfiguration('coeff_indoor_cool'); - $coeff_outdoor = $coeff_in * (($thermostat->getCache('lastOrder') - $temp_in) / ($thermostat->getCache('lastOrder') - $temp_out)) + $thermostat->getConfiguration('coeff_outdoor_cool'); + $coeff_outdoor = $coeff_in * (($thermostat->getCache('lastOrder', 0) - $temp_in) / ($thermostat->getCache('lastOrder', 0) - $temp_out)) + $thermostat->getConfiguration('coeff_outdoor_cool'); $coeff_outdoor = ($thermostat->getConfiguration('coeff_outdoor_cool') * $thermostat->getConfiguration('coeff_outdoor_cool_autolearn') + $coeff_outdoor) / ($thermostat->getConfiguration('coeff_outdoor_cool_autolearn') + 1); $thermostat->setConfiguration('coeff_outdoor_cool_autolearn', min($thermostat->getConfiguration('coeff_outdoor_cool_autolearn') + 1, 50)); if ($coeff_outdoor < 0 || !is_numeric($coeff_outdoor)) {