Took 32 minutes
This commit is contained in:
2022-11-18 00:01:56 +01:00
parent 03dd0e0fb6
commit 016f4bc3fe
7 changed files with 77 additions and 5 deletions

View File

@ -23,6 +23,7 @@ router.ws('/', async (ws, req, next) => {
WebSocketHandler.ws = ws;
await WebSocketHandler.sendRunningConfig();
await WebSocketHandler.sendContainers();
await WebSocketHandler.sendStatus();
async function sendWhenReady() {
@ -64,20 +65,28 @@ router.ws('/', async (ws, req, next) => {
}
case WebSocketEvent.CONTAINERS: {
let data = msg.data as { pumpPin: number; sensorType: SensorType; sensor1: number; sensor2: number; volume: number; }[];
await Container.remove({});
await Container.deleteMany({});
let i = 0;
for (let c of data) {
let container = new Container();
container.slot = i;
container.volume = c.volume;
container.pumpPin = c.pumpPin;
container.sensorType = c.sensorType;
container.sensorPin1 = c.sensor1;
container.sensorPin2 = c.sensor2;
container.enabled = true;
container.autoDisabled = true;
await container.save();
i++;
}
break;
}
case WebSocketEvent.CONFIG: {
// ToDo
// Danach setup modus aus
}
}
});