| 
						
						
							
								
							
						
						
					 | 
					 | 
					@ -899,7 +899,7 @@ exports.motorAction = async (req, reply) => {
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        // If threshold type is time, update threshold time
 | 
					 | 
					 | 
					 | 
					        // If threshold type is time, update threshold time
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        await Tank.updateOne(
 | 
					 | 
					 | 
					 | 
					        await Tank.updateOne(
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					          { customerId, "connections.inputConnections.motor_id": motorId },
 | 
					 | 
					 | 
					 | 
					          { customerId, "connections.inputConnections.motor_id": motorId },
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					          { $set: { "connections.inputConnections.$.manual_threshold_time": req.body.manual_threshold_time } }
 | 
					 | 
					 | 
					 | 
					          { $set: { "connections.inputConnections.$.manual_threshold_time": req.body.manual_threshold_time,startTime:req.body.startTime } }
 | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        );
 | 
					 | 
					 | 
					 | 
					        );
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        // Start monitoring water level based on threshold time
 | 
					 | 
					 | 
					 | 
					        // Start monitoring water level based on threshold time
 | 
				
			
			
		
	
	
		
		
			
				
					| 
						
							
								
							
						
						
							
								
							
						
						
					 | 
					 | 
					@ -1356,6 +1356,7 @@ exports.IotDevice = async (req, reply) => {
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					  try {
 | 
					 | 
					 | 
					 | 
					  try {
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    const { hardwareId, mode, tanks } = req.body;
 | 
					 | 
					 | 
					 | 
					    const { hardwareId, mode, tanks } = req.body;
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    
 | 
					 | 
					 | 
					 | 
					    
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    // create a new tank document with the current date and time
 | 
					 | 
					 | 
					 | 
					    // create a new tank document with the current date and time
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    const currentDate = new Date();
 | 
					 | 
					 | 
					 | 
					    const currentDate = new Date();
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    const date = currentDate.toISOString(); // save the date as an ISO string
 | 
					 | 
					 | 
					 | 
					    const date = currentDate.toISOString(); // save the date as an ISO string
 | 
				
			
			
		
	
	
		
		
			
				
					| 
						
							
								
							
						
						
							
								
							
						
						
					 | 
					 | 
					@ -1386,7 +1387,7 @@ exports.IotDevice = async (req, reply) => {
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    for (const record of recordsToDelete) {
 | 
					 | 
					 | 
					 | 
					    for (const record of recordsToDelete) {
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					      await record.remove();
 | 
					 | 
					 | 
					 | 
					      await record.remove();
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    }
 | 
					 | 
					 | 
					 | 
					    }
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					    console.log(tanks)
 | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    // Update waterlevel in tanksSchema for each tank
 | 
					 | 
					 | 
					 | 
					    // Update waterlevel in tanksSchema for each tank
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    for (const tank of tanks) {
 | 
					 | 
					 | 
					 | 
					    for (const tank of tanks) {
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					      const { tankhardwareId, tankHeight } = tank;
 | 
					 | 
					 | 
					 | 
					      const { tankhardwareId, tankHeight } = tank;
 | 
				
			
			
		
	
	
		
		
			
				
					| 
						
							
								
							
						
						
						
					 | 
					 | 
					
 
 |