Added chiller configuration items

Mon, 26 Jun 2017 19:21:07 +0200

author
Michiel Broek <mbroek@mbse.eu>
date
Mon, 26 Jun 2017 19:21:07 +0200
changeset 518
fd36bedab944
parent 517
5fd12d9f3f84
child 519
6bf06b1b6232

Added chiller configuration items

thermferm/mqtt.c file | annotate | diff | comparison | revisions
thermferm/rdconfig.c file | annotate | diff | comparison | revisions
thermferm/server.c file | annotate | diff | comparison | revisions
thermferm/thermferm.c file | annotate | diff | comparison | revisions
thermferm/thermferm.h file | annotate | diff | comparison | revisions
www-thermferm/css/style.css file | annotate | diff | comparison | revisions
www-thermferm/units.php file | annotate | diff | comparison | revisions
--- a/thermferm/mqtt.c	Mon Jun 26 13:58:11 2017 +0200
+++ b/thermferm/mqtt.c	Mon Jun 26 19:21:07 2017 +0200
@@ -272,6 +272,19 @@
 	payload = xstrcat(payload, (char *)",\"beer\":null");
     }
 
+    if (unit->chiller_address) {
+	payload = xstrcat(payload, (char *)",\"chiller\":{\"address\":\"");
+	payload = xstrcat(payload, unit->chiller_address);
+	payload = xstrcat(payload, (char *)"\",\"state\":\"");
+	payload = xstrcat(payload, (char *)TEMPSTATE[unit->chiller_state]);
+	payload = xstrcat(payload, (char *)"\",\"temperature\":");
+	sprintf(buf, "%.3f", unit->chiller_temperature / 1000.0);
+	payload = xstrcat(payload, buf);
+	payload = xstrcat(payload, (char *)"}");
+    } else {
+	payload = xstrcat(payload, (char *)",\"chiller\":null");
+    }
+
     if (unit->heater_address) {
 	payload = xstrcat(payload, (char *)",\"heater\":{\"address\":\"");
 	payload = xstrcat(payload, unit->heater_address);
--- a/thermferm/rdconfig.c	Mon Jun 26 13:58:11 2017 +0200
+++ b/thermferm/rdconfig.c	Mon Jun 26 19:21:07 2017 +0200
@@ -81,6 +81,8 @@
 	    free(tmp2->air_address);
 	if (tmp2->beer_address)
 	    free(tmp2->beer_address);
+	if (tmp2->chiller_address)
+	    free(tmp2->chiller_address);
 	if (tmp2->heater_address)
 	    free(tmp2->heater_address);
 	if (tmp2->cooler_address)
@@ -383,6 +385,24 @@
 		    return 1;
 		}
 	    }
+	    if (tmp3->chiller_address) {
+		if (((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "CHILLER_ADDRESS", "%s", tmp3->chiller_address)) < 0)) {
+		    syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement");
+		    return 1;
+		}
+		if (((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "CHILLER_STATE", "%d", tmp3->chiller_state)) < 0)) {
+		    syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement");
+		    return 1;
+		}
+		if (((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "CHILLER_TEMPERATURE", "%d", tmp3->chiller_temperature)) < 0)) {
+		    syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement");
+		    return 1;
+		}
+		if (((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "CHILLER_IDX", "%d", tmp3->chiller_idx)) < 0)) {
+		    syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement");
+		    return 1;
+		}
+	    }
 	    if (tmp3->heater_address) {
 		if (((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "HEATER_ADDRESS", "%s", tmp3->heater_address)) < 0)) {
 		    syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement");
@@ -1069,15 +1089,15 @@
     unit = (units_list *)malloc(sizeof(units_list));
     unit->next = NULL;
     unit->version = 1;
-    unit->uuid = unit->name = unit->alias = unit->air_address = unit->beer_address = unit->heater_address = \
+    unit->uuid = unit->name = unit->alias = unit->air_address = unit->beer_address = unit->chiller_address = unit->heater_address = \
 		 unit->cooler_address = unit->fan_address = unit->door_address = \
 		 unit->light_address = unit->psu_address = unit->profile = NULL;
     unit->volume = unit->prof_peak_abs = unit->prof_peak_rel = 0.0;
-    unit->air_temperature = unit->beer_temperature = unit->beer_set = unit->fridge_set = 20.0;
-    unit->air_state = unit->beer_state = 1; // missing
+    unit->air_temperature = unit->beer_temperature = unit->chiller_temperature = unit->beer_set = unit->fridge_set = 20.0;
+    unit->air_state = unit->beer_state = unit->chiller_state = 1; // missing
     unit->heater_state = unit->cooler_state = unit->fan_state = unit->door_state = \
 			 unit->light_state = unit->psu_state = unit->mode = unit->prof_state = 0;
-    unit->air_idx = unit->beer_idx = unit->heater_idx = unit->cooler_idx = unit->fan_idx = \
+    unit->air_idx = unit->beer_idx = unit->chiller_idx = unit->heater_idx = unit->cooler_idx = unit->fan_idx = \
 		    unit->door_idx = unit->light_idx = unit->psu_idx = 0;
     unit->heater_delay = unit->cooler_delay = unit->fan_delay = 20;	/* 5 minutes delay */
     unit->light_delay = 1;						/* 15 seconds delay	*/
@@ -1160,6 +1180,27 @@
 		unit->beer_temperature = ival;
 	    xmlFree(key);
 	}
