low water levels notification

master^2
Bhaskar 9 months ago
parent 126075f5aa
commit 97128080e0

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

Loading…
Cancel
Save