I'm trying to calculate if heater need start or stop.
But I have some difficult with the control code:
$hysteresis = 0.5;
$min_limit = $target_temperature-$hysteresis;
$max_limit = $target_temperature+$hysteresis;
if ($current_temperature<=$min_limit) {
echo 'eseguito parte 1';
return true;
}
if ($current_temperature>=$max_limit) {
echo 'eseguito parte 2';
return false;
}
E.g for a target temperature == 21, heater need to start at 20.5 and stop at 21.5.
But with current_temperature == 21.2 (for example) neither of the code is executed.
How can I intercept also the intermediate case?
Thank you
EDIT:
Thank to the comments of Mike and Federkun:
if ( ( ($current_temperature<=$min_limit)===false ) && ( ($current_temperature>=$max_limit)===false ) ) {
return true;
}