|
|
|
|
@ -1433,6 +1433,7 @@ exports.calculateCapacity = async (req, reply) => {
|
|
|
|
|
// };
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
exports.IotDevice = async (req, reply) => {
|
|
|
|
|
try {
|
|
|
|
|
const { hardwareId, mode, tanks } = req.body;
|
|
|
|
|
@ -1488,6 +1489,7 @@ 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
|
|
|
|
|
@ -1507,6 +1509,8 @@ exports.IotDevice = async (req, reply) => {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Send the latest three documents
|
|
|
|
|
const latestOttanks = await IotData.find({ hardwareId })
|
|
|
|
|
.sort({ date: -1, time: -1 });
|
|
|
|
|
@ -1525,6 +1529,7 @@ exports.IotDevice = async (req, reply) => {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// exports.IotDevice3 = async (req, reply) => {
|
|
|
|
|
// try {
|
|
|
|
|
// const { hardwareId, mode, tanks } = req.body;
|
|
|
|
|
|