+	if ((!xmlStrcmp(cur->name, (const xmlChar *)"CHILLER_ADDRESS"))) {
+	    unit->chiller_address = (char *)xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
+	}
+	if ((!xmlStrcmp(cur->name, (const xmlChar *)"CHILLER_STATE"))) {
+	    key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
+	    if (sscanf((const char *)key, "%d", &ival) == 1)
+		unit->chiller_state = ival;
+	    xmlFree(key);
+	}
+	if ((!xmlStrcmp(cur->name, (const xmlChar *)"CHILLER_IDX"))) {
+	    key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
+	    if (sscanf((const char *)key, "%d", &ival) == 1)
+		unit->chiller_idx = ival;
+	    xmlFree(key);
+	}
+	if ((!xmlStrcmp(cur->name, (const xmlChar *)"CHILLER_TEMPERATURE"))) {
+	    key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
+	    if (sscanf((const char *)key, "%d", &ival) == 1)
+		unit->chiller_temperature = ival;
+	    xmlFree(key);
+	}
 	if ((!xmlStrcmp(cur->name, (const xmlChar *)"HEATER_ADDRESS"))) {
 	    unit->heater_address = (char *)xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
 	}
--- a/thermferm/server.c	Mon Jun 26 13:58:11 2017 +0200
+++ b/thermferm/server.c	Mon Jun 26 19:21:07 2017 +0200
@@ -1864,6 +1864,9 @@
 		if (current->beer_address)
 		    free(current->beer_address);
 		current->beer_address = NULL;
+		if (current->chiller_address)
+		    free(current->chiller_address);
+		current->chiller_address = NULL;
 		if (current->heater_address)
 		    free(current->heater_address);
 		current->heater_address = NULL;
@@ -1904,6 +1907,9 @@
 		if (current->beer_address)
 		    free(current->beer_address);
 		current->beer_address = NULL;
+		if (current->chiller_address)
+		    free(current->chiller_address);
+		current->chiller_address = NULL;
 		if (current->heater_address)
 		    free(current->heater_address);
 		current->heater_address = NULL;
@@ -2009,14 +2015,14 @@
 	uuid_unparse(uu, unit->uuid);
 	unit->name = xstrcpy(param);
 	unit->alias = xstrcpy(an);
-	unit->air_address = unit->beer_address = unit->heater_address = unit->cooler_address = \
+	unit->air_address = unit->beer_address = unit->chiller_address = unit->heater_address = unit->cooler_address = \
 			    unit->fan_address = unit->door_address = unit->light_address = \
 			    unit->psu_address = unit->profile = NULL;
-	unit->air_idx = unit->beer_idx = unit->heater_idx = unit->cooler_idx = unit->fan_idx = \
+	unit->air_idx = unit->beer_idx = unit->chiller_idx = unit->heater_idx = unit->cooler_idx = unit->fan_idx = \
 			unit->door_idx = unit->light_idx = unit->psu_idx = 0;
 	unit->volume = unit->prof_peak_abs = unit->prof_peak_rel = 0.0;
-	unit->air_state = unit->beer_state = 1;
-	unit->air_temperature = unit->beer_temperature = 20000;
+	unit->air_state = unit->beer_state = unit->chiller_state = 1;
+	unit->air_temperature = unit->beer_temperature = unit->chiller_temperature = 20000;
 	unit->beer_set = unit->fridge_set = 20.0;
 	unit->heater_state = unit->cooler_state = unit->fan_state = unit->door_state = unit->mode = \
 			     unit->light_state = unit->psu_state = unit->prof_state = 0;
@@ -2102,6 +2108,10 @@
 		srv_send((char *)"BEER_STATE,%s", TEMPSTATE[unit->beer_state]);
 		srv_send((char *)"BEER_TEMPERATURE,%.3f", unit->beer_temperature / 1000.0);
 		srv_send((char *)"BEER_IDX,%d", unit->beer_idx);
+		srv_send((char *)"CHILLER_ADDRESS,%s", MBSE_SS(unit->chiller_address));
+		srv_send((char *)"CHILLER_STATE,%s", TEMPSTATE[unit->chiller_state]);
+		srv_send((char *)"CHILLER_TEMPERATURE,%.3f", unit->chiller_temperature / 1000.0);
+		srv_send((char *)"CHILLER_IDX,%d", unit->chiller_idx);
 		srv_send((char *)"HEATER_ADDRESS,%s", unit->heater_address);
 		srv_send((char *)"HEATER_STATE,%d", unit->heater_state);
 		srv_send((char *)"HEATER_DELAY,%d", unit->heater_delay);
@@ -2264,6 +2274,27 @@
 				    unit->beer_idx = ival;
 				}
 
