You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The original functions.php had a statement which set the temperature to 9999 if it couldn't read a sensor value (ie: sensor drops off network/disconnects). When I modified the way sensors were read into file, I broke that.
The problem is this:
Since temps are read once a minute from cron, and if a sensor goes rouge while the temp is being read, it will come back as 0 degrees in the file. This triggers the automatic heating function to turn everything on and heat the tub from a false reading. We need to get the else statement working again so it won't kick on the heater and pump. If the (tub) temp is set to 9999 it won't ever turn on because it's value is above any set temp.
Here's the code as it exists now.
function GetTemp($address)
{
global $m_connect;
$sql = "SELECT * FROM sensors WHERE address='$address' LIMIT 1";
$query = mysqli_query($m_connect,$sql);
$sensor = mysqli_fetch_assoc($query);
//File to read
$file = '/var/log/sensors/'.$address.'/sonoff_th';
if (file_exists($file)) {
//Read the file line by line
$lines = file($file);
//Get the temp from second line
$temp = ($lines[1]);
} else {
$temp = "9999";
}
return $temp + $sensor['calibration_value'];
}
The text was updated successfully, but these errors were encountered:
The original functions.php had a statement which set the temperature to 9999 if it couldn't read a sensor value (ie: sensor drops off network/disconnects). When I modified the way sensors were read into file, I broke that.
The problem is this:
Since temps are read once a minute from cron, and if a sensor goes rouge while the temp is being read, it will come back as 0 degrees in the file. This triggers the automatic heating function to turn everything on and heat the tub from a false reading. We need to get the else statement working again so it won't kick on the heater and pump. If the (tub) temp is set to 9999 it won't ever turn on because it's value is above any set temp.
Here's the code as it exists now.
function GetTemp($address)
{
global $m_connect;
$sql = "SELECT * FROM sensors WHERE address='$address' LIMIT 1";
$query = mysqli_query($m_connect,$sql);
$sensor = mysqli_fetch_assoc($query);
//File to read
$file = '/var/log/sensors/'.$address.'/sonoff_th';
if (file_exists($file)) {
//Read the file line by line
$lines = file($file);
//Get the temp from second line
$temp = ($lines[1]);
} else {
$temp = "9999";
}
return $temp + $sensor['calibration_value'];
}
The text was updated successfully, but these errors were encountered: