It's not really necessary, but it's a kind of ballast. You can follow the way I did it, but on your own risk .
Start with installing my MxInfo tools and start ConfigJson.html. Tapping on the last button in first line you see if you have old devices.
The first idea I had was to remove the old devices in the program buffer, download the new config.json onto the local PC and exchange it manually on server PC. But I'm not sure whether it is save to do so.
So I did it in this way:
- in ConfigJson.html tap on the last button in the second row to store the list of old devices into a file on server.
- add the lines below to updateBackendConfig.js at to appropiate place.
- start zway server again and the old devices mentioned in the file are deleted
If you have too many old devices, only the first part is stored. There is any limit, maybe buffer length. So you must repeat the whole procedure (store file + restart server) maybe several times.
Code: Select all
// ----------- code added 2019-02-11 start ---------------------------------
// remove old devices from config.json
var fil = 'MxInfoOldDevices.json';
try {
var devOldArray = loadObject(fil);
console.log("Info: cleaning config.json via "+fil);
if (devOldArray.length > 0) {
devOldArray.forEach(function(oldDevId) {
delete config.vdevInfo[oldDevId];
config.profiles.forEach(function(profile, ix) {
var indx;
indx = config.profiles[ix].dashboard.indexOf(oldDevId);
if (indx >= 0) {
config.profiles[ix].dashboard.splice(indx, 1);
}
indx = config.profiles[ix].hide_single_device_events.indexOf(oldDevId);
if (indx >= 0) {
config.profiles[ix].hide_single_device_events.splice(indx, 1);
}
});
});
saveObject(fil, '[]');
}
} catch(e) {
console.log("Error: cleaning config.json via "+fil+".json: ", e);
}
// ----------- code added 2019-02-11 end ---------------------------------
// Save changes
if (oldConfigJSON !== JSON.stringify(config)) { // do we need to update the config?
try {
saveObject("config.json", config);
} catch (e) {
console.log("Error: can not write back config.json to storage: ", e);
}
}
}
I added my enhanced version of updateBackendConfig.js for V2.3.7 to this post.