hdl-automation-nodered
Version:
Provides control and feedback of the HDL Automation bus for Node Red https://www.hdlautomation.com/
118 lines (112 loc) • 4.54 kB
HTML
<!-- Settings Panel -->
<script type="text/x-red" data-template-name="hdl-device">
<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-subnetId"><i class="icon-bookmark"></i> Device Subnet</label>
<input type="text" id="node-input-subnetId">
</div>
<div class="form-row">
<label for="node-input-deviceId"><i class="icon-bookmark"></i> Device ID</label>
<input type="text" id="node-input-deviceId">
</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>
<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 from the device to this PC</option>
<option value="all">Output all messages sent from the device</option>
</select>
</div>
</script>
<!-- Register -->
<script type="text/javascript">
RED.nodes.registerType('hdl-device', {
category: 'HDL',
color: '#25A6FF',
defaults: {
name: {value: ""},
subnetId: {required: true, validate: RED.validators.number()},
deviceId: {required: true, validate: RED.validators.number()},
network: {value: "", type: "hdl-network"},
outputMode: {value: "answerBack", required: true}
},
inputs: 1,
outputs: 1,
align: "right",
icon: "db.png",
paletteLabel: "Device",
label: function() {
return this.name||"HDL Device";
}
});
</script>
<!-- Information Panel -->
<script type="text/x-red" data-help-name="hdl-device">
<h1>HDL Device</h1>
<h2>The HDL Device node provides connection to a device on the HDL bus. This node acts like the HDL bus node, however it will only accept connections with the specific device.</h2>
<h2>Settings</h2>
<p><strong>Name</strong>: The name of the node that will appear in the flow.</p>
<p><strong>Subnet ID</strong>: The subnet id of the device on the HDL network</p>
<p><strong>Device ID</strong>: The device id of the device on the HDL network</p>
<p><strong>Network</strong>: The HDL network device that is providing connection to the bus via a network connection.</p>
<p><strong>Output Mode</strong>: The amount of information that will be outputted. </p>
<h2>Sending a message to the device</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”,
“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,
“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: 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>