diff --git a/src/controllers/tanksController.js b/src/controllers/tanksController.js index d8985a2f..13a12322 100644 --- a/src/controllers/tanksController.js +++ b/src/controllers/tanksController.js @@ -3308,10 +3308,6 @@ const monitorWaterLevels = async () => { for (const tank of tanks) { - -//console.log(fcmTokens) - //console.log(`🔍 Tank: ${tank.tankName} | Water Level: ${tank.waterlevel} | FCM Tokens:`, fcmTokens); - const { _id, customerId, // Move this to the top @@ -3336,9 +3332,13 @@ const monitorWaterLevels = async () => { //console.error("❌ No valid FCM tokens found for customerId:", customerId); continue; // Skip this tank } - const lowWaterLevel = (auto_min_percentage / 100) * capacity; // Low threshold in liters - const criticalLowWaterLevel = (reserved_percentage / 100) * capacity; // Critical threshold in liters - const currentWaterPercentage = (currentWaterLevel / capacity) * 100; // Current percentage + const LOW_PERCENTAGE = 20; // 20% threshold + const CRITICAL_PERCENTAGE = 10; // 10% threshold + + // **Calculate thresholds based on tank capacity** + const lowWaterLevel = (LOW_PERCENTAGE / 100) * capacity; + const criticalLowWaterLevel = (CRITICAL_PERCENTAGE / 100) * capacity; + const currentWaterPercentage = (currentWaterLevel / capacity) * 100; // const lowWaterLevel = 9483; // Low threshold in liters // const criticalLowWaterLevel = 9483; if (currentWaterLevel <= criticalLowWaterLevel) {