|
|
@ -1390,11 +1390,15 @@ exports.IotDevice = async (req, reply) => {
|
|
|
|
console.log(tanks)
|
|
|
|
console.log(tanks)
|
|
|
|
// Update waterlevel in tanksSchema for each tank
|
|
|
|
// Update waterlevel in tanksSchema for each tank
|
|
|
|
for (const tank of tanks) {
|
|
|
|
for (const tank of tanks) {
|
|
|
|
|
|
|
|
console.log(tank)
|
|
|
|
const { tankhardwareId, tankHeight } = tank;
|
|
|
|
const { tankhardwareId, tankHeight } = tank;
|
|
|
|
console.log(hardwareId,tankhardwareId)
|
|
|
|
console.log(hardwareId,tankhardwareId)
|
|
|
|
// Find the corresponding tank in tanksSchema
|
|
|
|
// Find the corresponding tank in tanksSchema
|
|
|
|
const existingTank = await Tank.findOne({ hardwareId, tankhardwareId });
|
|
|
|
const existingTank = await Tank.findOne({ hardwareId, tankhardwareId });
|
|
|
|
|
|
|
|
if (!existingTank) {
|
|
|
|
|
|
|
|
console.log(`No tank found for tankhardwareId '${tankhardwareId}'. Skipping.`);
|
|
|
|
|
|
|
|
continue; // Skip to the next iteration
|
|
|
|
|
|
|
|
}
|
|
|
|
console.log(existingTank,"existing tank")
|
|
|
|
console.log(existingTank,"existing tank")
|
|
|
|
if (existingTank) {
|
|
|
|
if (existingTank) {
|
|
|
|
// Update the waterlevel using the tankHeight value
|
|
|
|
// Update the waterlevel using the tankHeight value
|
|
|
|