+			    } else if (strcmp(kwd, (char *)"CHILLER_ADDRESS") == 0) {
+				if (val && unit->chiller_address && (strcmp(val, unit->chiller_address)))
+				    syslog(LOG_NOTICE, "Fermenter unit %s chiller address `%s' to `%s'", unit->uuid, unit->chiller_address, val);
+				if (unit->chiller_address) {
+				    device_count(FALSE, unit->chiller_address);
+				    free(unit->chiller_address);
+				}
+				if (val) {
+				    unit->chiller_address = xstrcpy(val);
+				    device_count(TRUE, unit->chiller_address);
+				} else
+				    unit->chiller_address = NULL;
+				unit->mqtt_flag |= MQTT_FLAG_DATA;
+
+			    } else if (val && (strcmp(kwd, (char *)"CHILLER_IDX") == 0)) {
+				if (sscanf(val, "%d", &ival) == 1) {
+				    if (unit->chiller_idx != ival)
+					syslog(LOG_NOTICE, "Fermenter unit %s chiller idx %d to %d", unit->uuid, unit->chiller_idx, ival);
+				    unit->beer_idx = ival;
+				}
+
 			    } else if (strcmp(kwd, (char *)"HEATER_ADDRESS") == 0) {
 				if (val && unit->heater_address && (strcmp(val, unit->heater_address)))
 				    syslog(LOG_NOTICE, "Fermenter unit %s heater address `%s' to `%s'", unit->uuid, unit->heater_address, val);
--- a/thermferm/thermferm.c	Mon Jun 26 13:58:11 2017 +0200
+++ b/thermferm/thermferm.c	Mon Jun 26 19:21:07 2017 +0200
@@ -1240,7 +1240,7 @@
 			    unit->air_temperature = temp;
 			    unit->air_state = 0;
 			} else {
-			    syslog(LOG_NOTICE, "deviation error deviation=%d, old=%d new=%d", deviation, unit->air_temperature, temp);
+			    syslog(LOG_NOTICE, "deviation error air deviation=%d, old=%d new=%d", deviation, unit->air_temperature, temp);
 			}
 		    } else if (rc == DEVPRESENT_ERROR) {
 			unit->air_state = 1;
@@ -1262,7 +1262,7 @@
     			    unit->beer_temperature = temp;
 			    unit->beer_state = 0;
 			} else {
-			    syslog(LOG_NOTICE, "deviation error deviation=%d, old=%d new=%d", deviation, unit->beer_temperature, temp);
+			    syslog(LOG_NOTICE, "deviation error beer deviation=%d, old=%d new=%d", deviation, unit->beer_temperature, temp);
 			}
 		    } else if (rc == DEVPRESENT_ERROR) {
 			unit->beer_state = 1;
@@ -1271,6 +1271,28 @@
 		    }
 		}
 
+		if (unit->chiller_address) {
+		    rc = device_in(unit->chiller_address, &temp);
+		    if (rc == DEVPRESENT_YES) {
+			deviation = 40000;
+			if ((unit->chiller_temperature == 0) ||
+			    (unit->chiller_temperature && (temp > (int)unit->chiller_temperature - deviation) && (temp < ((int)unit->chiller_temperature + deviation)))) {
+			    if (unit->chiller_temperature != temp) {
+				unit->mqtt_flag |= MQTT_FLAG_DATA;
+				pub_domoticz_temp(unit->chiller_idx, temp);
+			    }
+			    unit->chiller_temperature = temp;
+			    unit->chiller_state = 0;
+			} else {
+			    syslog(LOG_NOTICE, "deviation error chiller deviation=%d, old=%d new=%d", deviation, unit->chiller_temperature, temp);
+			}
+		    } else if (rc == DEVPRESENT_ERROR) {
+			unit->chiller_state = 1;
+		    } else {
+			unit->chiller_state = 2;
+		    }
+		}
+
 		/*
 		 * Unit door state, default is closed.
 		 */
@@ -1629,6 +1651,14 @@
 			if ((unit->mode == UNITMODE_BEER) && ((unit->air_temperature / 1000.0) < (unit->PID_cool->Input - 5.0))) {
 			    unit->PID_cool->OutP = 0.0;
 			}
+			/*
+			 * Prevent cooling if we use a chiller and the chiller temperature is not low enough.
+			 */
+			if (unit->chiller_address && (unit->chiller_state == 0)) {
+			    if ((unit->chiller_temperature / 1000.0) > (unit->PID_cool->Input - 1)) {
+			    	unit->PID_cool->OutP = 0.0;
+			    }
+			}
 		    	if (debug)
 			    fprintf(stdout, "Cool: sp=%.2f Input=%.2f iState=%.2f Err=%.2f Out=%.2f\n",
 				unit->PID_cool->SetP, unit->PID_cool->Input, unit->PID_cool->iState, unit->PID_cool->Err, unit->PID_cool->OutP);
--- a/thermferm/thermferm.h	Mon Jun 26 13:58:11 2017 +0200
+++ b/thermferm/thermferm.h	Mon Jun 26 19:21:07 2017 +0200
@@ -142,6 +142,10 @@
     int			beer_state;		/* 0=ok, 1=missing, 2=error 	*/
     int			beer_temperature;	/* Beer temperature in C * 1000	*/
     int			beer_idx;		/* Domoticz idx			*/
