diff -r 8c52b09bdecc -r abdba3f9d9e2 www-thermferm/getstate.php --- a/www-thermferm/getstate.php Wed Aug 20 14:01:15 2014 +0200 +++ b/www-thermferm/getstate.php Wed Aug 20 17:42:35 2014 +0200 @@ -36,9 +36,11 @@ $beer_temperature = "NA"; $beer_state = "NA"; $target_temperature = "NA"; -$led1 = $led2 = $led3 = $sw1 = $sw2 = $sw3 = 0; +$led1 = $led2 = $led3 = $sw1 = $sw2 = $sw3 = ""; $fridge_set = "NA"; $beer_set = "NA"; +$heater = $cooler = $fan = "no"; + if (startsWith($arr[0], "213")) { $j = 1; @@ -57,12 +59,24 @@ $beer_temperature = $f[1]; if ($f[0] == "MODE") $mode = $f[1]; - if ($f[0] == "COOLER_STATE") + 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_STATE") + } + 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_STATE") + } + 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] == "BEER_SET") && ($mode == "BEER")) $target_temperature = $f[1]; if (($f[0] == "FRIDGE_SET") && ($mode == "FRIDGE")) @@ -74,11 +88,50 @@ } +/* + * 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, 'target_temperature' => $target_temperature, - 'mode' => $mode, + 'mode' => $modestr, 'led1' => $led1, 'led2' => $led2, 'led3' => $led3,