diff --git a/docs/project-state.md b/docs/project-state.md index 0a6878f..aeff01f 100644 --- a/docs/project-state.md +++ b/docs/project-state.md @@ -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 \ No newline at end of file +- 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 \ No newline at end of file diff --git a/firmware/esp32/overland-controller/sensors.cpp b/firmware/esp32/overland-controller/sensors.cpp index d38f9a9..bbebca0 100644 --- a/firmware/esp32/overland-controller/sensors.cpp +++ b/firmware/esp32/overland-controller/sensors.cpp @@ -168,7 +168,22 @@ bool assignTempSensorByIndex(int configIndex, int scanIndex) { return false; } - appConfig.tempSensors[configIndex].address = sensorAddressStrings[scanIndex]; + String selectedAddress = sensorAddressStrings[scanIndex]; + + for (int i = 0; i < MAX_TEMP_SENSORS; i++) { + if (i == configIndex) { + continue; + } + + if (appConfig.tempSensors[i].address == selectedAddress) { + appConfig.tempSensors[i].address = ""; + appConfig.tempSensors[i].enabled = false; + sensors.tempsF[i] = -127.0; + sensors.online[i] = false; + } + } + + appConfig.tempSensors[configIndex].address = selectedAddress; appConfig.tempSensors[configIndex].enabled = true; return true;