diff --git a/src/controllers/tanksController.js b/src/controllers/tanksController.js index 7f3fdef8..720244e9 100644 --- a/src/controllers/tanksController.js +++ b/src/controllers/tanksController.js @@ -2945,7 +2945,15 @@ exports.motorAction = async (req, reply) => { reply.code(200).send({ message: "Motor started successfully." }); - const lowWaterThreshold = 5; // Adjust as needed + } 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 thresholdTime = new Date(manual_threshold_time); // Convert threshold time if (new Date() >= thresholdTime || currentWaterPercentage <= lowWaterThreshold) { @@ -2961,14 +2969,6 @@ 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,);