diff --git a/firmware/esp32/overland-controller/overland-controller.ino b/firmware/esp32/overland-controller/overland-controller.ino index 5dee9bd..d6e7410 100644 --- a/firmware/esp32/overland-controller/overland-controller.ino +++ b/firmware/esp32/overland-controller/overland-controller.ino @@ -1158,40 +1158,60 @@ function renderConfigControls(data){ `).join(""); } - const tempCount=$("tempEnabledCount"); - if(tempCount){ - tempCount.value=temps.filter(t=>t.enabled).length; - } + setConfigValue("tempEnabledCount", temps.filter(t=>t.enabled).length); const tempBox=$("tempConfigList"); - if(tempBox){ + if(!tempBox) return; + + const existingSignature=tempBox.dataset.signature||""; + const nextSignature=temps.map(t=>t.id).join("|"); + + if(existingSignature!==nextSignature){ + tempBox.dataset.signature=nextSignature; tempBox.innerHTML=temps.map((t,i)=>` -
+
Temp Slot ${i+1}
- +
Address
-
${t.address||"unassigned"}
+
`).join(""); } + + temps.forEach((t,i)=>{ + setConfigValue("tempName"+i,t.name||""); + + const address=$("tempAddress"+i); + if(address) address.textContent=t.address||"unassigned"; + + const enabled=$("tempEnabled"+i); + if(enabled && !configTouched["tempEnabled"+i] && document.activeElement!==enabled){ + enabled.checked=!!t.enabled; + } + + const weather=$("tempWeather"+i); + if(weather && !configTouched["tempWeather"+i] && document.activeElement!==weather){ + weather.checked=!!t.weather; + } + }); } async function saveRelayConfig(){ @@ -1250,7 +1270,10 @@ async function saveTempConfig(){ await fetch(api("/config/save"),{method:"POST"}); await load(); alert("Temperature config saved"); - clearConfigTouched(["tempEnabledCount"]); + clearConfigTouched([ + "tempEnabledCount", + ...temps.flatMap((_,i)=>["tempName"+i,"tempEnabled"+i,"tempWeather"+i]) + ]); } async function loadWifiConfig(){