dashboard: add grouped temperature overview tiles
This commit is contained in:
@@ -38,7 +38,8 @@ void loadDefaultConfig() {
|
||||
"Temperature " + String(i + 1),
|
||||
"",
|
||||
i < appConfig.tempSensorCount,
|
||||
false
|
||||
false,
|
||||
"cabin"
|
||||
};
|
||||
}
|
||||
|
||||
@@ -101,6 +102,10 @@ void loadConfig() {
|
||||
(prefix + "weather").c_str(),
|
||||
appConfig.tempSensors[i].weather
|
||||
);
|
||||
appConfig.tempSensors[i].group = preferences.getString(
|
||||
(prefix + "group").c_str(),
|
||||
appConfig.tempSensors[i].group
|
||||
);
|
||||
}
|
||||
|
||||
appConfig.bms.enabled = preferences.getBool("bms_enabled", appConfig.bms.enabled);
|
||||
@@ -136,6 +141,7 @@ void saveConfig() {
|
||||
preferences.putString((prefix + "addr").c_str(), appConfig.tempSensors[i].address);
|
||||
preferences.putBool((prefix + "enabled").c_str(), appConfig.tempSensors[i].enabled);
|
||||
preferences.putBool((prefix + "weather").c_str(), appConfig.tempSensors[i].weather);
|
||||
preferences.putString((prefix + "group").c_str(), appConfig.tempSensors[i].group);
|
||||
}
|
||||
|
||||
preferences.putBool("bms_enabled", appConfig.bms.enabled);
|
||||
@@ -187,7 +193,9 @@ void printConfig() {
|
||||
Serial.print(" / enabled ");
|
||||
Serial.print(appConfig.tempSensors[i].enabled ? "true" : "false");
|
||||
Serial.print(" / address ");
|
||||
Serial.println(appConfig.tempSensors[i].address);
|
||||
Serial.print(appConfig.tempSensors[i].address);
|
||||
Serial.print(" / group ");
|
||||
Serial.println(appConfig.tempSensors[i].group);
|
||||
}
|
||||
|
||||
Serial.println(" BMS:");
|
||||
|
||||
@@ -22,6 +22,7 @@ struct TempSensorConfig {
|
||||
String address;
|
||||
bool enabled;
|
||||
bool weather;
|
||||
String group;
|
||||
};
|
||||
|
||||
struct BmsConfig {
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user