hdl-automation-nodered
Version:
Provides control and feedback of the HDL Automation bus for Node Red https://www.hdlautomation.com/
109 lines (104 loc) • 3.97 kB
HTML
<!-- Information Panel -->
<script id="hdl-info-panel" type="text/x-red" data-help-name="hdl-bus">
<h1>HDL Bus</h1>
<h2>The HDL bus node provides direct connection to the HDL bus.</h2>
<h2>Settings</h2>
<p><strong>Name</strong>: The name of the node that will appear in the flow.</p>
<p><strong>Output Mode</strong>: The amount of information that will be outputted. </p>
<p><strong>Network</strong>: The HDL network device that is providing connection to the bus via a network connection.</p>
<h2>Sending a message to the bus</h2>
<p>When sending there are two ways to send the information, first send it using the supported commands, or send a raw packet.<p>
<xmp>
1. Supported method (Scene control as an example)
var msg = {
“payload”: {
“operate”: “sceneControl”,
“mode”: “set”,
“direction”: “request”,
"subnetId": 1,
"deviceId": 1,
“data”: {
“areaNumber”: 1,
“sceneNumber”: 1
}
}
}
return msg;
The above message will set the scene of the device is was sent to scene 1 in area 1.
2. Sending a raw packet (Advanced)
var msg = {
“payload”: {
“opCode”: 0x0002,
"subnetId": 1,
"deviceId": 1,
“contents”: Buffer.from([1, 1])
}
}
return msg;
The above message will do the same, set the scene of the device is was sent to scene 1 in area 1.
</xmp>
<h2>Receiving a message from the bus</h2>
<p>When receiving a message from the bus it will be outputted in the following format<p>
<xmp>
msg: {
payload: {
opCode: 0x002,
sender: {
deviceType: "HDL-MR1220" OR "0x000B",
subnetId: 1,
deviceId: 1,
wasSentToThisDevice: true
}
operate: “sceneControl”,
mode: “set”,
direction: “request”,
data: {
areaNumber: 1,
sceneNumber: 1
},
contents: [0x01, 0x01]
}
}
</xmp>
<p>However if the command is not supported the operate, mode, direction, and data fields will be null<p>
</script>
<!-- Settings Panel -->
<script type="text/x-red" data-template-name="hdl-bus">
<div class="form-row">
<label for="node--input-name"><i class="icon-tag"></i> Name</label>
<input type="text" id="node--input-name" placeholder="Name">
</div>
<div class="form-row">
<label for="node-input-outputMode"><i class="icon-tag"></i> Output Mode:</label>
<select id="node-input-outputMode">
<option value=""></option>
<option value="answerback">Only output answer back</option>
<option value="local">Output all messages sent to this PC</option>
<option value="all">Output all messages</option>
</select>
</div>
<div class="form-row">
<label for="node-input-network"><i class="icon-bookmark"></i> Network</label>
<input type="text" id="node-input-network">
</div>
</script>
<!-- Register -->
<script type="text/javascript">
RED.nodes.registerType('hdl-bus', {
category: 'HDL',
color: '#25FFCA',
defaults: {
name: {value: ""},
outputMode: {value: "answerBack", required: true},
network: {value: "", type: "hdl-network"}
},
inputs: 1,
outputs: 1,
align: "right",
icon: "serial.png",
paletteLabel: "Bus",
label: function() {
return this.name||"HDL Bus";
}
});
</script>