--- a/thermferm/rdconfig.c Fri Aug 03 21:58:30 2018 +0200 +++ b/thermferm/rdconfig.c Sat Aug 04 16:29:12 2018 +0200 @@ -33,6 +33,7 @@ const char TEMPSTATE[3][8] = { "OK", "MISSING", "ERROR" }; const char UNITMODE[5][8] = { "OFF", "NONE", "FRIDGE", "BEER", "PROFILE" }; +const char UNITSTAGE[3][10] = { "PRIMARY", "SECONDARY", "TERTIARY" }; const char PROFSTATE[5][6] = { "OFF", "PAUSE", "RUN", "DONE", "ABORT" }; const char DEVTYPE[8][6] = { "NA", "W1", "GPIO", "RC433", "DHT", "I2C", "SPI", "SIM" }; const char DEVPRESENT[4][6] = { "UNDEF", "NO", "YES", "ERROR" }; @@ -563,6 +564,10 @@ syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); return 1; } + if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "STAGE", "%s", UNITSTAGE[tmp3->stage] )) < 0) { + syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); + return 1; + } if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "BEER_SET", "%.1f", tmp3->beer_set)) < 0) { syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); return 1; @@ -1145,7 +1150,7 @@ 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->light_state = unit->psu_state = unit->mode = unit->prof_state = unit->stage = 0; 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 */ @@ -1381,6 +1386,16 @@ } xmlFree(key); } + if ((!xmlStrcmp(cur->name, (const xmlChar *)"STAGE"))) { + key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); + for (i = 0; i < 3; i++) { + if (! xmlStrcmp(key, (const xmlChar *)UNITSTAGE[i])) { + unit->stage = i; + break; + } + } + xmlFree(key); + } if ((!xmlStrcmp(cur->name, (const xmlChar *)"BEER_SET"))) { key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); if (sscanf((const char *)key, "%f", &val) == 1)