@ -1441,7 +1441,7 @@ eventEmitter.on(
` 🕒 Pump started at: ${ startTime } \n ` +
` Will stop after: ' ${ manual _threshold _time } ' mins ` ;
await sendNotification ( hw _Id , customerId , fcmTokens , "A rminta MOTOR STARTED", message ) ;
await sendNotification ( hw _Id , customerId , fcmTokens , "A RMINTA : MOTOR STARTED", message ) ;
} catch ( error ) {
console . error ( "Error in motorStart event:" , error ) ;
}
@ -1502,7 +1502,7 @@ eventEmitter.on(
` 🕒 Pump stopped at: ${ stopTime } \n ` +
` 💧 Total water pumped: ${ totalWaterPumped } liters \n ` ;
await sendNotification ( hw _Id , customerId , fcmTokens , "A rminta MOTOR STOPPED", message ) ;
await sendNotification ( hw _Id , customerId , fcmTokens , "A RMINTA : MOTOR STOPPED", message ) ;
} catch ( 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`);
// });
// 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 {
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 ) ;
console . log ( "Threshold time notification sent successfully." ) ;
} catch ( error ) {
@ -3087,17 +3082,15 @@ exports.motorAction = async (req, reply) => {
console . log ( thresholdTime , "thresholdTime" )
console . log ( "motor stopping because it entered this condition" )
// 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 (
"sendThresholdTimeNotification" ,
customerId ,
fcmToken ,
manual _threshold _time ,
motorId
motorId ,
tankName ,
blockName
) ;
const currentTime = moment ( ) . tz ( 'Asia/Kolkata' ) . format ( 'DD-MMM-YYYY - HH:mm' ) ;
await Tank . updateOne (