master^2
Bhaskar 7 months ago
parent a7fa07453c
commit da1aeec667

@ -1441,7 +1441,7 @@ eventEmitter.on(
`🕒 Pump started at: ${startTime} \n` + `🕒 Pump started at: ${startTime} \n` +
`Will stop after: '${manual_threshold_time}' mins`; `Will stop after: '${manual_threshold_time}' mins`;
await sendNotification(hw_Id, customerId, fcmTokens, "Arminta MOTOR STARTED", message); await sendNotification(hw_Id, customerId, fcmTokens, "ARMINTA : MOTOR STARTED", message);
} catch (error) { } catch (error) {
console.error("Error in motorStart event:", error); console.error("Error in motorStart event:", error);
} }
@ -1502,7 +1502,7 @@ eventEmitter.on(
`🕒 Pump stopped at: ${stopTime}\n` + `🕒 Pump stopped at: ${stopTime}\n` +
`💧 Total water pumped: ${totalWaterPumped} liters\n`; `💧 Total water pumped: ${totalWaterPumped} liters\n`;
await sendNotification(hw_Id, customerId, fcmTokens, "Arminta MOTOR STOPPED", message); await sendNotification(hw_Id, customerId, fcmTokens, "ARMINTA : MOTOR STOPPED", message);
} catch (error) { } catch (error) {
console.error("Error in motorStop event:", error); console.error("Error in motorStop event:", error);
} }
@ -1571,18 +1571,13 @@ eventEmitter.on('sendCriticalHighWaterNotification', async (fcmTokens, tankInfo,
// await sendNotification(fcmTokens, 'High Water Level', `Motor ID: ${motorId}, water level reached above 90% at ${timestamp}. Current Water Level: ${waterLevel} Ltrs`); // await sendNotification(fcmTokens, 'High Water Level', `Motor ID: ${motorId}, water level reached above 90% at ${timestamp}. Current Water Level: ${waterLevel} Ltrs`);
// }); // });
// eventEmitter.on('sendThresholdTimeNotification', async (fcmTokens, message) => {
// try {
// await sendNotification(fcmTokens, 'Threshold Time Reached', message, 'Motor Alert');
// console.log("Threshold time notification sent successfully.");
// } catch (error) {
// console.error("Error sending threshold time notification:", error);
// }
// });
eventEmitter.on('sendThresholdTimeNotification', async (customerId, fcmTokens, thresholdTime, hw_Id) => { eventEmitter.on('sendThresholdTimeNotification', async (customerId, fcmTokens, thresholdTime, hw_Id, tankName, blockName) => {
try { try {
const message = `Motor Stopped as it completed ${thresholdTime} minutes.`; const message =
`🛢️ Tank Name: '${tankName}'\n` +
`🏢 Block Name: '${blockName}'\n` +
`Motor Stopped as it completed ${thresholdTime} minutes.`;
await sendNotification(hw_Id, customerId, fcmTokens, 'Motor Alert', message); await sendNotification(hw_Id, customerId, fcmTokens, 'Motor Alert', message);
console.log("Threshold time notification sent successfully."); console.log("Threshold time notification sent successfully.");
} catch (error) { } catch (error) {
@ -3087,17 +3082,15 @@ exports.motorAction = async (req, reply) => {
console.log(thresholdTime,"thresholdTime") console.log(thresholdTime,"thresholdTime")
console.log("motor stopping because it entered this condition") console.log("motor stopping because it entered this condition")
// Emit the threshold time notification // Emit the threshold time notification
// eventEmitter.emit(
// "sendThresholdTimeNotification",
// fcmToken,
// `Motor has reached its time threshold of ${req.body.manual_threshold_time} minutes and will stop.`
// );
eventEmitter.emit( eventEmitter.emit(
"sendThresholdTimeNotification", "sendThresholdTimeNotification",
customerId, customerId,
fcmToken, fcmToken,
manual_threshold_time, manual_threshold_time,
motorId motorId,
tankName,
blockName
); );
const currentTime = moment().tz('Asia/Kolkata').format('DD-MMM-YYYY - HH:mm'); const currentTime = moment().tz('Asia/Kolkata').format('DD-MMM-YYYY - HH:mm');
await Tank.updateOne( await Tank.updateOne(

Loading…
Cancel
Save