+    char		*chiller_address;	/* DS18B20 address		*/
+    int			chiller_state;		/* 0=ok, 1=missing, 2=error	*/
+    int			chiller_temperature;	/* Chiller temp. in C * 1000	*/
+    int			chiller_idx;		/* Domoticz idx			*/
     char		*heater_address;	/* Heater relay or PWM		*/
     int			heater_state;		/* Heater state 0..100		*/
     int			heater_delay;		/* Heater delay time /15 sec	*/
--- a/www-thermferm/css/style.css	Mon Jun 26 13:58:11 2017 +0200
+++ b/www-thermferm/css/style.css	Mon Jun 26 19:21:07 2017 +0200
@@ -149,7 +149,7 @@
 }
 
 td.editfield {
-    width: 500px;
+    width: 300px;
     padding: 1px 3px 1px 3px;
 }
 
--- a/www-thermferm/units.php	Mon Jun 26 13:58:11 2017 +0200
+++ b/www-thermferm/units.php	Mon Jun 26 19:21:07 2017 +0200
@@ -96,6 +96,8 @@
 	$cmd[] = "AIR_IDX,".$_POST['AirIdx'];
 	$cmd[] = "BEER_ADDRESS,".$_POST['BeerAddress'];
 	$cmd[] = "BEER_IDX,".$_POST['BeerIdx'];
+	$cmd[] = "CHILLER_ADDRESS,".$_POST['ChillerAddress'];
+	$cmd[] = "CHILLER_IDX,".$_POST['ChillerIdx'];
 	$cmd[] = "HEATER_ADDRESS,".$_POST['HeaterAddress'];
 	$cmd[] = "HEATER_DELAY,".$_POST['HeaterDelay'];
 	$cmd[] = "HEATER_IDX,".$_POST['HeaterIdx'];
@@ -137,6 +139,8 @@
     unset($_POST['AirIdx']);
     unset($_POST['BeerAddress']);
     unset($_POST['BeerIdx']);
+    unset($_POST['ChillerAddress']);
+    unset($_POST['ChillerIdx']);
     unset($_POST['HeaterAddress']);
     unset($_POST['HeaterDelay']);
     unset($_POST['HeaterIdx']);
@@ -197,7 +201,7 @@
 
     global $arr;
 
-    if (isset($_POST['UUID']) && isset($_POST['Name']) && isset($_POST['Volume']) && isset($_POST['AirAddress']) &&
+    if (isset($_POST['UUID']) && isset($_POST['Name']) && isset($_POST['Volume']) && isset($_POST['AirAddress']) && isset($_POST['ChillerAddress']) &&
 	isset($_POST['BeerAddress']) && isset($_POST['HeaterAddress']) && isset($_POST['CoolerAddress']) && isset($_POST['LightAddress']) &&
 	isset($_POST['HeaterDelay']) && isset($_POST['CoolerDelay']) && isset($_POST['LightDelay']) && isset($_POST['PSUAddress']) &&
 	isset($_POST['FanAddress']) && isset($_POST['DoorAddress']) && isset($_POST['TempSetMin']) && isset($_POST['TempSetMax']) &&
@@ -205,7 +209,7 @@
 	isset($_POST['PIDH_pGain']) && isset($_POST['PIDH_iGain']) && isset($_POST['PIDH_dGain']) && isset($_POST['PIDH_idleRange']) &&
 	isset($_POST['PIDC_iMax']) && isset($_POST['PIDH_iMax']) && isset($_POST['AirIdx']) && isset($_POST['BeerIdx']) &&
 	isset($_POST['HeaterIdx']) && isset($_POST['CoolerIdx']) && isset($_POST['LightIdx']) && isset($_POST['DoorIdx']) &&
-	isset($_POST['PSUIdx']) && isset($_POST['FanIdx']) &&
+	isset($_POST['PSUIdx']) && isset($_POST['FanIdx']) && isset($_POST['ChillerIdx']) &&
 	isset($_POST['FanDelay']) && isset($_POST['key']) && isset($_POST['command'])) {
 
 	if ($_POST['key'] == 'Cancel')
@@ -360,13 +364,13 @@
 	    if ($f[0] == "NAME") {
     		$outstr .= '       <tr class="editor">'.PHP_EOL;
     		$outstr .= '        <td class="editname">Unit Name</td>'.PHP_EOL;
-    		$outstr .= '        <td class="editfield"><input type="text" name="Name" size="50" value="'.$f[1].'"></td>'.PHP_EOL;
+    		$outstr .= '        <td colspan="3" class="editfield"><input type="text" name="Name" size="50" value="'.$f[1].'"></td>'.PHP_EOL;
 		$outstr .= '       </tr>'.PHP_EOL;
 	    }
 	    if ($f[0] == "VOLUME") {
     		$outstr .= '       <tr class="editor">'.PHP_EOL;
     		$outstr .= '        <td class="editname">Unit Volume</td>'.PHP_EOL;
-    		$outstr .= '        <td class="editfield"><input type="text" name="Volume" size="5" value="'.$f[1].'"></td>'.PHP_EOL;
+    		$outstr .= '        <td colspan="3" class="editfield"><input type="text" name="Volume" size="5" value="'.$f[1].'"></td>'.PHP_EOL;
 		$outstr .= '       </tr>'.PHP_EOL;
 	    }
 	    if ($f[0] == "AIR_ADDRESS") {
@@ -388,10 +392,10 @@
 		    }
 		}
     		$outstr .= '        </select></td>'.PHP_EOL;
-		$outstr .= '       </tr>'.PHP_EOL;
+//		$outstr .= '       </tr>'.PHP_EOL;
 	    }
 	    if ($f[0] == "AIR_IDX") {
-		$outstr .= '       <tr class="editor">'.PHP_EOL;
+//		$outstr .= '       <tr class="editor">'.PHP_EOL;
 		$outstr .= '        <td class="editname">Air domoticz idx</td>'.PHP_EOL;
 		$outstr .= '        <td class="editfield"><input type="text" name="AirIdx" size="5" value="'.$f[1].'"></td>'.PHP_EOL;
 		$outstr .= '       </tr>'.PHP_EOL;
@@ -415,14 +419,41 @@
                     }
 		}
 		$outstr .= '        </select></td>'.PHP_EOL;
