diff --git a/README.md b/README.md index 06ea30e..6934b6c 100644 --- a/README.md +++ b/README.md @@ -32,6 +32,9 @@ Connect your Philips Hue Lights with ioBroker. ## Changelog +### 1.3.8 (2020-07-04) +- (Zefau) fixed long-time polling for connection retry after connection fails serval times on short-time polling (see [#58](https://github.com/Zefau/ioBroker.hue-extended/issues/58)) + ### 1.3.7 (2020-07-01) - (Zefau) added additional verification checks of the response received from the Hue Bridge (see [#45](https://github.com/Zefau/ioBroker.hue-extended/issues/45)) - (Zefau) fixed long-time polling for connection retry after connection fails serval times on short-time polling (see [#58](https://github.com/Zefau/ioBroker.hue-extended/issues/58)) diff --git a/hue-extended.js b/hue-extended.js index e1a103c..6127b17 100644 --- a/hue-extended.js +++ b/hue-extended.js @@ -111,8 +111,9 @@ function startAdapter(options) library.set(Library.CONNECTION, true); // set current states from objects - for (let state in states) + for (let state in states) { library.setDeviceState(state.replace(adapterName + '.' + adapter.instance + '.', ''), states[state] && states[state].val); + } // retrieve payload from Hue Bridge getPayload(adapter.config.refresh || 30); @@ -633,6 +634,9 @@ function getPayload(refresh) throw new Error('Incorrect data return from Hue API'); } + // everything looks good + library.set(Library.CONNECTION, true); + // create channel library.set({ 'node': channel, @@ -702,6 +706,8 @@ function getPayload(refresh) } }).catch(err => { + library.set(Library.CONNECTION, false); + // Indicate that tree is not synchronized anymore library.set({ ...library.getNode('syncing'), 'node': 'info.syncing' }, false); //library.set({ ...library.getNode('syncing'), 'node': 'info.syncing' + library.ucFirst(channel) }, false); @@ -733,13 +739,13 @@ function getPayload(refresh) // TRY AGAIN OR STOP ADAPTER let timeout = 60; if (!retry || retry < 10) { - adapter.log.debug('Error connecting to Hue Bridge: ' + error + '. ' + (retry > 0 ? 'Already retried ' + retry + 'x so far. ' : '') + 'Try again in 10 seconds..'); + adapter.log[!retry ? 'warn' : 'debug']('Error connecting to Hue Bridge: ' + error + '. ' + (retry > 0 ? 'Already retried ' + retry + 'x so far. ' : '') + 'Reconnecting..'); //adapter.log.debug(err.message); //adapter.log.debug(JSON.stringify(err.stack)); - timeout = 10; + timeout = 6; } else { - library.terminate('Error connecting to Hue Bridge: ' + error + '. ' + (retry > 0 ? 'Already retried ' + retry + 'x in total, thus connection closed now.' : 'Connection closed.') + ' See debug log for details.'); + adapter.log.warn('Error connecting to Hue Bridge: ' + error + '. ' + (retry > 0 ? 'Already retried ' + retry + 'x so far. ' : '') + 'Try again in 1 minute..'); adapter.log.debug(err.message); adapter.log.debug(JSON.stringify(err.stack)); } diff --git a/io-package.json b/io-package.json index aa5f68f..5d46e34 100644 --- a/io-package.json +++ b/io-package.json @@ -1,7 +1,7 @@ { "common": { "name": "hue-extended", - "version": "1.3.7", + "version": "1.3.8", "title": "Philips Hue Extended", "desc": { "en": "Integration of all your Philips Hue Devices with your ioBroker", @@ -109,7 +109,7 @@ "email": "zefau@mailbox.org" } ], - "installedFrom": "https://github.com/Zefau/ioBroker.hue-extended/tarball/4667185e9a4db67b24b2165e868301576d881613" + "installedFrom": "iobroker.hue-extended@1.3.7" }, "native": { "refresh": 30, diff --git a/package.json b/package.json index 5711e3c..fd91c42 100644 --- a/package.json +++ b/package.json @@ -1,24 +1,27 @@ { - "_from": "https://github.com/Zefau/ioBroker.hue-extended/tarball/4667185e9a4db67b24b2165e868301576d881613", - "_id": "iobroker.hue-extended@1.3.6", + "_from": "iobroker.hue-extended@1.3.7", + "_id": "iobroker.hue-extended@1.3.7", "_inBundle": false, - "_integrity": "sha512-Oew4JpcBqB+T/RU+Dhn9fcCgwkvVtPTmtfkCA046A5BdlJ0fv3tvot/rdF+HxHIwtVaEwxFby/q+gFadNhnb9A==", + "_integrity": "sha512-6jDitHrsQpUkUM1FXBJjzazL3fM+fldJSr4QR9QKmytYrYcdZIXPdsLeN3osXiNThoUqZ5mHu1oaYnhQCRkOuA==", "_location": "/iobroker.hue-extended", "_phantomChildren": {}, "_requested": { - "type": "remote", - "raw": "https://github.com/Zefau/ioBroker.hue-extended/tarball/4667185e9a4db67b24b2165e868301576d881613", - "rawSpec": "https://github.com/Zefau/ioBroker.hue-extended/tarball/4667185e9a4db67b24b2165e868301576d881613", - "saveSpec": "https://github.com/Zefau/ioBroker.hue-extended/tarball/4667185e9a4db67b24b2165e868301576d881613", - "fetchSpec": "https://github.com/Zefau/ioBroker.hue-extended/tarball/4667185e9a4db67b24b2165e868301576d881613" + "type": "version", + "registry": true, + "raw": "iobroker.hue-extended@1.3.7", + "name": "iobroker.hue-extended", + "escapedName": "iobroker.hue-extended", + "rawSpec": "1.3.7", + "saveSpec": null, + "fetchSpec": "1.3.7" }, "_requiredBy": [ "#USER", "/" ], - "_resolved": "https://github.com/Zefau/ioBroker.hue-extended/tarball/4667185e9a4db67b24b2165e868301576d881613", - "_shasum": "c2c8aebfc251946f2de05232cc0382f14edc41e0", - "_spec": "https://github.com/Zefau/ioBroker.hue-extended/tarball/4667185e9a4db67b24b2165e868301576d881613", + "_resolved": "https://registry.npmjs.org/iobroker.hue-extended/-/iobroker.hue-extended-1.3.7.tgz", + "_shasum": "5a095093f3c1f6ccce5b58c5d416011e1e755b74", + "_spec": "iobroker.hue-extended@1.3.7", "_where": "/opt/iobroker", "author": { "name": "zefau", @@ -73,5 +76,5 @@ "test:unit": "mocha test/unit --exit", "translate": "gulp translateAndUpdateWordsJS" }, - "version": "1.3.7" + "version": "1.3.8" }