diff -r 13555c27b592 -r 5b6d7b640e52 www-thermferm/getstate.php --- a/www-thermferm/getstate.php Thu Apr 25 14:26:47 2024 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,174 +0,0 @@ - - * - * This file is part of ThermFerm - * - * This is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2, or (at your option) any - * later version. - * - * ThermFerm is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with ThermFerm; see the file COPYING. If not, write to the Free - * Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. - *****************************************************************************/ - -require_once('utilities.php'); - -if (isset($_GET["uuid"])) - $uuid = $_GET["uuid"]; -else - $uuid = "e53858c3-a97e-4b07-85e9-524257909f45"; - -$answer = send_cmd('UNIT GET '.$uuid); -$arr = explode("\r\n", $answer); - -$air_temperature = "NA"; -$air_state = "NA"; -$beer_temperature = "NA"; -$beer_state = "NA"; -$chiller_temperature = "NA"; -$chiller_state = "NA"; -$target_temperature_lo = "NA"; -$target_temperature_hi = "NA"; -$led1 = $led2 = $led3 = $sw1 = $sw2 = $sw3 = $alarmled = ""; -$fridge_set = "NA"; -$beer_set = "NA"; -$heater = $cooler = $chiller = $fan = $psu = $door = "no"; -$prof_state = "OFF"; -$mode = "NA"; -$cooler_state = "NA"; -$heater_state = "NA"; -$fan_state = "NA"; - -if (startsWith($arr[0], "213")) { - $j = 1; - while (1) { - if (strcmp($arr[$j], ".") == 0) - break; - $f = explode(",", $arr[$j]); - - if ($f[0] == "AIR_STATE") - $air_state = $f[1]; - if (($f[0] == "AIR_TEMPERATURE") && ($air_state == "YES")) - $air_temperature = $f[1]; - if ($f[0] == "BEER_STATE") - $beer_state = $f[1]; - if (($f[0] == "BEER_TEMPERATURE") && ($beer_state == "YES")) - $beer_temperature = $f[1]; - if ($f[0] == "CHILLER_STATE") - $chiller_state = $f[1]; - if (($f[0] == "CHILLER_TEMPERATURE") && ($chiller_state == "YES")) - $chiller_temperature = $f[1]; - if ($f[0] == "MODE") - $mode = $f[1]; - if (($f[0] == "COOLER_ADDRESS") && (strcmp($f[1], "(null)"))) - $cooler = "yes"; - if ($f[0] == "COOLER_STATE") { - $cooler_state = $f[1]; - $led1 = $f[1] ? '
' : '
'; - } - if (($f[0] == "HEATER_ADDRESS") && (strcmp($f[1], "(null)"))) - $heater = "yes"; - if ($f[0] == "HEATER_STATE") { - $heater_state = $f[1]; - $led2 = $f[1] ? '
' : '
'; - } - if (($f[0] == "FAN_ADDRESS") && (strcmp($f[1], "(null)"))) - $fan = "yes"; - if ($f[0] == "FAN_STATE") { - $fan_state = $f[1]; - $led3 = $f[1] ? '
' : '
'; - } - if (($f[0] == "PSU_ADDRESS") && (strcmp($f[1], "(null)"))) - $psu = "yes"; - if (($f[0] == "DOOR_ADDRESS") && (strcmp($f[1], "(null)"))) - $door = "yes"; - if (($f[0] == "BEER_SET_LO") && ($mode == "BEER")) - $target_temperature_lo = $f[1]; - if (($f[0] == "BEER_SET_HI") && ($mode == "BEER")) - $target_temperature_hi = $f[1]; - if (($f[0] == "FRIDGE_SET_LO") && ($mode == "FRIDGE")) - $target_temperature_lo = $f[1]; - if (($f[0] == "FRIDGE_SET_HI") && ($mode == "FRIDGE")) - $target_temperature_hi = $f[1]; - if (($f[0] == "PROF_TARGET_LO") && ($mode == "PROFILE")) - $target_temperature_lo = $f[1]; - if (($f[0] == "PROF_TARGET_HI") && ($mode == "PROFILE")) - $target_temperature_hi = $f[1]; - if (($f[0] == "PROF_STATE") && ($mode == "PROFILE")) - $prof_state = 'State: '.$f[1]; - if ($f[0] == "ALARM") - $alarmled = $f[1] ? '
' : '
'; - $j++; - } -} - - -/* - * Create the value for the mode select radio buttons - */ -strcmp($mode, "OFF") ? $se = "" : $se = " checked"; -$modestr = ' Off
'.PHP_EOL; -strcmp($mode, "NONE") ? $se = "" : $se = " checked"; -$modestr .= ' None
'.PHP_EOL; -(strcmp($heater, "no") || strcmp($cooler, "no")) ? $dis = "" : $dis = " disabled"; -strcmp($mode, "FRIDGE") ? $se = "" : $se = " checked"; -$modestr .= ' Fridge
'.PHP_EOL; -strcmp($mode, "BEER") ? $se = "" : $se = " checked"; -$modestr .= ' Beer
'.PHP_EOL; -strcmp($mode, "PROFILE") ? $se = "" : $se = " checked"; -$modestr .= ' Profile'.PHP_EOL; - - -/* - * Create the values for the on/off switches - */ -(($mode == "NONE") && ($cooler == "yes")) ? $dis = "" : $dis = " disabled"; -($cooler_state == "0") ? $ch = " checked" : $ch = ""; -$sw1 = ' Off
'.PHP_EOL; -($cooler_state == "100") ? $ch = " checked" : $ch = ""; -$sw1 .= ' On'.PHP_EOL; - -(($mode == "NONE") && ($heater == "yes")) ? $dis = "" : $dis = " disabled"; -($heater_state == "0") ? $ch = " checked" : $ch = ""; -$sw2 = ' Off
'.PHP_EOL; -($heater_state == "100") ? $ch = " checked" : $ch = ""; -$sw2 .= ' On'.PHP_EOL; - -(($mode == "NONE") && ($fan== "yes")) ? $dis = "" : $dis = " disabled"; -($fan_state == "0") ? $ch = " checked" : $ch = ""; -$sw3 = ' Off
'.PHP_EOL; -($fan_state == "100") ? $ch = " checked" : $ch = ""; -$sw3 .= ' On'.PHP_EOL; - - - -$reply = array ( - 'air_temperature' => $air_temperature, - 'beer_temperature' => $beer_temperature, - 'chiller_temperature' => $chiller_temperature, - 'target_temperature_lo' => $target_temperature_lo, - 'target_temperature_hi' => $target_temperature_hi, - 'mode' => $modestr, - 'led1' => $led1, - 'led2' => $led2, - 'led3' => $led3, - 'sw1' => $sw1, - 'sw2' => $sw2, - 'sw3' => $sw3, - 'profile_state' => $prof_state, - 'alarm' => $alarmled -); - - -echo json_encode($reply); -?>