diff --git a/src/controllers/tanksController.js b/src/controllers/tanksController.js index 720244e9..7f3fdef8 100644 --- a/src/controllers/tanksController.js +++ b/src/controllers/tanksController.js @@ -2945,15 +2945,7 @@ exports.motorAction = async (req, reply) => { reply.code(200).send({ message: "Motor started successfully." }); - } else if (action === "stop") { - motorStopStatus = "1"; // If action is stop, set stop status to "1" - - try { - - - const totalWaterPumped = await calculateTotalPumpedWater(customerId, motorId, start_instance_id); - - const lowWaterThreshold = 5; // Adjust as needed + const lowWaterThreshold = 5; // Adjust as needed const thresholdTime = new Date(manual_threshold_time); // Convert threshold time if (new Date() >= thresholdTime || currentWaterPercentage <= lowWaterThreshold) { @@ -2969,6 +2961,14 @@ exports.motorAction = async (req, reply) => { } console.log("Motor stopped"); + + } else if (action === "stop") { + motorStopStatus = "1"; // If action is stop, set stop status to "1" + + try { + + + const totalWaterPumped = await calculateTotalPumpedWater(customerId, motorId, start_instance_id); eventEmitter.emit("motorStop", customerId, fcmToken, tankName, blockName, stopTime, "Mobile APP", totalWaterPumped, typeOfWater, motorId, loggedInUser.phone,);