Skip to content

Commit ef00d9a

Browse files
committed
Merge branch 'master' of github.com:csuermann/node-red-contrib-virtual-smart-home
2 parents d55e79c + 4491321 commit ef00d9a

File tree

4 files changed

+28
-3
lines changed

4 files changed

+28
-3
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
.DS_Store
2-
node_modules
2+
node_modules*
33
test.js
44
.vscode/launch.json

MqttClient.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ class MqttClient extends EventEmitter {
1414
resubscribe: false,
1515
clean: true,
1616
protocolVersion: 5,
17+
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.
1718
}
1819

1920
this.client = null

connection.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,15 @@ module.exports = function (RED) {
224224
execCallbackForAllThrottled = throttle(this.execCallbackForAll, 1000)
225225

226226
execCallbackForOne(nodeId, eventName, params, ...moreParams) {
227+
if (!this.childNodes[nodeId]) {
228+
this.logger(
229+
`execCallbackForOne() failed because node ${nodeId} has not been registered at this connection node!`,
230+
null,
231+
'warn'
232+
)
233+
return
234+
}
235+
227236
if (this.childNodes[nodeId][eventName]) {
228237
return this.childNodes[nodeId][eventName](params, ...moreParams)
229238
}

virtual-device.html

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,22 @@
3838
name: { value: '', required: true },
3939
//deviceId: { value: 'vshd-xxx', required: false },
4040
topic: { value: '', required: false },
41-
metadata: { value: '', required: false },
41+
metadata: {
42+
value: '',
43+
required: false,
44+
validate: (value) => {
45+
if (value === '') {
46+
// empty metadata should not be marked as invalid
47+
return true
48+
}
49+
50+
try {
51+
return typeof JSON.parse(value) === 'object'
52+
} catch (e) {
53+
return false
54+
}
55+
},
56+
},
4257
connection: { type: 'vsh-connection', required: true },
4358
template: { value: 'SWITCH', required: true },
4459
retrievable: { value: false },
@@ -128,7 +143,7 @@
128143
</div>
129144

130145
<div class="form-row">
131-
<label for="node-input-metadata"><i class="fa fa-code"></i> Metadata</label>
146+
<label><i class="fa fa-code"></i> Metadata</label>
132147
<input
133148
type="text"
134149
id="node-input-metadata"

0 commit comments

Comments
 (0)