diff --git a/src/controllers/tanksController.js b/src/controllers/tanksController.js index 161e4882..8840dc97 100644 --- a/src/controllers/tanksController.js +++ b/src/controllers/tanksController.js @@ -2347,9 +2347,9 @@ cron.schedule("* * * * *", async () => { exports.publishMotorStopStatus = async (motor_id, motor_stop_status) => { - console.log("entered publish",motor_id,motor_stop_status) + // console.log("entered publish",motor_id,motor_stop_status) const deviceTopic = `water/operation/${motor_id}`; // Target specific IoT - console.log(deviceTopic,"deviceTopic") + //console.log(deviceTopic,"deviceTopic") const payload = { topic: 'operation', object: { @@ -2358,7 +2358,7 @@ exports.publishMotorStopStatus = async (motor_id, motor_stop_status) => { } }; - console.log(`📡 Publishing to ${deviceTopic}`); + //console.log(`📡 Publishing to ${deviceTopic}`); console.log(payload); // Publish to the specific device's control topic @@ -2913,11 +2913,10 @@ exports.motorAction = async (req, reply) => { await newMotorData.save(); console.log("entered time",motorId,motorStopStatus) // Update the tank connections with start time and threshold time - for await (const tank of Tank.find({ "connections.inputConnections.motor_id": motorId })) { this.publishMotorStopStatus(motorId, motorStopStatus); for await (const tank of Tank.find({ "connections.inputConnections.motor_id": motorId })) { const index = tank.connections.inputConnections.findIndex(connection => connection.motor_id === motorId); - + if (index !== -1) { await Tank.updateOne( { customerId, "connections.inputConnections.motor_id": motorId }, @@ -3053,7 +3052,7 @@ exports.motorAction = async (req, reply) => { // } }, 30000); // Check every minute - } + } else if (req.body.threshold_type === "litres") { console.log("entered litres")