-		$outstr .= '       </tr>'.PHP_EOL;
+//		$outstr .= '       </tr>'.PHP_EOL;
 	    }
 	    if ($f[0] == "BEER_IDX") {
-		$outstr .= '       <tr class="editor">'.PHP_EOL;
+//		$outstr .= '       <tr class="editor">'.PHP_EOL;
 		$outstr .= '        <td class="editname">Beer domoticz idx</td>'.PHP_EOL;
 		$outstr .= '        <td class="editfield"><input type="text" name="BeerIdx" size="5" value="'.$f[1].'"></td>'.PHP_EOL;
 		$outstr .= '       </tr>'.PHP_EOL;
 	    }
+	    if ($f[0] == "CHILLER_ADDRESS") {
+		$outstr .= '       <tr class="editor">'.PHP_EOL;
+		$outstr .= '        <td class="editname">Chiller Sensor Address</td>'.PHP_EOL;
+		$outstr .= '        <td class="editfield"><select name="ChillerAddress">'.PHP_EOL;
+		$outstr .= '         <option value="">Not Assigned</option>'.PHP_EOL;
+		if (startsWith($devices[0], "212")) {
+		    $j = 1;
+		    while (1) {
+			if (strcmp($devices[$j], ".") == 0)
+			    break;
+			$g = explode(",", $devices[$j]);
+			if ($g[5] == "IN_ANALOG") {
+			    ($f[1] == $g[0]) ? $se = " selected" : $se = "";
+			    $outstr .= '         <option value="'.$g[0].'"'.$se.'>'.$g[1].' '.$g[4].'</option>'.PHP_EOL;
+			}
+			$j++;
+		    }
+		}
+		$outstr .= '        </select></td>'.PHP_EOL;
+//		$outstr .= '       </tr>'.PHP_EOL;
+	    }
+	    if ($f[0] == "CHILLER_IDX") {
+//		$outstr .= '       <tr class="editor">'.PHP_EOL;
+		$outstr .= '        <td class="editname">Chiller domoticz idx</td>'.PHP_EOL;
+		$outstr .= '        <td class="editfield"><input type="text" name="ChillerIdx" size="5" value="'.$f[1].'"></td>'.PHP_EOL;
+		$outstr .= '       </tr>'.PHP_EOL;
+	    }
 	    if ($f[0] == "HEATER_ADDRESS") {
 		$outstr .= '       <tr class="editor">'.PHP_EOL;
 		$outstr .= '        <td class="editname">Heater Switch Address</td>'.PHP_EOL;
@@ -442,10 +473,10 @@
 		    }
 		}
 		$outstr .= '        </select></td>'.PHP_EOL;
-		$outstr .= '       </tr>'.PHP_EOL;
+//		$outstr .= '       </tr>'.PHP_EOL;
 	    }
 	    if ($f[0] == "HEATER_DELAY") {
-		$outstr .= '       <tr class="editor">'.PHP_EOL;
+//		$outstr .= '       <tr class="editor">'.PHP_EOL;
 		$outstr .= '        <td class="editname">Heater Switch Delay</td>'.PHP_EOL;
 		$outstr .= '        <td class="editfield"><input type="text" name="HeaterDelay" size="5" value="'.$f[1].'"> seconds (0..720)</td>'.PHP_EOL;
 		$outstr .= '       </tr>'.PHP_EOL;
@@ -454,16 +485,22 @@
 		$outstr .= '       <tr class="editor">'.PHP_EOL;
 		$outstr .= '        <td class="editname">Heater domoticz idx</td>'.PHP_EOL;
 		$outstr .= '        <td class="editfield"><input type="text" name="HeaterIdx" size="5" value="'.$f[1].'"></td>'.PHP_EOL;
-		$outstr .= '       </tr>'.PHP_EOL;
+//		$outstr .= '       </tr>'.PHP_EOL;
 	    }
 	    if ($f[0] == "PIDH_IMAX") {
-		$outstr .= '       <tr class="editor">'.PHP_EOL;
+//		$outstr .= '       <tr class="editor">'.PHP_EOL;
 		$outstr .= '        <td class="editname">PID Heat Maximum</td>'.PHP_EOL;
 		$outstr .= '        <td class="editfield"><input type="text" name="PIDH_iMax" size="6" value="'.$f[1].'"> % (1..100)</td>'.PHP_EOL;
 		$outstr .= '       </tr>'.PHP_EOL;
 	    }
