added start and stop time

master
varun 1 year ago
parent 14bef259f3
commit f4c6286940

@ -883,7 +883,7 @@ exports.motorAction = async (req, reply) => {
if (action === "stop") { if (action === "stop") {
await Tank.updateOne( await Tank.updateOne(
{ customerId, "connections.inputConnections.motor_id": motorId }, { customerId, "connections.inputConnections.motor_id": motorId },
{ $set: { "connections.inputConnections.$.motor_stop_status": "1" } } { $set: { "connections.inputConnections.$.motor_stop_status": "1",stopTime:req.body.stopTime } }
); );
} else { } else {
// Update the motor stop status to "2" for start action // Update the motor stop status to "2" for start action
@ -917,7 +917,7 @@ exports.motorAction = async (req, reply) => {
}, 60000); // Check water level every minute }, 60000); // Check water level every minute
} else if (req.body.threshold_type === "litres") { } else if (req.body.threshold_type === "litres") {
// If threshold type is percentage, calculate percentage threshold // If threshold type is percentage, calculate percentage threshold
const receiver_tank_info = await Tank.findOne({ customerId, tankName: req.body.to, tankLocation: req.body.to_type.toLowerCase() }); const receiver_tank_info = await Tank.findOne({ customerId, tankName: req.body.to, tankLocation: req.body.to_type.toLowerCase(),startTime:req.body.startTime });
if (!receiver_tank_info) { if (!receiver_tank_info) {
throw new Error("Receiver tank not found."); throw new Error("Receiver tank not found.");
} }

@ -289,7 +289,7 @@ module.exports = function (fastify, opts, next) {
threshold_type:{type:"string"}, threshold_type:{type:"string"},
manual_threshold_litres:{type:"string"}, manual_threshold_litres:{type:"string"},
manual_threshold_time:{type:"string"}, manual_threshold_time:{type:"string"},
stop_at:{type:"number"}, stopTime:{type:"string"},
motor_id:{type:"string"}, motor_id:{type:"string"},
}, },
}, },

Loading…
Cancel
Save