diff --git a/index.js b/index.js index fd52d22..05dcaaf 100644 --- a/index.js +++ b/index.js @@ -20,11 +20,10 @@ const save_data = async time => { try { const devices = await deviceSchema.find({}); //console.log("DEVICES => " + devices); - for (const { ip, _id, lastStatus } of devices) { + for (const { _id, ip } of devices) { const value_data = await getScript(ip); const data = JSON.parse(value_data); - - //console.log(lastStatus, data.Sensors[0].Switch); + const { lastStatus } = await deviceSchema.findById(_id); if (lastStatus != data.Sensors[0].Switch) { await statusSchema.findOneAndUpdate(