allow single sensor detection, get rid of sensor disabled hardware state == nomessage

This commit is contained in:
2026-02-27 23:12:40 +01:00
parent c575fc2c36
commit 9b21d505e6
10 changed files with 92 additions and 32 deletions

View File

@@ -8,7 +8,7 @@ document.body.innerHTML = require('./main.html') as string;
import {TimeView} from "./timeview";
import {PlantViews} from "./plant";
import {PlantViews, PLANT_COUNT} from "./plant";
import {NetworkConfigView} from "./network";
import {NightLampView} from "./nightlightview";
import {TankConfigView} from "./tankview";
@@ -29,7 +29,7 @@ import {
SetTime, SSIDList, TankInfo,
TestPump,
VersionInfo,
FileList, SolarState, PumpTestResult, DetectionResult, CanPower
FileList, SolarState, PumpTestResult, Detection, CanPower
} from "./api";
import {SolarView} from "./solarview";
import {toast} from "./toast";
@@ -361,7 +361,7 @@ export class Controller {
)
}
async detectSensors() {
async detectSensors(detection: Detection) {
let counter = 0
let limit = 5
controller.progressview.addProgress("detect_sensors", counter / limit * 100, "Detecting sensors " + (limit - counter) + "s")
@@ -376,9 +376,11 @@ export class Controller {
timerId = setTimeout(updateProgress, 1000);
fetch(PUBLIC_URL + "/detect_sensors", { method: "POST" })
var pretty = JSON.stringify(detection, undefined, 1);
fetch(PUBLIC_URL + "/detect_sensors", { method: "POST", body: pretty })
.then(response => response.json())
.then (json => json as DetectionResult)
.then (json => json as Detection)
.then(json => {
clearTimeout(timerId);
controller.progressview.removeProgress("detect_sensors");
@@ -573,7 +575,15 @@ export class Controller {
this.logView = new LogView(this)
this.hardwareView = new HardwareConfigView(this)
this.detectBtn = document.getElementById("detect_sensors") as HTMLButtonElement
this.detectBtn.onclick = () => { controller.detectSensors(); }
this.detectBtn.onclick = () => {
const detection: Detection = {
plant: Array.from({length: PLANT_COUNT}, () => ({
sensor_a: true,
sensor_b: true,
})),
};
controller.detectSensors(detection);
}
this.rebootBtn = document.getElementById("reboot") as HTMLButtonElement
this.rebootBtn.onclick = () => {
controller.reboot();