+	    if ($f[0] == "PIDH_IDLERANGE") {
+		$outstr .= '       <tr class="editor">'.PHP_EOL;
+		$outstr .= '        <td class="editname">Heater Idle Range</td>'.PHP_EOL;
+		$outstr .= '        <td class="editfield"><input type="text" name="PIDH_idleRange" size="6" value="'.$f[1].'"> &deg;C (Heater margin)</td>'.PHP_EOL;
+//		$outstr .= '       </tr>'.PHP_EOL;
+	    }
 	    if ($f[0] == "PIDH_PGAIN") {
-		$outstr .= '       <tr class="editor">'.PHP_EOL;
+//		$outstr .= '       <tr class="editor">'.PHP_EOL;
 		$outstr .= '        <td class="editname">PID Heat pGain</td>'.PHP_EOL;
 		$outstr .= '        <td class="editfield"><input type="text" name="PIDH_pGain" size="6" value="'.$f[1].'"> Proportional</td>'.PHP_EOL;
 		$outstr .= '       </tr>'.PHP_EOL;
@@ -472,20 +509,14 @@
 		$outstr .= '       <tr class="editor">'.PHP_EOL;
 		$outstr .= '        <td class="editname">PID Heat iGain</td>'.PHP_EOL;
 		$outstr .= '        <td class="editfield"><input type="text" name="PIDH_iGain" size="6" value="'.$f[1].'"> Intergral</td>'.PHP_EOL;
-		$outstr .= '       </tr>'.PHP_EOL;
+//		$outstr .= '       </tr>'.PHP_EOL;
 	    }
 	    if ($f[0] == "PIDH_DGAIN") {
-		$outstr .= '       <tr class="editor">'.PHP_EOL;
+//		$outstr .= '       <tr class="editor">'.PHP_EOL;
 		$outstr .= '        <td class="editname">PID Heat dGain</td>'.PHP_EOL;
 		$outstr .= '        <td class="editfield"><input type="text" name="PIDH_dGain" size="6" value="'.$f[1].'"> Derivative</td>'.PHP_EOL;
 		$outstr .= '       </tr>'.PHP_EOL;
 	    }
-	    if ($f[0] == "PIDH_IDLERANGE") {
-		$outstr .= '       <tr class="editor">'.PHP_EOL;
-		$outstr .= '        <td class="editname">Heater Idle Range</td>'.PHP_EOL;
-		$outstr .= '        <td class="editfield"><input type="text" name="PIDH_idleRange" size="6" value="'.$f[1].'"> &deg;C (Heater margin)</td>'.PHP_EOL;
-		$outstr .= '       </tr>'.PHP_EOL;
-	    }
 	    if ($f[0] == "COOLER_ADDRESS") {
 		$outstr .= '       <tr class="editor">'.PHP_EOL;
 		$outstr .= '        <td class="editname">Cooler Switch Address</td>'.PHP_EOL;
@@ -505,10 +536,10 @@
 		    }
 		}
 		$outstr .= '        </select></td>'.PHP_EOL;
-		$outstr .= '       </tr>'.PHP_EOL;
+//		$outstr .= '       </tr>'.PHP_EOL;
 	    }
 	    if ($f[0] == "COOLER_DELAY") {
-		$outstr .= '       <tr class="editor">'.PHP_EOL;
+//		$outstr .= '       <tr class="editor">'.PHP_EOL;
 		$outstr .= '        <td class="editname">Cooler Switch Delay</td>'.PHP_EOL;
 		$outstr .= '        <td class="editfield"><input type="text" name="CoolerDelay" size="5" value="'.$f[1].'"> seconds (0..720)</td>'.PHP_EOL;
 		$outstr .= '       </tr>'.PHP_EOL;
@@ -517,16 +548,22 @@
 		$outstr .= '       <tr class="editor">'.PHP_EOL;
 		$outstr .= '        <td class="editname">Cooler domoticz idx</td>'.PHP_EOL;
 		$outstr .= '        <td class="editfield"><input type="text" name="CoolerIdx" size="5" value="'.$f[1].'"></td>'.PHP_EOL;
-		$outstr .= '       </tr>'.PHP_EOL;
+//		$outstr .= '       </tr>'.PHP_EOL;
 	    }
 	    if ($f[0] == "PIDC_IMAX") {
-		$outstr .= '       <tr class="editor">'.PHP_EOL;
+//		$outstr .= '       <tr class="editor">'.PHP_EOL;
 		$outstr .= '        <td class="editname">PID Cool Maximum</td>'.PHP_EOL;
 		$outstr .= '        <td class="editfield"><input type="text" name="PIDC_iMax" size="6" value="'.$f[1].'"> % (1..100)</td>'.PHP_EOL;
 		$outstr .= '       </tr>'.PHP_EOL;
 	    }
