changes in motor_id

master
varun 1 year ago
parent 25f9ced32e
commit 2179769a1f

@ -899,7 +899,7 @@ exports.motorAction = async (req, reply) => {
// If threshold type is time, update threshold time // If threshold type is time, update threshold time
await Tank.updateOne( await Tank.updateOne(
{ customerId, "connections.inputConnections.motor_id": motorId }, { customerId, "connections.inputConnections.motor_id": motorId },
{ $set: { "connections.inputConnections.$.manual_threshold_time": req.body.manual_threshold_time } } { $set: { "connections.inputConnections.$.manual_threshold_time": req.body.manual_threshold_time,startTime:req.body.startTime } }
); );
// Start monitoring water level based on threshold time // Start monitoring water level based on threshold time
@ -1356,6 +1356,7 @@ exports.IotDevice = async (req, reply) => {
try { try {
const { hardwareId, mode, tanks } = req.body; const { hardwareId, mode, tanks } = req.body;
// create a new tank document with the current date and time // create a new tank document with the current date and time
const currentDate = new Date(); const currentDate = new Date();
const date = currentDate.toISOString(); // save the date as an ISO string const date = currentDate.toISOString(); // save the date as an ISO string
@ -1386,7 +1387,7 @@ exports.IotDevice = async (req, reply) => {
for (const record of recordsToDelete) { for (const record of recordsToDelete) {
await record.remove(); await record.remove();
} }
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) {
const { tankhardwareId, tankHeight } = tank; const { tankhardwareId, tankHeight } = tank;

@ -74,7 +74,7 @@ const tanksSchema = new mongoose.Schema({
manual_threshold_percentage:{type: String, default: "90"}, manual_threshold_percentage:{type: String, default: "90"},
manual_threshold_time:{type: String, default: null}, manual_threshold_time:{type: String, default: null},
threshold_type:{type: String, default: "percentage"}, threshold_type:{type: String, default: "percentage"},
startTime:{type: String,default:null}
} }
], ],
outputConnections: [ outputConnections: [

Loading…
Cancel
Save