mirror of
https://github.com/eliasrenman/gardentron.git
synced 2026-03-16 20:46:07 +01:00
feat: outline of processor
This commit is contained in:
30
server/src/processors/moisture.processor.ts
Normal file
30
server/src/processors/moisture.processor.ts
Normal file
@@ -0,0 +1,30 @@
|
||||
// import Queue from "queue";
|
||||
|
||||
import { Prisma } from "@prisma/client";
|
||||
import { iotClient } from "../axios/iot.axios";
|
||||
import { MositureRow } from "../cron";
|
||||
|
||||
// const q = new Queue({ results: [] });
|
||||
export function checkReadingAndEnqueue(rows: MositureRow[]) {
|
||||
// Read config for threshold values
|
||||
// Conclude which sensors need watering.
|
||||
// Enqueue relevant
|
||||
}
|
||||
function enqueue() {}
|
||||
|
||||
function process() {
|
||||
// Enable water gate
|
||||
// Check moisture level once per second for configured time
|
||||
// If the moisture level does not increase a significant amount trigger water-empty alarm and clear queue
|
||||
// If moisture level reaches upper threshold then cancel out of the checking loop
|
||||
// Finally turn of the water gate
|
||||
}
|
||||
function timeoutCb() {}
|
||||
|
||||
function toggleWater(index: number, on: boolean) {
|
||||
return iotClient
|
||||
.post(`relay/${on ? "activate" : "deactivate"}`, {
|
||||
relay: index,
|
||||
})
|
||||
.then((item) => ({ on: true }));
|
||||
}
|
||||
Reference in New Issue
Block a user