Bhaskar 9 months ago
commit 27b94299e0

@ -4893,7 +4893,8 @@ client.on('message', async (topic, message) => {
const waterLevel = parseInt(waterLevelHeight * waterCapacityPerCm, 10); // Calculated water level
// Update water level in the existing tank
if (waterLevel >= 0) {
console.log(tankHeight,"this is located in tank controllers at iot-data mqtt sub ")
if (tankHeight>0 && waterLevel >= 0) {
existingTank.waterlevel = waterLevel;
await existingTank.save();
@ -4925,6 +4926,15 @@ client.on('message', async (topic, message) => {
const inputConnection = motorTank.connections.inputConnections.find(conn => conn.motor_id === hw_Id); // Updated variable name
if (inputConnection) {
inputConnection.motor_status = status; // Update motor status
if (inputConnection.motor_stop_status === "1" && status === "2" && inputConnection.motor_on_type !== "forced_manual") {
inputConnection.motor_stop_status = "2";
inputConnection.motor_on_type = "forced_manual";
}
if (inputConnection.motor_stop_status === "2" && status === "1") {
inputConnection.motor_stop_status = "1";
}
await motorTank.save(); // Save the updated tank
}

Loading…
Cancel
Save