From 690b0434b4e06e4bfdfdf2d25047ffabbb97359f Mon Sep 17 00:00:00 2001 From: Thomas Krofta Date: Wed, 27 Mar 2024 13:14:49 +0100 Subject: [PATCH] Fix - Ignore empty delta on startup --- openweather.js | 16 ++++++++-------- package.json | 2 +- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/openweather.js b/openweather.js index 24f4ee3..d2e4c8e 100644 --- a/openweather.js +++ b/openweather.js @@ -114,16 +114,16 @@ function onDeltasUpdate(deltas) { if (deltas === null && !Array.isArray(deltas) && deltas.length === 0) { throw "Deltas cannot be null"; } + if (deltas.updates && Array.isArray(deltas.updates)) + deltas.updates.forEach(u => { + u.values.forEach((value) => { + let onDeltaUpdated = subscriptionHandler.find((d) => d.path === value.path); - deltas.updates.forEach(u => { - u.values.forEach((value) => { - let onDeltaUpdated = subscriptionHandler.find((d) => d.path === value.path); - - if (onDeltaUpdated !== null) { - onDeltaUpdated.handle(value.value); - } + if (onDeltaUpdated !== null) { + onDeltaUpdated.handle(value.value); + } + }); }); - }); } function onPositionUpdate(value) { diff --git a/package.json b/package.json index 5befb2b..d307bda 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "openweather-signalk", - "version": "0.8.0", + "version": "0.8.1", "description": "SignalK plugin to provide data from OpenWeather Service", "main": "index.js", "scripts": {