automation of motor switch test2

master
varun 1 year ago
parent 4d8da59661
commit 79f39d5fa4

@ -931,8 +931,13 @@ exports.motorAction = async (req, reply) => {
// Start monitoring water level based on threshold time // Start monitoring water level based on threshold time
const thresholdTime = moment().add(req.body.manual_threshold_time, 'minutes').toDate(); const thresholdTime = moment().add(req.body.manual_threshold_time, 'minutes').toDate();
const intervalId = setInterval(async () => { const intervalId = setInterval(async () => {
// Check if threshold time has been reached const splr_tank_info3 = await Tank.findOne({ customerId, tankName: req.body.from, tankLocation: req.body.from_type.toLowerCase() });
if (new Date() >= thresholdTime) { const splr_tank_info3_waterlevel = parseInt(splr_tank_info3.waterlevel, 10);
const splr_tank_info3_capacity = parseInt(splr_tank_info3.capacity, 10);
const splr_tank_info3_percentage = (splr_tank_info3_waterlevel / splr_tank_info3_capacity) * 100;
console.log(splr_tank_info3_percentage,"percentage for less than 20")
if (new Date() >= thresholdTime || splr_tank_info3_percentage<=20) {
// Stop the motor pump // Stop the motor pump
await Tank.updateOne( await Tank.updateOne(
{ customerId, "connections.inputConnections.motor_id": motorId }, { customerId, "connections.inputConnections.motor_id": motorId },

Loading…
Cancel
Save