dashboard: add grouped temperature overview tiles

This commit is contained in:
2026-06-10 23:58:40 -06:00
parent b393e8d704
commit c4138468f2
8 changed files with 194 additions and 86 deletions
@@ -1183,6 +1183,15 @@ function renderConfigControls(data){
<div id="tempAddress${i}" class="tempConfigAddress"></div>
</div>
<label class="inputHelp" for="tempGroup${i}">Group</label>
<select id="tempGroup${i}" onchange="markConfigFieldTouched('tempGroup${i}')">
<option value="cabin">Cabin</option>
<option value="fridge">Fridge</option>
<option value="outside">Outside</option>
<option value="battery">Battery</option>
<option value="other">Other</option>
</select>
<div class="tempConfigControls">
<label class="tempCheck">
<input id="tempEnabled${i}" type="checkbox" onchange="markConfigFieldTouched('tempEnabled${i}'); saveTempConfig()">
@@ -1211,6 +1220,11 @@ function renderConfigControls(data){
if(weather && !configTouched["tempWeather"+i] && document.activeElement!==weather){
weather.checked=!!t.weather;
}
const group=$("tempGroup"+i);
if(group && !configTouched["tempGroup"+i] && document.activeElement!==group){
group.value=t.group||"cabin";
}
});
}
@@ -1253,6 +1267,7 @@ async function saveTempConfig(){
const name=$("tempName"+i)?.value.trim() || temps[i].name || temps[i].id;
const enabled=$("tempEnabled"+i)?.checked || false;
const weather=$("tempWeather"+i)?.checked || false;
const group=$("tempGroup"+i)?.value || temps[i].group || "cabin";
await fetch(api("/config/temp"),{
method:"POST",
@@ -1262,7 +1277,8 @@ async function saveTempConfig(){
name:name,
address:temps[i].address||"",
enabled:enabled,
weather:weather
weather:weather,
group:group
})
});
}
@@ -1272,7 +1288,7 @@ async function saveTempConfig(){
alert("Temperature config saved");
clearConfigTouched([
"tempEnabledCount",
...temps.flatMap((_,i)=>["tempName"+i,"tempEnabled"+i,"tempWeather"+i])
...temps.flatMap((_,i)=>["tempName"+i,"tempEnabled"+i,"tempWeather"+i,"tempGroup"+i])
]);
}
@@ -2000,6 +2016,7 @@ void buildConfigDocument(JsonObject doc) {
temp["address"] = appConfig.tempSensors[i].address;
temp["enabled"] = appConfig.tempSensors[i].enabled;
temp["weather"] = appConfig.tempSensors[i].weather;
temp["group"] = appConfig.tempSensors[i].group;
}
}
@@ -2193,6 +2210,7 @@ void applyImportedConfig(JsonObject doc) {
if (temp["address"].is<String>()) appConfig.tempSensors[index].address = temp["address"].as<String>();
if (temp["enabled"].is<bool>()) appConfig.tempSensors[index].enabled = temp["enabled"].as<bool>();
if (temp["weather"].is<bool>()) appConfig.tempSensors[index].weather = temp["weather"].as<bool>();
if (temp["group"].is<String>()) appConfig.tempSensors[index].group = temp["group"].as<String>();
}
}
@@ -2298,6 +2316,7 @@ void buildStatusDocument(JsonDocument& doc) {
temp["name"] = appConfig.tempSensors[i].name;
temp["enabled"] = appConfig.tempSensors[i].enabled;
temp["weather"] = appConfig.tempSensors[i].weather;
temp["group"] = appConfig.tempSensors[i].group;
temp["online"] = sensors.online[i];
if (sensors.online[i]) {
temp["temperature_f"] = sensors.tempsF[i];
@@ -2441,6 +2460,8 @@ void sendConfigResponse(Stream& output, bool ok = true) {
temp["name"] = appConfig.tempSensors[i].name;
temp["address"] = appConfig.tempSensors[i].address;
temp["enabled"] = appConfig.tempSensors[i].enabled;
temp["weather"] = appConfig.tempSensors[i].weather;
temp["group"] = appConfig.tempSensors[i].group;
}
serializeJson(doc, output);
@@ -3422,6 +3443,7 @@ void handleUpdateTempSensorConfig() {
if (doc["address"].is<String>()) appConfig.tempSensors[index].address = doc["address"].as<String>();
if (doc["enabled"].is<bool>()) appConfig.tempSensors[index].enabled = doc["enabled"].as<bool>();
if (doc["weather"].is<bool>()) appConfig.tempSensors[index].weather = doc["weather"].as<bool>();
if (doc["group"].is<String>()) appConfig.tempSensors[index].group = doc["group"].as<String>();
sendOkConfig();
}
@@ -3562,6 +3584,7 @@ void handleTempClear() {
appConfig.tempSensors[i].address = "";
appConfig.tempSensors[i].enabled = false;
appConfig.tempSensors[i].weather = false;
appConfig.tempSensors[i].group = "cabin";
sensors.tempsF[i] = -127.0;
sensors.online[i] = false;
}
@@ -3598,6 +3621,7 @@ void handleTempClear() {
appConfig.tempSensors[configIndex].address = "";
appConfig.tempSensors[configIndex].enabled = false;
appConfig.tempSensors[configIndex].weather = false;
appConfig.tempSensors[configIndex].group = "cabin";
sensors.tempsF[configIndex] = -127.0;
sensors.online[configIndex] = false;