diff --git a/src/controllers/tanksController.js b/src/controllers/tanksController.js index b65cc01e..10122ac9 100644 --- a/src/controllers/tanksController.js +++ b/src/controllers/tanksController.js @@ -899,7 +899,7 @@ exports.motorAction = async (req, reply) => { // If threshold type is time, update threshold time await Tank.updateOne( { 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 @@ -1355,6 +1355,7 @@ exports.calculateCapacity = async (req, reply) => { exports.IotDevice = async (req, reply) => { try { const { hardwareId, mode, tanks } = req.body; + // create a new tank document with the current date and time const currentDate = new Date(); @@ -1386,7 +1387,7 @@ exports.IotDevice = async (req, reply) => { for (const record of recordsToDelete) { await record.remove(); } - + console.log(tanks) // Update waterlevel in tanksSchema for each tank for (const tank of tanks) { const { tankhardwareId, tankHeight } = tank; diff --git a/src/models/tanks.js b/src/models/tanks.js index 86f4d718..42ddee51 100644 --- a/src/models/tanks.js +++ b/src/models/tanks.js @@ -74,7 +74,7 @@ const tanksSchema = new mongoose.Schema({ manual_threshold_percentage:{type: String, default: "90"}, manual_threshold_time:{type: String, default: null}, threshold_type:{type: String, default: "percentage"}, - + startTime:{type: String,default:null} } ], outputConnections: [