master
varun 1 year ago
parent e94bf2af2e
commit 3eecb3d02f

@ -1175,6 +1175,10 @@ exports.calculateCapacity = async (req, reply) => {
// reply.code(500).send({ error: err.message });
// }
// };
exports.IotDevice = async (req, reply) => {
try {
const { hardwareId, mode, tanks } = req.body;
@ -1222,7 +1226,8 @@ exports.IotDevice = async (req, reply) => {
const tank_height = parseInt(existingTank.height.replace(/,/g, ''), 10) * 30.48;
const water_level_height = tank_height - tankHeight;
const waterCapacityPerCm = parseInt(existingTank.waterCapacityPerCm.replace(/,/g, ''), 10);
const water_level = water_level_height * waterCapacityPerCm;
let water_level = water_level_height * waterCapacityPerCm;
water_level = Math.round(water_level); // Round to nearest whole number
existingTank.waterlevel = water_level.toString(); // Convert to string as per schema definition
// Save the updated tank document
@ -1259,6 +1264,8 @@ exports.IotDevice = async (req, reply) => {
}
};
// exports.getIotD = async(req, reply) => {
// try {
// await IotData.find({hardwareId: req.query.hardwareId})

Loading…
Cancel
Save