diff --git a/README.md b/README.md index 037b9b08..8511adf1 100644 --- a/README.md +++ b/README.md @@ -57,6 +57,9 @@ In den Adapter-Settings muss die IP der Hue Bridge sowie ein Username konfigurie ### __WORK IN PROGRESS__ --> +### 3.5.1 (2021-02-20) +* (foxriver76) avoid crash cases on invalid xy, setting state for non-existing device and on failing user creation + ### 3.5.0 (2021-02-18) * (foxriver76) use official js-controller regex for replacing forbidden chars (fixes #165) * (foxriver76) use release-script diff --git a/io-package.json b/io-package.json index e0366dc2..936a6ffd 100644 --- a/io-package.json +++ b/io-package.json @@ -1,8 +1,20 @@ { "common": { "name": "hue", - "version": "3.5.0", + "version": "3.5.1", "news": { + "3.5.1": { + "en": "avoid crash cases on invalid xy, setting state for non-existing device and on failing user creation", + "de": "Vermeiden Sie Absturzfälle auf ungültigem xy, setzen Sie den Status für nicht vorhandenes Gerät und schlagen Sie die Benutzererstellung fehl", + "ru": "Избегайте сбоев при недопустимом xy, настройке состояния для несуществующего устройства и при сбое создания пользователя", + "pt": "evite casos de falha em xy inválido, configuração de estado para dispositivo não existente e falha na criação do usuário", + "nl": "vermijd crashgevallen op ongeldige xy, instellingstoestand voor niet-bestaand apparaat en bij mislukte aanmaak van gebruikers", + "fr": "éviter les cas de plantage sur un xy non valide, définir l'état d'un périphérique non existant et en cas d'échec de la création d'utilisateur", + "it": "evitare casi di arresto anomalo su xy non valido, impostazione dello stato per dispositivo inesistente e mancata creazione dell'utente", + "es": "evitar casos de bloqueo en xy no válido, establecer el estado para el dispositivo no existente y en la creación de un usuario fallido", + "pl": "unikaj przypadków awarii na nieprawidłowym xy, ustawianiu stanu dla nieistniejącego urządzenia i niepowodzeniu tworzenia użytkownika", + "zh-cn": "避免在无效的xy,不存在的设备的设置状态以及用户创建失败时发生崩溃的情况" + }, "3.5.0": { "en": "use official js-controller regex for replacing forbidden chars (fixes #165)\nuse release-script\nsentry added", "de": "Verwenden Sie den offiziellen regulären Ausdruck für js-controller, um verbotene Zeichen zu ersetzen (Fixes # 165).\nbenutze das Release-Skript\nWachposten hinzugefügt", @@ -230,18 +242,6 @@ "es": "Se agregaron nuevos indicadores de grupos de entretenimiento y se agregó la posibilidad de iniciar y detener la transmisión", "pl": "dodano nowe wskaźniki grup rozrywkowych oraz dodano możliwość rozpoczęcia i zakończenia transmisji", "zh-cn": "添加了娱乐团体的新指标,并增加了开始和停止流媒体播放的可能性" - }, - "3.0.3": { - "en": "fixed problem turning on/off switchs like Osram Plug", - "de": "Problem beim Ein- und Ausschalten von Schaltern wie Osram Plug behoben", - "ru": "исправлена проблема включения / выключения выключателей, таких как Osram Plug", - "pt": "problema corrigido ao ligar / desligar interruptores como o Osram Plug", - "nl": "probleem opgelost met het in- en uitschakelen van schakelaars zoals Osram Plug", - "fr": "correction d'un problème d'activation / désactivation des interrupteurs comme la prise Osram", - "it": "risolto il problema di accensione / spegnimento di interruttori come Osram Plug", - "es": "problema solucionado al encender / apagar interruptores como Osram Plug", - "pl": "naprawiono problem z włączaniem / wyłączaniem przełączników takich jak Osram Plug", - "zh-cn": "解决了打开/关闭Osram Plug等开关的问题" } }, "title": "Philips Hue Bridge", diff --git a/main.js b/main.js index 8d6f467c..75a5bbe7 100644 --- a/main.js +++ b/main.js @@ -268,7 +268,13 @@ function startAdapter(options) { try { obj = await adapter.getObjectAsync(id); } catch (e) { - adapter.log.error(`obj "${id}" in callback getObject is null or undefined`); + adapter.log.error(`Could not get object "${id}" on stateChange: ${e.message}`); + return; + } + + // maybe someone emitted a state change for a non existing device via script + if (!obj) { + adapter.log.error(`Object "${id}" on stateChange is null or undefined`); return; } @@ -316,7 +322,12 @@ function startAdapter(options) { let xy = ls.xy.toString().split(','); xy = {'x': xy[0], 'y': xy[1]}; - xy = hueHelper.GamutXYforModel(xy.x, xy.y, (Object.prototype.hasOwnProperty.call(obj.native, 'modelid') ? obj.native.modelid.trim() : 'default')); + xy = hueHelper.GamutXYforModel(xy.x, xy.y, Object.prototype.hasOwnProperty.call(obj.native, 'modelid') ? obj.native.modelid.trim() : 'default'); + if (!xy) { + adapter.log.error(`Invalid "xy" value "${state.val}" for id "${id}"`); + return; + } + finalLS.xy = `${xy.x},${xy.y}`; lightState = lightState.xy(parseFloat(xy.x), parseFloat(xy.y)); @@ -648,7 +659,7 @@ async function createUser(ip) { if (!e.getHueErrorType || e.getHueErrorType() !== 101) { adapter.log.error(e); } - return {error: e.getHueErrorType ? e.getHueErrorType() : e, message: JSON.stringify(e)}; + return {error: e.getHueErrorType ? e.getHueErrorType() : e, message: e.message}; } } // endCreateUser diff --git a/package-lock.json b/package-lock.json index ba32c7b4..4582c6fc 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "iobroker.hue", - "version": "3.5.0", + "version": "3.5.1", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index bbf6a3b4..9b638662 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "iobroker.hue", - "version": "3.5.0", + "version": "3.5.1", "description": "Connects Philips Hue LED Bulbs, Friends of Hue LED Lamps and Stripes and other SmartLink capable Devices (LivingWhites, some LivingColors) via Philips Hue Bridges", "author": "hobbyquaker ", "contributors": [