node-red-contrib-self-healing
Version:
SHEN: Self-healing extensions for Node-RED.
108 lines (100 loc) • 3.43 kB
HTML
<script type="text/javascript">
RED.nodes.registerType("redundancy-manager", {
category: "SHEN",
defaults: {
name: { value: "" },
timeout: {
value: "15",
required: true,
validate: RED.validators.number(),
},
pingInterval: {
value: "5",
required: true,
validate: RED.validators.number(),
},
},
icon: "status.png",
color: "#74b9ff",
inputs: 1,
outputs: 3,
align: "left",
inputLabels: "mqtt",
outputLabels: ["master(bool)", "ips(array)", "ping"],
label: function () {
return this.name || "redundancy-manager";
},
});
</script>
<script type="text/html" data-template-name="redundancy-manager">
<div class="form-row">
<label for="node-input-name"
><i class="fa fa-tag"></i>
<span data-i18n="node-red:common.label.name"></span
></label>
<input
type="text"
id="node-input-name"
data-i18n="[placeholder]node-red:common.label.name"
/>
</div>
<div class="form-row">
<label for="node-input-pingInterval"
><i class="fa fa-tag"></i> Ping interval (s)</label
>
<input type="number" id="node-input-pingInterval" placeholder="10" />
</div>
<div class="form-row">
<label for="node-input-timeout"><i class="fa fa-tag"></i>Timeout (s)</label>
<input type="number" id="node-input-timeout" placeholder="10" />
</div>
</script>
<script type="text/html" data-help-name="redundancy-manager">
<p>
A node that manages redundant instances of Node-RED (setting a master
instance). Works only on the local network (uses mqtt communication).
</p>
<h3>Details</h3>
<p>
This node can be placed in a given flow, connected to two mqtt nodes: one
for input and another one for output. The mqtt nodes will be used to elect a
master instance of the several redundancy nodes (properly connected to two
mqtt nodes in the same way). For this, the bully election algorithm will be
used, prioritizing the IP address with the largest last octet. Each node
will send as output an object with the property "master" set as true or
false, in order to enable or disable certain flows, depending on whether it
was elected as master or not.
</p>
<h3>Setup</h3>
<p>
In order for the redundancy node to work properly, it must connect to two
mqtt nodes: one for the input ("mqtt"), an mqtt-in, and another for the
third output ("ping"), an mqtt-out.
</p>
<h3>Properties</h3>
<dl class="message-properties">
<dt>name<span class="property-type">string</span></dt>
<dd>name of node to be displayed in editor</dd>
<dt>pingInterval<span class="property-type">integer</span></dt>
<dd>ping interval to the mqtt-out, in seconds</dd>
<dt>timeout<span class="property-type">integer</span></dt>
<dd>connection timeout, in seconds</dd>
</dl>
<h3>Inputs</h3>
<dl class="message-properties">
<p>An mqtt-in node for a given topic</p>
</dl>
<h3>Outputs</h3>
<dl class="message-properties">
<p>Equal to the last message sent as input</p>
<dt>master(bool)</dt>
<dd>if the redundancy-manager node is the master instance or not</dd>
<dt>ips(array)</dt>
<dd>
an array containing the ip addresses of other deviced with
redundancy-manager nodes
</dd>
<dt>ping</dt>
<dd>ping for the output mqtt-out node</dd>
</dl>
</script>