|
|
|
@ -3274,7 +3274,24 @@ exports.motorAction = async (req, reply) => {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} else if (action === "stop") {
|
|
|
|
|
await stopMotor(motorId, customerId, start_instance_id);
|
|
|
|
|
// Dynamically find start_instance_id from tank
|
|
|
|
|
const tankWithMotor = await Tank.findOne({
|
|
|
|
|
customerId,
|
|
|
|
|
"connections.inputConnections.motor_id": motorId
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
let dynamicInstanceId = null;
|
|
|
|
|
|
|
|
|
|
if (tankWithMotor) {
|
|
|
|
|
const connection = tankWithMotor.connections.inputConnections.find(conn => conn.motor_id === motorId);
|
|
|
|
|
if (connection && connection.start_instance_id) {
|
|
|
|
|
dynamicInstanceId = connection.start_instance_id;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
await stopMotor(motorId, customerId, dynamicInstanceId);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|