diff --git a/README.md b/README.md index d0abf313..b7d6b558 100644 --- a/README.md +++ b/README.md @@ -171,6 +171,11 @@ The datapoints are created on the basis of the returned values of the Fritz AHA |toggle|boolean|x|toggle switch for template activation| |lasttemplate|text|-|last confirmed template| +### routines +|Object|Value|settable|Description| +|--------|-------|:-:|--------| +|active|boolean|x|toggle switch for routine activation| + ## API limitations * Boost and WindowOpen can only be set for the next 24h. time=0 is cancelling the command @@ -195,6 +200,10 @@ otherwise it is more complex and individually to be parametrized. * blind alert state -> decode bit array ## Changelog +### 2.4.0 +* new function for routines which activatetrigger +* correction for templates and scenario (all templates are buttons, no need to check functionbitmask) + ### 2.3.1 * new function gettriggerlist in admin * corrected xml2json-light (included drirectly in repo until PR#8 is merged in repo), caused problems with templates in newer FB-firmware diff --git a/io-package.json b/io-package.json index b6cf2fff..74aea773 100644 --- a/io-package.json +++ b/io-package.json @@ -1,8 +1,21 @@ { "common": { "name": "fritzdect", - "version": "2.3.1", + "version": "2.4.0", "news": { + "2.4.0": { + "en": "new function for routines, correction for templates", + "de": "neue funktion für routinen, korrektur für vorlagen", + "ru": "новая функция для рутин, коррекция для шаблонов", + "pt": "nova função para rotinas, correção para modelos", + "nl": "nieuwe functie voor routines, correctie voor templates", + "fr": "nouvelle fonction pour les routines, correction pour les modèles", + "it": "nuova funzione per le routine, correzione per i modelli", + "es": "nueva función para rutinas, corrección para plantillas", + "pl": "nowe funkcje dla rutynów, poprawki do szablonów", + "uk": "нова функція для рутин, виправлення шаблонів", + "zh-cn": "例行的新职能,模板的更正" + }, "2.3.1": { "en": "fault correction on xml2json conversion at templates from newer FB firmware", "de": "Fehlerkorrektur bei xml2json Konvertierung bei Vorlagen aus neuerer FB Firmware", diff --git a/main.js b/main.js index 2f2d687f..ca24a93d 100644 --- a/main.js +++ b/main.js @@ -193,6 +193,9 @@ class Fritzdect extends utils.Adapter { this.log.info('start creating templates '); await this.createTemplates(this.fritz).catch((e) => this.errorHandlerAdapter(e)); this.log.info('finished creating templates (if any) '); + this.log.info('start creating routines '); + await this.createRoutines(this.fritz).catch((e) => this.errorHandlerAdapter(e)); + this.log.info('finished creating routines (if any) '); this.log.info('start initial updating devices/groups'); await this.updateDevices(this.fritz).catch((e) => this.errorHandlerAdapter(e)); this.log.info('finished initial updating devices/groups'); @@ -205,6 +208,7 @@ class Fritzdect extends utils.Adapter { try { this.log.debug('polling! fritzdect is alive'); await this.updateDevices(this.fritz).catch((e) => this.errorHandlerAdapter(e)); + await this.updateRoutines(this.fritz).catch((e) => this.errorHandlerAdapter(e)); } catch (e) { this.log.warn(`[Polling] <== ${e}`); } @@ -889,6 +893,28 @@ class Fritzdect extends utils.Adapter { .catch((e) => this.errorHandlerApi(e)); } } + } else if (idx.startsWith('routine_')) { + //must be fritzbox routine + id = idx.replace(/routine_/g, ''); //routine + this.log.info('Routine ID: ' + id + ' identified for command (' + dp + ') : ' + state.val); + if (dp == 'active') { + if ( + state.val === 1 || + state.val === '1' || + state.val === 'true' || + state.val === true || + state.val === 'on' || + state.val === 'ON' + ) { + this.fritz + .applyTrigger(id) + .then((sid) => { + this.log.debug('cmd Active to template ' + id + ' to ' + state.val); + this.log.debug('response ' + sid); + }) + .catch((e) => this.errorHandlerApi(e)); + } + } } } } //from if state&ack @@ -1141,7 +1167,7 @@ class Fritzdect extends utils.Adapter { if (error == '0000000000000000') { this.log.error('Did not get session id -> invalid username or password?'); } else if (!error.response) { - this.log.error('no response part in returned message'); + this.log.error('no response part in returned error message'); } else if (error.response.statusCode) { if (error.response.statusCode == 403) { this.log.error( @@ -1178,6 +1204,42 @@ class Fritzdect extends utils.Adapter { this.log.error('try/catch error in function errorHandlerAdapter' + e); } } + async updateRoutines(fritz) { + this.log.debug('__________________________'); + this.log.debug('updating Routines '); + try { + const routineslistinfos = await fritz.getTriggerListInfos().catch((e) => this.errorHandlerApi(e)); + let typ = ''; + let role = ''; + if (routineslistinfos) { + let routines = parser.xml2json(routineslistinfos); + routines = [].concat((routines.triggerlist || {}).trigger || []).map((trigger) => { + return trigger; + }); + this.log.debug('__________________________'); + this.log.debug('routines\n'); + this.log.debug(JSON.stringify(routines)); + if (routines.length) { + this.log.debug('update routines ' + routines.length); + await Promise.all( + routines.map(async (routine) => { + this.log.debug('__________________________'); + this.log.debug('updating Routine ' + routine.name); + let active = routine.active == 0 ? false : true; + await this.setStateAsync('routine_' + routine.identifier.replace(/\s/g, '') + '.active', { + val: active, + ack: true + }); + this.log.debug('activation is ' + active); + }) + ); + } + } + return Promise.resolve(); + } catch (e) { + return Promise.reject(this.log.error('try/catch updateRoutines ' + e)); + } + } async updateDevices(fritz) { this.log.debug('__________________________'); this.log.debug('updating Devices / Groups '); @@ -1822,49 +1884,19 @@ class Fritzdect extends utils.Adapter { //await this.asyncForEach(templates, async (template) => { await Promise.all( templates.map(async (template) => { - if ( - (template.functionbitmask & 320) == 320 || - (template.functionbitmask & 4160) == 4160 || - (template.functionbitmask & 2688) == 2688 || - (template.functionbitmask & 40960) == 40960 || - (template.functionbitmask & 36864) == 36864 || - (template.functionbitmask & 335888) == 335888 || - (template.functionbitmask & 2944) == 2944 - ) { - //heating template - typ = 'template_'; - role = 'switch'; - this.log.debug('__________________________'); - this.log.debug('setting up Template ' + template.name); - await this.createTemplate( - typ, - template.identifier.replace(/\s/g, ''), - template.name, - role, - template.id - ); - } else if (template.functionbitmask == 0 && template.applymask[0] == 256) { - // no other way to identify this one, role as switch may be not right - //telefon template - typ = 'template_'; - role = 'switch'; - this.log.debug('__________________________'); - this.log.debug('setting up Template ' + template.name); - await this.createTemplate( - typ, - template.identifier.replace(/\s/g, ''), - template.name, - role, - template.id - ); - } else { - this.log.debug( - 'nix vorbereitet für diese Art von Template ' + - template.functionbitmask + - ' -> ' + - template.name - ); - } + //everything in template is a button to be activated, no need to check the functionbitmask + //subtemplates or devices are not taken over to iobroker + typ = 'template_'; + role = 'switch'; + this.log.debug('__________________________'); + this.log.debug('setting up Template ' + template.name); + await this.createTemplate( + typ, + template.identifier.replace(/\s/g, ''), + template.name, + role, + template.id + ); }) ); } @@ -1874,6 +1906,45 @@ class Fritzdect extends utils.Adapter { return Promise.reject(this.log.error('try/catch createTemplates ' + e)); } } + async createRoutines(fritz) { + try { + const routineslistinfos = await fritz.getTriggerListInfos().catch((e) => this.errorHandlerApi(e)); + let typ = ''; + let role = ''; + if (routineslistinfos) { + let routines = parser.xml2json(routineslistinfos); + routines = [].concat((routines.triggerlist || {}).trigger || []).map((trigger) => { + return trigger; + }); + this.log.debug('__________________________'); + this.log.debug('routines\n'); + this.log.debug(JSON.stringify(routines)); + if (routines.length) { + this.log.info('CREATE Routines ' + routines.length); + await Promise.all( + routines.map(async (routine) => { + //heating template + typ = 'routine_'; + role = 'switch'; + this.log.debug('__________________________'); + this.log.debug('setting up Routine ' + routine.name); + let active = routine.active == 0 ? false : true; + await this.createRoutine( + typ, + routine.identifier.replace(/\s/g, ''), + routine.name, + role, + active + ); + }) + ); + } + } + return Promise.resolve(); + } catch (e) { + return Promise.reject(this.log.error('try/catch createRoutines ' + e)); + } + } async createDevices(fritz) { try { const devicelistinfos = await fritz.getDeviceListInfos().catch((e) => this.errorHandlerApi(e)); @@ -3047,6 +3118,46 @@ class Fritzdect extends utils.Adapter { await this.setStateAsync(typ + newId + '.toggle', { val: false, ack: true }); return; } + async createRoutine(typ, newId, name, role, val) { + this.log.debug('create Template objects '); + await this.setObjectNotExistsAsync(typ + newId, { + type: 'channel', + common: { + name: name, + role: role + }, + native: { + aid: newId + } + }); + await this.setObjectNotExistsAsync(typ + newId + '.name', { + type: 'state', + common: { + name: 'Name', + type: 'string', + read: true, + write: false, + role: 'info', + desc: 'Name' + }, + native: {} + }); + await this.setStateAsync(typ + newId + '.name', { val: name, ack: true }); + await this.setObjectNotExistsAsync(typ + newId + '.active', { + type: 'state', + common: { + name: 'Routine activation', + type: 'boolean', + read: true, + write: true, + role: 'button', + desc: 'Routine Activation' + }, + native: {} + }); + await this.setStateAsync(typ + newId + '.active', { val: val, ack: true }); + return; + } async createThermostat(newId) { this.log.debug('create Thermostat objects'); await this.setObjectNotExistsAsync('DECT_' + newId + '.hkrmode', { diff --git a/package-lock.json b/package-lock.json index bf6326ed..57cded82 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "iobroker.fritzdect", - "version": "2.3.1", + "version": "2.4.0", "lockfileVersion": 1, "requires": true, "dependencies": { @@ -36,9 +36,9 @@ } }, "@eslint-community/regexpp": { - "version": "4.8.0", - "resolved": "https://registry.npmjs.org/@eslint-community/regexpp/-/regexpp-4.8.0.tgz", - "integrity": "sha512-JylOEEzDiOryeUnFbQz+oViCXS0KsvR1mvHkoMiu5+UiBvy+RYX7tzlIIIEstF/gVa2tj9AQXk3dgnxv6KxhFg==", + "version": "4.8.1", + "resolved": "https://registry.npmjs.org/@eslint-community/regexpp/-/regexpp-4.8.1.tgz", + "integrity": "sha512-PWiOzLIUAjN/w5K17PoF4n6sKBw0gqLHPhywmYHP4t1VFQQVYeb1yWsJwnMVEMl3tUHME7X/SJPZLmtG7XBDxQ==", "dev": true }, "@eslint/eslintrc": { @@ -70,9 +70,9 @@ } }, "@eslint/js": { - "version": "8.48.0", - "resolved": "https://registry.npmjs.org/@eslint/js/-/js-8.48.0.tgz", - "integrity": "sha512-ZSjtmelB7IJfWD2Fvb7+Z+ChTIKWq6kjda95fLcQKNS5aheVHn4IkfgRQE3sIIzTcSLwLcLZUD9UBt+V7+h+Pw==", + "version": "8.49.0", + "resolved": "https://registry.npmjs.org/@eslint/js/-/js-8.49.0.tgz", + "integrity": "sha512-1S8uAY/MTJqVx0SC4epBq+N2yhuwtNwLbJYNZyhL2pO1ZVKn5HFXav5T41Ryzy9K9V7ZId2JB2oy/W4aCd9/2w==", "dev": true }, "@humanwhocodes/config-array": { @@ -222,9 +222,9 @@ "dev": true }, "@types/chai": { - "version": "4.3.5", - "resolved": "https://registry.npmjs.org/@types/chai/-/chai-4.3.5.tgz", - "integrity": "sha512-mEo1sAde+UCE6b2hxn332f1g1E8WfYRu6p5SvTKr2ZKC1f7gFJXk4h5PyGP9Dt6gCaG8y8XhwnXWC6Iy2cmBng==", + "version": "4.3.6", + "resolved": "https://registry.npmjs.org/@types/chai/-/chai-4.3.6.tgz", + "integrity": "sha512-VOVRLM1mBxIRxydiViqPcKn6MIxZytrbMpd6RJLIWKxUNr3zux8no0Oc7kJx0WAPIitgZ0gkrDS+btlqQpubpw==", "dev": true }, "@types/chai-as-promised": { @@ -254,9 +254,9 @@ } }, "@types/gulp": { - "version": "4.0.13", - "resolved": "https://registry.npmjs.org/@types/gulp/-/gulp-4.0.13.tgz", - "integrity": "sha512-Ms20Q2tZ3MpThZGn4Ag6e7ifz/oQJFxsuiopqz5oHmhE6q2ohnELgafi5K/pKX/4ntlpidS61v/TXAguYsVcaA==", + "version": "4.0.14", + "resolved": "https://registry.npmjs.org/@types/gulp/-/gulp-4.0.14.tgz", + "integrity": "sha512-zjhBRyGTIPnJ/gByJpjtFyRPKej7zkNFct+QgDhAwpOEoJ2MQjajhU69vrcHIffKcnt3Dik2JHzgMj0C1q9WOg==", "dev": true, "requires": { "@types/undertaker": ">=1.2.6", @@ -279,9 +279,9 @@ "dev": true }, "@types/node": { - "version": "20.5.7", - "resolved": "https://registry.npmjs.org/@types/node/-/node-20.5.7.tgz", - "integrity": "sha512-dP7f3LdZIysZnmvP3ANJYTSwg+wLLl8p7RqniVlV7j+oXSXAbt9h0WIBFmJy5inWZoX9wZN6eXx+YXd9Rh3RBA==" + "version": "20.6.3", + "resolved": "https://registry.npmjs.org/@types/node/-/node-20.6.3.tgz", + "integrity": "sha512-HksnYH4Ljr4VQgEy2lTStbCKv/P590tmPe5HqOnv9Gprffgv5WXAY+Y5Gqniu0GGqeTCUdBnzC3QSrzPkBkAMA==" }, "@types/picomatch": { "version": "2.3.0", @@ -330,9 +330,9 @@ } }, "@types/undertaker": { - "version": "1.2.8", - "resolved": "https://registry.npmjs.org/@types/undertaker/-/undertaker-1.2.8.tgz", - "integrity": "sha512-gW3PRqCHYpo45XFQHJBhch7L6hytPsIe0QeLujlnFsjHPnXLhJcPdN6a9368d7aIQgH2I/dUTPFBlGeSNA3qOg==", + "version": "1.2.9", + "resolved": "https://registry.npmjs.org/@types/undertaker/-/undertaker-1.2.9.tgz", + "integrity": "sha512-rOGGHtWFP4jsSKXvW2BJn+hYIAJ4cvsJi5wscbfbBHQ0yLQvTUXKvL+i72cv+8biktveFLEqbMpsKmJQxYVPQw==", "dev": true, "requires": { "@types/node": "*", @@ -341,9 +341,9 @@ } }, "@types/undertaker-registry": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/@types/undertaker-registry/-/undertaker-registry-1.0.1.tgz", - "integrity": "sha512-Z4TYuEKn9+RbNVk1Ll2SS4x1JeLHecolIbM/a8gveaHsW0Hr+RQMraZACwTO2VD7JvepgA6UO1A1VrbktQrIbQ==", + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/@types/undertaker-registry/-/undertaker-registry-1.0.2.tgz", + "integrity": "sha512-O9CqcXYnCsHUSd71+hohlhEaP57dThYQQ8/cDwskhTCJ1kA3E5CVaK1sbEnukP2eWlpSgae/8KqgJBw3w/DmoQ==", "dev": true }, "@types/vinyl": { @@ -436,9 +436,9 @@ "dev": true }, "anymatch": { - "version": "3.1.2", - "resolved": "https://registry.npmjs.org/anymatch/-/anymatch-3.1.2.tgz", - "integrity": "sha512-P43ePfOAIupkguHUycrc4qJ9kz8ZiuOUijaETwX7THt0Y/GNK7v0aa8rY816xWjZ7rJdA5XdMcpVFTKMq+RvWg==", + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/anymatch/-/anymatch-3.1.3.tgz", + "integrity": "sha512-KMReFUr0B4t+D+OBkjR3KYqvocp2XaSzO55UcB6mgQMd3KbcE+mWTyvVV7D/zsdEbNnV6acZUutkiHQXvTr1Rw==", "dev": true, "requires": { "normalize-path": "^3.0.0", @@ -720,9 +720,9 @@ } }, "binary-extensions": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-2.1.0.tgz", - "integrity": "sha512-1Yj8h9Q+QDF5FzhMs/c9+6UntbD5MkRfRwac8DoEm9ZfUBZ7tZ55YcGVAzEe4bXsdQHEk+s9S5wsOKVdZrw0tQ==", + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-2.2.0.tgz", + "integrity": "sha512-jDctJ/IVQbZoJykoeHbhXpOlNBqGNcwXJKJog42E5HDPUwQTSdjCHdihjj0DlnheQ7blbT6dHOafNAiS8ooQKA==", "dev": true }, "bindings": { @@ -1339,16 +1339,16 @@ "dev": true }, "eslint": { - "version": "8.48.0", - "resolved": "https://registry.npmjs.org/eslint/-/eslint-8.48.0.tgz", - "integrity": "sha512-sb6DLeIuRXxeM1YljSe1KEx9/YYeZFQWcV8Rq9HfigmdDEugjLEVEa1ozDjL6YDjBpQHPJxJzze+alxi4T3OLg==", + "version": "8.49.0", + "resolved": "https://registry.npmjs.org/eslint/-/eslint-8.49.0.tgz", + "integrity": "sha512-jw03ENfm6VJI0jA9U+8H5zfl5b+FvuU3YYvZRdZHOlU2ggJkxrlkJH4HcDrZpj6YwD8kuYqvQM8LyesoazrSOQ==", "dev": true, "requires": { "@eslint-community/eslint-utils": "^4.2.0", "@eslint-community/regexpp": "^4.6.1", "@eslint/eslintrc": "^2.1.2", - "@eslint/js": "8.48.0", - "@humanwhocodes/config-array": "^0.11.10", + "@eslint/js": "8.49.0", + "@humanwhocodes/config-array": "^0.11.11", "@humanwhocodes/module-importer": "^1.0.1", "@nodelib/fs.walk": "^1.2.8", "ajv": "^6.12.4", @@ -1780,9 +1780,9 @@ } }, "flatted": { - "version": "3.2.7", - "resolved": "https://registry.npmjs.org/flatted/-/flatted-3.2.7.tgz", - "integrity": "sha512-5nqDSxl8nn5BSNxyR3n4I6eDmbolI6WT+QqR547RwxQapgjQBmtktdP+HTBb/a/zLsbzERTONyUB5pefh5TtjQ==", + "version": "3.2.9", + "resolved": "https://registry.npmjs.org/flatted/-/flatted-3.2.9.tgz", + "integrity": "sha512-36yxDn5H7OFZQla0/jFJmbIKTdZAQHngCedGxiMmpNfEZM0sdEeT+WczLQrjK6D7o2aiyLYDnkw0R3JK0Qv1RQ==", "dev": true }, "flush-write-stream": { @@ -1796,9 +1796,9 @@ } }, "follow-redirects": { - "version": "1.15.2", - "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.2.tgz", - "integrity": "sha512-VQLG33o04KaQ8uYi2tVNbdrWp1QWxNNea+nmIB4EVM28v0hmP17z7aG1+wAkNzVq4KeXTq3221ye5qTJP91JwA==", + "version": "1.15.3", + "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.3.tgz", + "integrity": "sha512-1VzOtuEM8pC9SFU1E+8KfTjZyMztRsgEfwQl44z8A25uy13jSzTj6dyK2Df52iV0vgHCfBwLhDWevLn95w5v6Q==", "dev": true }, "for-in": { @@ -1843,6 +1843,48 @@ "requires": { "command-line-args": "^5.2.0", "command-line-usage": "^7.0.1" + }, + "dependencies": { + "array-back": { + "version": "6.2.2", + "resolved": "https://registry.npmjs.org/array-back/-/array-back-6.2.2.tgz", + "integrity": "sha512-gUAZ7HPyb4SJczXAMUXMGAvI976JoK3qEx9v1FTmeYuJj0IBiaKttG1ydtGKdkfqWkIkouke7nG8ufGy77+Cvw==" + }, + "command-line-usage": { + "version": "7.0.1", + "resolved": "https://registry.npmjs.org/command-line-usage/-/command-line-usage-7.0.1.tgz", + "integrity": "sha512-NCyznE//MuTjwi3y84QVUGEOT+P5oto1e1Pk/jFPVdPPfsG03qpTIl3yw6etR+v73d0lXsoojRpvbru2sqePxQ==", + "requires": { + "array-back": "^6.2.2", + "chalk-template": "^0.4.0", + "table-layout": "^3.0.0", + "typical": "^7.1.1" + } + }, + "table-layout": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/table-layout/-/table-layout-3.0.2.tgz", + "integrity": "sha512-rpyNZYRw+/C+dYkcQ3Pr+rLxW4CfHpXjPDnG7lYhdRoUcZTUt+KEsX+94RGp/aVp/MQU35JCITv2T/beY4m+hw==", + "requires": { + "@75lb/deep-merge": "^1.1.1", + "array-back": "^6.2.2", + "command-line-args": "^5.2.1", + "command-line-usage": "^7.0.0", + "stream-read-all": "^3.0.1", + "typical": "^7.1.1", + "wordwrapjs": "^5.1.0" + } + }, + "typical": { + "version": "7.1.1", + "resolved": "https://registry.npmjs.org/typical/-/typical-7.1.1.tgz", + "integrity": "sha512-T+tKVNs6Wu7IWiAce5BgMd7OZfNYUndHwc5MknN+UHOudi7sGZzuHdCadllRuqJ3fPtgFtIH9+lt9qRv6lmpfA==" + }, + "wordwrapjs": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/wordwrapjs/-/wordwrapjs-5.1.0.tgz", + "integrity": "sha512-JNjcULU2e4KJwUNv6CHgI46UvDGitb6dGryHajXTDiLgg1/RiGoPSDw4kZfYnwGtEXf2ZMeIewDQgFGzkCB2Sg==" + } } }, "fs-extra": { @@ -1873,9 +1915,9 @@ "dev": true }, "fsevents": { - "version": "2.3.2", - "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz", - "integrity": "sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==", + "version": "2.3.3", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz", + "integrity": "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==", "dev": true, "optional": true }, @@ -3352,31 +3394,31 @@ "dev": true }, "nise": { - "version": "5.1.2", - "resolved": "https://registry.npmjs.org/nise/-/nise-5.1.2.tgz", - "integrity": "sha512-+gQjFi8v+tkfCuSCxfURHLhRhniE/+IaYbIphxAN2JRR9SHKhY8hgXpaXiYfHdw+gcGe4buxgbprBQFab9FkhA==", + "version": "5.1.4", + "resolved": "https://registry.npmjs.org/nise/-/nise-5.1.4.tgz", + "integrity": "sha512-8+Ib8rRJ4L0o3kfmyVCL7gzrohyDe0cMFTBa2d364yIrEGMEoetznKJx899YxjybU6bL9SQkYPSBBs1gyYs8Xg==", "dev": true, "requires": { "@sinonjs/commons": "^2.0.0", - "@sinonjs/fake-timers": "^7.0.4", + "@sinonjs/fake-timers": "^10.0.2", "@sinonjs/text-encoding": "^0.7.1", "just-extend": "^4.0.2", "path-to-regexp": "^1.7.0" }, "dependencies": { "@sinonjs/fake-timers": { - "version": "7.1.2", - "resolved": "https://registry.npmjs.org/@sinonjs/fake-timers/-/fake-timers-7.1.2.tgz", - "integrity": "sha512-iQADsW4LBMISqZ6Ci1dupJL9pprqwcVFTcOsEmQOEhW+KLCVn/Y4Jrvg2k19fIHCp+iFprriYPTdRcQR8NbUPg==", + "version": "10.3.0", + "resolved": "https://registry.npmjs.org/@sinonjs/fake-timers/-/fake-timers-10.3.0.tgz", + "integrity": "sha512-V4BG07kuYSUkTCSBHG8G8TNhM+F19jXFWnQtzj+we8DrkpSBCee9Z3Ms8yiGer/dlmhe35/Xdgyo3/0rQKg7YA==", "dev": true, "requires": { - "@sinonjs/commons": "^1.7.0" + "@sinonjs/commons": "^3.0.0" }, "dependencies": { "@sinonjs/commons": { - "version": "1.8.6", - "resolved": "https://registry.npmjs.org/@sinonjs/commons/-/commons-1.8.6.tgz", - "integrity": "sha512-Ky+XkAkqPZSm3NLBeUng77EBQl3cmeJhITaGHdYH8kjVB+aun3S4XBRti2zt17mtt0mIUDiNxYeoJm6drVvBJQ==", + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/@sinonjs/commons/-/commons-3.0.0.tgz", + "integrity": "sha512-jXBtWAF4vmdNmZgD5FoKsVLv3rPgDnLgPbU84LIJ3otV44vJlDRokVng5v8NFJdCf/da9legHcKaRuZs4L7faA==", "dev": true, "requires": { "type-detect": "4.0.8" @@ -3704,9 +3746,9 @@ "dev": true }, "picomatch": { - "version": "2.2.2", - "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.2.2.tgz", - "integrity": "sha512-q0M/9eZHzmr0AulXyPwNfZjtwZ/RBZlbN3K3CErVrk50T2ASYI7Bye0EvekFY3IP1Nt2DHu0re+V2ZHIpMkuWg==", + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz", + "integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==", "dev": true }, "pify": { @@ -4181,30 +4223,6 @@ "resolved": "https://registry.npmjs.org/diff/-/diff-5.1.0.tgz", "integrity": "sha512-D+mk+qE8VC/PAUrlAU34N+VfXev0ghe5ywmpqrawphmVZc1bEfn56uo9qpyGp1p4xpzOHkSW4ztBd6L7Xx4ACw==", "dev": true - }, - "nise": { - "version": "5.1.4", - "resolved": "https://registry.npmjs.org/nise/-/nise-5.1.4.tgz", - "integrity": "sha512-8+Ib8rRJ4L0o3kfmyVCL7gzrohyDe0cMFTBa2d364yIrEGMEoetznKJx899YxjybU6bL9SQkYPSBBs1gyYs8Xg==", - "dev": true, - "requires": { - "@sinonjs/commons": "^2.0.0", - "@sinonjs/fake-timers": "^10.0.2", - "@sinonjs/text-encoding": "^0.7.1", - "just-extend": "^4.0.2", - "path-to-regexp": "^1.7.0" - }, - "dependencies": { - "@sinonjs/commons": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/@sinonjs/commons/-/commons-2.0.0.tgz", - "integrity": "sha512-uLa0j859mMrg2slwQYdO/AkrOfmH+X6LTVmNTS9CqexuE2IvVORIkSpJLqePAbEnKJ77aMmCwr1NUZ57120Xcg==", - "dev": true, - "requires": { - "type-detect": "4.0.8" - } - } - } } } }, diff --git a/package.json b/package.json index 12207a47..a919d25c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "iobroker.fritzdect", - "version": "2.3.1", + "version": "2.4.0", "description": "ioBroker fritzbox DECT Adapter", "author": { "name": "foxthefox", @@ -11,7 +11,16 @@ }, "homepage": "https://github.com/foxthefox/ioBroker.fritzdect", "license": "MIT", - "keywords": [ "ioBroker", "DECT2x0", "DECT3x0", "DECT4x0", "DECT500", "Contacts", "Blinds", "fritzbox" ], + "keywords": [ + "ioBroker", + "DECT2x0", + "DECT3x0", + "DECT4x0", + "DECT500", + "Contacts", + "Blinds", + "fritzbox" + ], "repository": { "type": "git", "url": "https://github.com/foxthefox/ioBroker.fritzdect" diff --git a/test/integration.js b/test/integration.js index b8e4901b..ed79c7d4 100644 --- a/test/integration.js +++ b/test/integration.js @@ -10,6 +10,7 @@ console.log('PATH ist ' + path.join(__dirname, './data/')); const xmlDevicesGroups = fs.readFileSync(path.join(__dirname, './data/') + 'test_api_response.xml'); const xmlTemplate = fs.readFileSync(path.join(__dirname, './data/') + 'template_answer.xml'); +//const xmlTemplate = fs.readFileSync(path.join(__dirname, './data/') + 'template.xml'); const xmlTriggerlist = fs.readFileSync(path.join(__dirname, './data/') + 'getriggerlistinfos.xml'); const xmlTempStat = fs.readFileSync(path.join(__dirname, './data/') + 'devicestat_temp_answer.xml'); const xmlPowerStats = fs.readFileSync(path.join(__dirname, './data/') + 'devicestat_power_answer.xml'); @@ -2931,7 +2932,34 @@ tests.integration(path.join(__dirname, '..'), { ); }); }).timeout(2000); - + //hier für routines ein neues describe? + it('Check values of routine 1, should be created', () => { + return new Promise(async (resolve) => { + harness.states.getState('fritzdect.0.routine_trg695F2D-3CBF1DC25.name', function(err, state) { + if (err) console.error(err); + expect(state).to.exist; + if (!state) { + console.error('state "fritzdect.0.routine_trg695F2D-3CBF1DC25.name" not set'); + } else { + console.log('fritzdect.0.routine_trg695F2D-3CBF1DC25.name ... ' + state.val); + } + expect(state.val).to.exist; + expect(state.val).to.be.equal('Trigger AlertOn'); + harness.states.getState('fritzdect.0.routine_trg695F2D-3CBF1DC25.active', function(err, state) { + if (err) console.error(err); + expect(state).to.exist; + if (!state) { + console.error('state "fritzdect.0.routine_trg695F2D-3CBF1DC25.active" not set'); + } else { + console.log('fritzdect.0.routine_trg695F2D-3CBF1DC25.active ... ' + state.val); + expect(state.val).to.exist; + expect(state.val).to.be.equal(true); + resolve(); + } + }); + }); + }); + }).timeout(2000); /* it('Should work, to send a message', () => { return new Promise(async (resolve) => {