|
|
|
@ -932,13 +932,7 @@ exports.motorAction = async (req, reply) => {
|
|
|
|
|
const thresholdTime = moment().add(req.body.manual_threshold_time, 'minutes').toDate();
|
|
|
|
|
const intervalId = setInterval(async () => {
|
|
|
|
|
// Check if threshold time has been reached
|
|
|
|
|
const splr_tank_info3 = await Tank.findOne({ customerId, tankName: req.body.from, tankLocation: req.body.from_type.toLowerCase() });
|
|
|
|
|
const splr_tank_info3_waterlevel = parseInt(splr_tank_info3.waterlevel, 10);
|
|
|
|
|
const splr_tank_info3_capacity = parseInt(splr_tank_info3.capacity, 10);
|
|
|
|
|
const splr_tank_info3_percentage = (splr_tank_info3_waterlevel / splr_tank_info3_capacity) * 100;
|
|
|
|
|
console.log(splr_tank_info3_percentage,"percentage for less than 20")
|
|
|
|
|
|
|
|
|
|
if (new Date() >= thresholdTime || splr_tank_info3_percentage<=20) {
|
|
|
|
|
if (new Date() >= thresholdTime) {
|
|
|
|
|
// Stop the motor pump
|
|
|
|
|
await Tank.updateOne(
|
|
|
|
|
{ customerId, "connections.inputConnections.motor_id": motorId },
|
|
|
|
@ -1494,7 +1488,6 @@ exports.IotDevice = async (req, reply) => {
|
|
|
|
|
const waterCapacityPerCm = parseInt(existingTank.waterCapacityPerCm.replace(/,/g, ''), 10);
|
|
|
|
|
const water_level = water_level_height * waterCapacityPerCm;
|
|
|
|
|
|
|
|
|
|
if (water_level >= 0) {
|
|
|
|
|
existingTank.waterlevel = water_level;
|
|
|
|
|
|
|
|
|
|
// Save the updated tank document
|
|
|
|
@ -1514,8 +1507,6 @@ exports.IotDevice = async (req, reply) => {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Send the latest three documents
|
|
|
|
|
const latestOttanks = await IotData.find({ hardwareId })
|
|
|
|
|
.sort({ date: -1, time: -1 });
|
|
|
|
|