Skip to content

Commit

Permalink
fix for php8
Browse files Browse the repository at this point in the history
  • Loading branch information
zoic21 authored Mar 15, 2024
1 parent b6495f5 commit 1ab33fa
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions core/class/thermostat.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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)) {
Expand All @@ -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)) {
Expand All @@ -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)) {
Expand All @@ -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)) {
Expand Down

0 comments on commit 1ab33fa

Please sign in to comment.