server bug fixed

This commit is contained in:
Dawid Kubicki 2019-01-20 23:43:02 +01:00
parent 114463618e
commit 2924473ec0

View File

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