master^2
Varun 7 months ago
parent 5c037fdfef
commit 780d1f4178

@ -2868,18 +2868,17 @@ exports.motorAction = async (req, reply) => {
if (action === "start") { if (action === "start") {
if (motorIntervals[motorId]) { if (motorIntervals[motorId]) {
console.log(`🛑 Clearing interval for motorId: ${motorId}`); console.log(`🛑 Clearing old interval for motorId: ${motorId}`);
clearInterval(motorIntervals[motorId]); clearInterval(motorIntervals[motorId]);
delete motorIntervals[motorId]; delete motorIntervals[motorId];
// Confirm deletion // Confirm deletion
if (!motorIntervals[motorId]) { if (!motorIntervals[motorId]) {
console.log(`Interval for motorId: ${motorId} successfully deleted.`); console.log(`Old interval successfully deleted.`);
} else { } else {
console.error(`❌ Failed to delete interval for motorId: ${motorId}`); console.error(`❌ Failed to delete old interval.`);
} }
} }
const startTime = moment().tz('Asia/Kolkata').format('DD-MMM-YYYY - HH:mm'); const startTime = moment().tz('Asia/Kolkata').format('DD-MMM-YYYY - HH:mm');
@ -2894,8 +2893,8 @@ exports.motorAction = async (req, reply) => {
}} }}
); );
eventEmitter.emit("motorStart", customerId, fcmToken, tankName, blockName, startTime, "Mobile APP", manual_threshold_time, typeOfWater, motorId, loggedInUser.phone); eventEmitter.emit("motorStart", customerId, fcmToken, tankName, blockName, startTime, "Mobile APP", manual_threshold_time, typeOfWater, motorId, loggedInUser.phone);
this.publishMotorStopStatus(motorId, motorStopStatus); //this.publishMotorStopStatus(motorId, motorStopStatus);
reply.code(200).send({ message: "Motor started successfully." }); reply.code(200).send({ message: "Motor started successfully." });
if (req.body.threshold_type === "time") { if (req.body.threshold_type === "time") {

Loading…
Cancel
Save