+	    if ($f[0] == "PIDC_IDLERANGE") {
+		$outstr .= '       <tr class="editor">'.PHP_EOL;
+		$outstr .= '        <td class="editname">Cooler Idle Range</td>'.PHP_EOL;
+		$outstr .= '        <td class="editfield"><input type="text" name="PIDC_idleRange" size="6" value="'.$f[1].'"> &deg;C (Cooler margin)</td>'.PHP_EOL;
+//		$outstr .= '       </tr>'.PHP_EOL;
+	    }
 	    if ($f[0] == "PIDC_PGAIN") {
-		$outstr .= '       <tr class="editor">'.PHP_EOL;
+//		$outstr .= '       <tr class="editor">'.PHP_EOL;
 		$outstr .= '        <td class="editname">PID Cool pGain</td>'.PHP_EOL;
 		$outstr .= '        <td class="editfield"><input type="text" name="PIDC_pGain" size="6" value="'.$f[1].'"> Proportional</td>'.PHP_EOL;
 		$outstr .= '       </tr>'.PHP_EOL;
@@ -535,20 +572,14 @@
 		$outstr .= '       <tr class="editor">'.PHP_EOL;
 		$outstr .= '        <td class="editname">PID Cool iGain</td>'.PHP_EOL;
 		$outstr .= '        <td class="editfield"><input type="text" name="PIDC_iGain" size="6" value="'.$f[1].'"> Intergral</td>'.PHP_EOL;
-		$outstr .= '       </tr>'.PHP_EOL;
+//		$outstr .= '       </tr>'.PHP_EOL;
 	    }
 	    if ($f[0] == "PIDC_DGAIN") {
-		$outstr .= '       <tr class="editor">'.PHP_EOL;
+//		$outstr .= '       <tr class="editor">'.PHP_EOL;
 		$outstr .= '        <td class="editname">PID Cool dGain</td>'.PHP_EOL;
 		$outstr .= '        <td class="editfield"><input type="text" name="PIDC_dGain" size="6" value="'.$f[1].'"> Derivative</td>'.PHP_EOL;
 		$outstr .= '       </tr>'.PHP_EOL;
 	    }
-	    if ($f[0] == "PIDC_IDLERANGE") {
-		$outstr .= '       <tr class="editor">'.PHP_EOL;
-		$outstr .= '        <td class="editname">Cooler Idle Range</td>'.PHP_EOL;
-		$outstr .= '        <td class="editfield"><input type="text" name="PIDC_idleRange" size="6" value="'.$f[1].'"> &deg;C (Cooler margin)</td>'.PHP_EOL;
-		$outstr .= '       </tr>'.PHP_EOL;
-	    }
 	    if ($f[0] == "FAN_ADDRESS") {
 		$outstr .= '       <tr class="editor">'.PHP_EOL;
 		$outstr .= '        <td class="editname">Fan Switch Address</td>'.PHP_EOL;
@@ -568,10 +599,10 @@
 		    }
 		}
 		$outstr .= '        </select></td>'.PHP_EOL;
-		$outstr .= '       </tr>'.PHP_EOL;
+//		$outstr .= '       </tr>'.PHP_EOL;
 	    }
 	    if ($f[0] == "FAN_DELAY") {
-		$outstr .= '       <tr class="editor">'.PHP_EOL;
+//		$outstr .= '       <tr class="editor">'.PHP_EOL;
 		$outstr .= '        <td class="editname">Fan Switch Delay</td>'.PHP_EOL;
 		$outstr .= '        <td class="editfield"><input type="text" name="FanDelay" size="5" value="'.$f[1].'"> seconds (0..720)</td>'.PHP_EOL;
 		$outstr .= '       </tr>'.PHP_EOL;
@@ -579,7 +610,7 @@
 	    if ($f[0] == "FAN_IDX") {
 		$outstr .= '       <tr class="editor">'.PHP_EOL;
 		$outstr .= '        <td class="editname">Fan domoticz idx</td>'.PHP_EOL;
-		$outstr .= '        <td class="editfield"><input type="text" name="FanIdx" size="5" value="'.$f[1].'"></td>'.PHP_EOL;
+		$outstr .= '        <td colspan="3" class="editfield"><input type="text" name="FanIdx" size="5" value="'.$f[1].'"></td>'.PHP_EOL;
 		$outstr .= '       </tr>'.PHP_EOL;
 	    }
 	    if ($f[0] == "LIGHT_ADDRESS") {
@@ -601,10 +632,10 @@
 		    }
 		}
 		$outstr .= '        </select></td>'.PHP_EOL;
