master^2
Varun 7 months ago
parent 17ec6115a8
commit 776586ece4

@ -2347,9 +2347,9 @@ cron.schedule("* * * * *", async () => {
exports.publishMotorStopStatus = async (motor_id, motor_stop_status) => { 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 const deviceTopic = `water/operation/${motor_id}`; // Target specific IoT
console.log(deviceTopic,"deviceTopic") //console.log(deviceTopic,"deviceTopic")
const payload = { const payload = {
topic: 'operation', topic: 'operation',
object: { 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); console.log(payload);
// Publish to the specific device's control topic // Publish to the specific device's control topic
@ -2913,7 +2913,6 @@ exports.motorAction = async (req, reply) => {
await newMotorData.save(); await newMotorData.save();
console.log("entered time",motorId,motorStopStatus) console.log("entered time",motorId,motorStopStatus)
// Update the tank connections with start time and threshold time // 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); this.publishMotorStopStatus(motorId, motorStopStatus);
for await (const tank of Tank.find({ "connections.inputConnections.motor_id": motorId })) { for await (const tank of Tank.find({ "connections.inputConnections.motor_id": motorId })) {
const index = tank.connections.inputConnections.findIndex(connection => connection.motor_id === motorId); const index = tank.connections.inputConnections.findIndex(connection => connection.motor_id === motorId);
@ -3053,7 +3052,7 @@ exports.motorAction = async (req, reply) => {
// } // }
}, 30000); // Check every minute }, 30000); // Check every minute
}
} }
else if (req.body.threshold_type === "litres") { else if (req.body.threshold_type === "litres") {
console.log("entered litres") console.log("entered litres")

Loading…
Cancel
Save