From 84b1c4dde9055b5869fe6cee3b0ea852182a42ab Mon Sep 17 00:00:00 2001 From: Cornelius Suermann Date: Sat, 15 Jun 2024 14:46:13 +0200 Subject: [PATCH 1/3] fix(virtual-device): Allow empty metadata. Fixes #258 --- virtual-device.html | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/virtual-device.html b/virtual-device.html index 8a5733a..b0e93a7 100644 --- a/virtual-device.html +++ b/virtual-device.html @@ -38,7 +38,22 @@ name: { value: '', required: true }, //deviceId: { value: 'vshd-xxx', required: false }, topic: { value: '', required: false }, - metadata: { value: '', required: false }, + metadata: { + value: '', + required: false, + validate: (value) => { + if (value === '') { + // empty metadata should not be marked as invalid + return true + } + + try { + return typeof JSON.parse(value) === 'object' + } catch (e) { + return false + } + }, + }, connection: { type: 'vsh-connection', required: true }, template: { value: 'SWITCH', required: true }, retrievable: { value: false }, @@ -128,7 +143,7 @@
- + Date: Sat, 15 Jun 2024 15:09:25 +0200 Subject: [PATCH 2/3] fix(connection): Prevent crash when receiving ReportState directive for unknown devices; Fixes #257 --- connection.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/connection.js b/connection.js index d441998..e7daf0c 100644 --- a/connection.js +++ b/connection.js @@ -224,6 +224,15 @@ module.exports = function (RED) { execCallbackForAllThrottled = throttle(this.execCallbackForAll, 1000) execCallbackForOne(nodeId, eventName, params, ...moreParams) { + if (!this.childNodes[nodeId]) { + this.logger( + `execCallbackForOne() failed because node ${nodeId} has not been registered at this connection node!`, + null, + 'warn' + ) + return + } + if (this.childNodes[nodeId][eventName]) { return this.childNodes[nodeId][eventName](params, ...moreParams) } From 4491321975e6f6bc5aac5d1b2548fa1c297d5159 Mon Sep 17 00:00:00 2001 From: Cornelius Suermann Date: Sat, 17 Aug 2024 06:24:25 +0200 Subject: [PATCH 3/3] fix(MQTT): Keep using IPv4 instead of IPv6 --- .gitignore | 2 +- MqttClient.js | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index f5d8a95..6066d8e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,4 @@ .DS_Store -node_modules +node_modules* test.js .vscode/launch.json diff --git a/MqttClient.js b/MqttClient.js index f7b5e8e..62467d0 100644 --- a/MqttClient.js +++ b/MqttClient.js @@ -14,6 +14,7 @@ class MqttClient extends EventEmitter { resubscribe: false, clean: true, protocolVersion: 5, + family: 4, //Version of IP stack. Must be 4, 6, or 0. The value 0 indicates that both IPv4 and IPv6 addresses are allowed. Default: 0. } this.client = null