diff --git a/main.js b/main.js index adb1413..c459435 100644 --- a/main.js +++ b/main.js @@ -301,6 +301,54 @@ function parseConfig(callback) { 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); + }); });