Update main.js

This commit is contained in:
钟进 2018-09-26 14:13:14 +08:00
parent 815904ef41
commit b6f44cc454

48
main.js
View File

@ -301,6 +301,54 @@ function parseConfig(callback) {
checkObjects(adapter.config, 'door', 'door', 'Door', tasks, newObjects); checkObjects(adapter.config, 'door', 'door', 'Door', tasks, newObjects);
tasks.push({
id: 'info',
name: 'add',
obj: {
type: 'channel',
common: {
name: 'info'
},
native: {}
}
});
adapter.getObject('info.connection', function (err, obj) {
if (!obj) {
obj = {
type: 'state',
common: {
name: 'Number of connected partners',
role: 'indicator.connected',
write: false,
read: true,
type: 'boolean'
},
native: {}
};
adapter.setObjectNotExists('info.connection', obj);
}
});
newObjects.push(adapter.namespace + '.info.connection');
// clear unused states
for (let id_ in oldObjects) {
if (oldObjects.hasOwnProperty(id_) && newObjects.indexOf(id_) === -1) {
tasks.push({
id: id_,
name: 'del'
});
}
}
processTasks(tasks, function () {
oldObjects = [];
newObjects = [];
adapter.subscribeStates('*');
callback(options);
});
}); });