Skip to content

Commit

Permalink
Merge branch 'master' of github.com:csuermann/node-red-contrib-virtua…
Browse files Browse the repository at this point in the history
…l-smart-home
  • Loading branch information
csuermann committed Oct 25, 2024
2 parents d55e79c + 4491321 commit ef00d9a
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.DS_Store
node_modules
node_modules*
test.js
.vscode/launch.json
1 change: 1 addition & 0 deletions MqttClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 9 additions & 0 deletions connection.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
19 changes: 17 additions & 2 deletions virtual-device.html
Original file line number Diff line number Diff line change
Expand Up @@ -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 },
Expand Down Expand Up @@ -128,7 +143,7 @@
</div>

<div class="form-row">
<label for="node-input-metadata"><i class="fa fa-code"></i> Metadata</label>
<label><i class="fa fa-code"></i> Metadata</label>
<input
type="text"
id="node-input-metadata"
Expand Down

0 comments on commit ef00d9a

Please sign in to comment.