master^2
Bhaskar 8 months ago
parent a831fb1093
commit 420beaffb6

@ -2504,20 +2504,20 @@ exports.motorAction = async (req, reply) => {
// delete motorIntervals[motorId]; // delete motorIntervals[motorId];
await checkWaterLevelsAndNotify(customerId, tankName, supplierTank.tankLocation, fcmToken); await checkWaterLevelsAndNotify(customerId, tankName, supplierTank.tankLocation, fcmToken);
if (currentWaterPercentage >= highWaterThreshold && !notificationSentStatus.highWater) { // if (currentWaterPercentage >= highWaterThreshold && !notificationSentStatus.highWater) {
eventEmitter.emit('sendHighWaterNotification', fcmToken, `Water level has reached high levels.`); // eventEmitter.emit('sendHighWaterNotification', fcmToken, `Water level has reached high levels.`);
notificationSentStatus.highWater = true; // Set flag to true to prevent duplicate notifications // notificationSentStatus.highWater = true; // Set flag to true to prevent duplicate notifications
} // }
if (currentWaterPercentage >= veryHighWaterThreshold && !notificationSentStatus.veryHighWater) { // if (currentWaterPercentage >= veryHighWaterThreshold && !notificationSentStatus.veryHighWater) {
eventEmitter.emit('sendVeryHighWaterNotification', fcmToken, `Water level has reached very high levels.`); // eventEmitter.emit('sendVeryHighWaterNotification', fcmToken, `Water level has reached very high levels.`);
notificationSentStatus.veryHighWater = true; // Set flag to true to prevent duplicate notifications // notificationSentStatus.veryHighWater = true; // Set flag to true to prevent duplicate notifications
} // }
if (currentWaterPercentage >= criticalHighWaterThreshold && !notificationSentStatus.criticallyHighWater) { // if (currentWaterPercentage >= criticalHighWaterThreshold && !notificationSentStatus.criticallyHighWater) {
eventEmitter.emit('sendCriticalHighWaterNotification', fcmToken, `Water level has reached critically high levels.`); // eventEmitter.emit('sendCriticalHighWaterNotification', fcmToken, `Water level has reached critically high levels.`);
notificationSentStatus.criticallyHighWater = true; // Set flag to true to prevent duplicate notifications // notificationSentStatus.criticallyHighWater = true; // Set flag to true to prevent duplicate notifications
} // }
clearInterval(motorIntervals[motorId]); // Stop the motor if condition met clearInterval(motorIntervals[motorId]); // Stop the motor if condition met
delete motorIntervals[motorId]; // Remove from interval object delete motorIntervals[motorId]; // Remove from interval object

Loading…
Cancel
Save