Harden temperature assignment clearing
This commit is contained in:
+11
-1
@@ -641,4 +641,14 @@ Request:
|
||||
|
||||
Temperature sensor config entries now include `weather: true`.
|
||||
|
||||
When a configured temp sensor has `weather: true`, the WebUI may show it as the outside/weather temperature badge. The `/status` temp objects also include this flag so HTTP, UART, USB serial, and future Pico clients can identify the selected outside-air sensor without guessing from the sensor name.\n
|
||||
When a configured temp sensor has `weather: true`, the WebUI may show it as the outside/weather temperature badge. The `/status` temp objects also include this flag so HTTP, UART, USB serial, and future Pico clients can identify the selected outside-air sensor without guessing from the sensor name.\n\n\n### Clear temperature assignments
|
||||
|
||||
`POST /temps/clear`
|
||||
|
||||
Request body options:
|
||||
|
||||
- `{ "id": "temp_1" }` clears one logical temp slot by ID.
|
||||
- `{ "slot": 1 }` clears one logical temp slot by number.
|
||||
- Empty POST body clears all temp assignments.
|
||||
|
||||
Clearing removes the stored DS18B20 address, disables the slot, clears the weather flag, resets cached temperature state, and persists config.\n
|
||||
@@ -163,4 +163,4 @@ Examples:
|
||||
5. Add config backup/restore.
|
||||
6. Improve BMS out-of-range behavior without changing NimBLE connect timeout.
|
||||
|
||||
- Fixed WebUI temperature probe scan by registering `/temps/scan`, `/temps/assign`, and `/temps/clear` firmware routes.\n\n- Added per-temperature-sensor `weather` flag and WebUI outside temperature badge with emoji thresholds: below 50°F ice, 50-74°F happy, 75-84°F sun, and 85°F+ fire.\n\n- Improved WebUI temperature sensor config checkbox layout with compact On/Weather controls.\n\n- Temperature probe assignment now enforces one logical slot per physical DS18B20 address; assigning a probe to a new slot clears the old slot mapping.\n\n- Added per-slot WebUI Clear buttons for temperature probe assignments using the existing `/temps/clear` API.\n\n- Fixed weather temp checkbox persistence by saving the `weather` flag from WebUI temp config and auto-saving checkbox changes.\n\n- Fixed temperature assignment clearing so Clear removes the stored DS18B20 address, disables the slot, clears weather flag, and resets cached temp state.\n
|
||||
- Fixed WebUI temperature probe scan by registering `/temps/scan`, `/temps/assign`, and `/temps/clear` firmware routes.\n\n- Added per-temperature-sensor `weather` flag and WebUI outside temperature badge with emoji thresholds: below 50°F ice, 50-74°F happy, 75-84°F sun, and 85°F+ fire.\n\n- Improved WebUI temperature sensor config checkbox layout with compact On/Weather controls.\n\n- Temperature probe assignment now enforces one logical slot per physical DS18B20 address; assigning a probe to a new slot clears the old slot mapping.\n\n- Added per-slot WebUI Clear buttons for temperature probe assignments using the existing `/temps/clear` API.\n\n- Fixed weather temp checkbox persistence by saving the `weather` flag from WebUI temp config and auto-saving checkbox changes.\n\n- Fixed temperature assignment clearing so Clear removes the stored DS18B20 address, disables the slot, clears weather flag, and resets cached temp state.\n\n- Hardened `/temps/clear` so clearing a temp slot removes the persisted DS18B20 address, disables the slot, clears weather flag, resets cached temp state, and supports clearing all slots with an empty POST body.\n
|
||||
@@ -2179,8 +2179,24 @@ void handleTempAssign() {
|
||||
}
|
||||
|
||||
void handleTempClear() {
|
||||
String body = server.arg("plain");
|
||||
|
||||
if (body.length() == 0) {
|
||||
for (int i = 0; i < MAX_TEMP_SENSORS; i++) {
|
||||
appConfig.tempSensors[i].address = "";
|
||||
appConfig.tempSensors[i].enabled = false;
|
||||
appConfig.tempSensors[i].weather = false;
|
||||
sensors.tempsF[i] = -127.0;
|
||||
sensors.online[i] = false;
|
||||
}
|
||||
|
||||
saveConfig();
|
||||
sendConfigJson();
|
||||
return;
|
||||
}
|
||||
|
||||
DynamicJsonDocument doc(512);
|
||||
DeserializationError error = deserializeJson(doc, server.arg("plain"));
|
||||
DeserializationError error = deserializeJson(doc, body);
|
||||
|
||||
if (error) {
|
||||
server.send(400, "application/json", "{\"ok\":false,\"error\":\"invalid_json\"}");
|
||||
@@ -2203,10 +2219,11 @@ void handleTempClear() {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!clearTempSensor(configIndex)) {
|
||||
server.send(400, "application/json", "{\"ok\":false,\"error\":\"unknown_temp_sensor\"}");
|
||||
return;
|
||||
}
|
||||
appConfig.tempSensors[configIndex].address = "";
|
||||
appConfig.tempSensors[configIndex].enabled = false;
|
||||
appConfig.tempSensors[configIndex].weather = false;
|
||||
sensors.tempsF[configIndex] = -127.0;
|
||||
sensors.online[configIndex] = false;
|
||||
|
||||
saveConfig();
|
||||
sendConfigJson();
|
||||
|
||||
Reference in New Issue
Block a user