-		$outstr .= '       </tr>'.PHP_EOL;
+//		$outstr .= '       </tr>'.PHP_EOL;
 	    }
 	    if ($f[0] == "LIGHT_DELAY") {
-		$outstr .= '       <tr class="editor">'.PHP_EOL;
+//		$outstr .= '       <tr class="editor">'.PHP_EOL;
 		$outstr .= '        <td class="editname">Lights Delay</td>'.PHP_EOL;
 		$outstr .= '        <td class="editfield"><input type="text" name="LightDelay" size="5" value="'.$f[1].'"> seconds (0..720)</td>'.PHP_EOL;
 		$outstr .= '       </tr>'.PHP_EOL;
@@ -612,7 +643,7 @@
 	    if ($f[0] == "LIGHT_IDX") {
 		$outstr .= '       <tr class="editor">'.PHP_EOL;
 		$outstr .= '        <td class="editname">Light domoticz idx</td>'.PHP_EOL;
-		$outstr .= '        <td class="editfield"><input type="text" name="LightIdx" size="5" value="'.$f[1].'"></td>'.PHP_EOL;
+		$outstr .= '        <td colspan="3" class="editfield"><input type="text" name="LightIdx" size="5" value="'.$f[1].'"></td>'.PHP_EOL;
 		$outstr .= '       </tr>'.PHP_EOL;
 	    }
 	    if ($f[0] == "DOOR_ADDRESS") {
@@ -634,10 +665,10 @@
 		    }
 		}
 		$outstr .= '        </select></td>'.PHP_EOL;                        
-		$outstr .= '       </tr>'.PHP_EOL;                                  
+//		$outstr .= '       </tr>'.PHP_EOL;                                  
 	    }
 	    if ($f[0] == "DOOR_IDX") {
-		$outstr .= '       <tr class="editor">'.PHP_EOL;
+//		$outstr .= '       <tr class="editor">'.PHP_EOL;
 		$outstr .= '        <td class="editname">Door domoticz idx</td>'.PHP_EOL;
 		$outstr .= '        <td class="editfield"><input type="text" name="DoorIdx" size="5" value="'.$f[1].'"></td>'.PHP_EOL;
 		$outstr .= '       </tr>'.PHP_EOL;
@@ -661,10 +692,10 @@
 		    }
 		}
 		$outstr .= '        </select></td>'.PHP_EOL;
-		$outstr .= '       </tr>'.PHP_EOL;
+//		$outstr .= '       </tr>'.PHP_EOL;
 	    }
 	    if ($f[0] == "PSU_IDX") {
-		$outstr .= '       <tr class="editor">'.PHP_EOL;
+//		$outstr .= '       <tr class="editor">'.PHP_EOL;
 		$outstr .= '        <td class="editname">PSU domoticz idx</td>'.PHP_EOL;
 		$outstr .= '        <td class="editfield"><input type="text" name="PSUIdx" size="5" value="'.$f[1].'"></td>'.PHP_EOL;
 		$outstr .= '       </tr>'.PHP_EOL;
@@ -673,10 +704,10 @@
 		$outstr .= '       <tr class="editor">'.PHP_EOL;
 		$outstr .= '        <td class="editname">Min. temp setting</td>'.PHP_EOL;
 		$outstr .= '        <td class="editfield"><input type="text" name="TempSetMin" size="5" value="'.$f[1].'"> &deg;C</td>'.PHP_EOL;
-		$outstr .= '       </tr>'.PHP_EOL;
+//		$outstr .= '       </tr>'.PHP_EOL;
 	    }
 	    if ($f[0] == "TEMP_SET_MAX") {
-		$outstr .= '       <tr class="editor">'.PHP_EOL;
+//		$outstr .= '       <tr class="editor">'.PHP_EOL;
 		$outstr .= '        <td class="editname">Max. temp setting</td>'.PHP_EOL;
 		$outstr .= '        <td class="editfield"><input type="text" name="TempSetMax" size="5" value="'.$f[1].'"> &deg;C</td>'.PHP_EOL;
 		$outstr .= '       </tr>'.PHP_EOL;
@@ -686,7 +717,7 @@
     }
     $outstr .= '       <tr class="editor">'.PHP_EOL;
     $outstr .= '        <td class="editname"><input type="submit" value="Save" name="key"></td>'.PHP_EOL;
-    $outstr .= '        <td class="editfield"><input type="submit" value="Cancel" name="key">';
+    $outstr .= '        <td colspan="3" class="editfield"><input type="submit" value="Cancel" name="key">';
     $outstr .= '<input type="submit" value="Delete" name="key" style="margin-left: 100px;">';
     $outstr .= '<input type="hidden" value="testdata" name="action">';
     $outstr .= '<input type="hidden" value="'.$command.'" name="command">';
@@ -779,6 +810,8 @@
     $outstr .= '<input type="hidden" value="0" name="AirIdx">';
     $outstr .= '<input type="hidden" value="" name="BeerAddress">';
     $outstr .= '<input type="hidden" value="0" name="BeerIdx">';
+    $outstr .= '<input type="hidden" value="" name="ChillerAddress">';
+    $outstr .= '<input type="hidden" value="0" name="ChillerIdx">';
     $outstr .= '<input type="hidden" value="" name="HeaterAddress">';
     $outstr .= '<input type="hidden" value="20" name="HeaterDelay">';
     $outstr .= '<input type="hidden" value="0" name="HeaterIdx">';

mercurial