save only 1 status

This commit is contained in:
Dawid Kubicki 2019-01-20 21:24:41 +01:00
parent bb8319acf4
commit 114463618e

View File

@ -20,10 +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 } of devices) {
const value_data = await getScript(ip);
const data = JSON.parse(value_data);
const { ip, lastStatus } = await deviceSchema.findById(_id);
//console.log(lastStatus, data.Sensors[0].Switch);
if (lastStatus != data.Sensors[0].Switch) {