@strato-automation/node-red-contrib-strato-automation
Version:
Strato Automation Official Node Red Library
140 lines (122 loc) • 5.02 kB
HTML
<script type="text/javascript">
RED.nodes.registerType('const', {
category: 'Strato Automation',
color: '#f3b567',
defaults: {
name: { value: "", label: "name" },
value: { value: "", required: true, label: "value" },
topic: { value: "default", required: true, label: "topic" },
},
inputs: 1,
outputs: 1,
icon: "hash.svg",
paletteLabel: function() {
return "Constant";
},
label: function () {
return (this.name || "Const") + ": " + this.value;
},
labelStyle: function () {
return this.name ? "node_label_italic" : "";
},
outputLabels: function (index) {
return this.topic;
},
oneditprepare: function () {
var node = this;
$("#node-input-topic").typedInput({
types: [
{
value: "",
options: topics()
}
]
})
$("#node-input-value").typedInput({
type: "num",
typeField: "#node-input-value-type"
})
}
});
</script>
<script type="text/html" data-template-name="const">
<!-- Basic Settings -->
<div class="form-tips" style="margin-bottom: 20px;">
<b>Basic Settings</b>
</div>
<div class="form-row">
<label for="node-input-name"><i class="fa fa-bookmark"></i> Name</label>
<input type="text" id="node-input-name" placeholder="Optional name for this constant">
</div>
<!-- Value Settings -->
<div class="form-tips" style="margin: 20px 0;">
<b>Constant Value</b>
</div>
<div style="padding-left: 10px; border-left: 3px solid #ddd;">
<div class="form-row">
<label for="node-input-value"><i class="fa fa-hashtag"></i> Value</label>
<input type="num" id="node-input-value" placeholder="Numeric constant value">
</div>
</div>
<!-- Output Settings -->
<div class="form-tips" style="margin: 20px 0;">
<b>Output Settings</b>
</div>
<div style="padding-left: 10px; border-left: 3px solid #ddd;">
<div class="form-row">
<label for="node-input-topic"><i class="fa fa-tags"></i> Topic</label>
<input type="text" id="node-input-topic">
</div>
</div>
<div class="form-tips" style="margin-top: 20px;">
<p><i class="fa fa-info-circle"></i> Tip: The constant value is automatically injected once at startup and on every input message.</p>
</div>
</script>
<script type="text/html" data-help-name="const">
<p>A node that outputs a constant numeric value, both automatically at startup and when triggered by an input message.</p>
<h3>Inputs</h3>
<dl class="message-properties">
<dt>payload <span class="property-type">any</span></dt>
<dd>Any input triggers the constant value output (payload is ignored)</dd>
<dt>topic <span class="property-type">string</span></dt>
<dd>Input topic is ignored, output uses configured topic</dd>
</dl>
<h3>Outputs</h3>
<dl class="message-properties">
<dt>payload <span class="property-type">number</span></dt>
<dd>The configured constant value</dd>
<dt>topic <span class="property-type">string</span></dt>
<dd>The configured topic name</dd>
<dt>__srcid <span class="property-type">string</span></dt>
<dd>The node's identifier</dd>
</dl>
<h3>Configuration</h3>
<dl class="message-properties">
<dt>Name <span class="property-type">string</span></dt>
<dd>Optional name to identify the node in the flow</dd>
<dt>Value <span class="property-type">number</span></dt>
<dd>The constant numeric value to output</dd>
<dt>Topic <span class="property-type">string</span></dt>
<dd>Topic identifier for the output messages</dd>
</dl>
<h3>Status</h3>
<dl class="message-properties">
<dt>Grey dot</dt>
<dd>Shows the configured topic name</dd>
</dl>
<h3>Details</h3>
<p>This node provides a way to inject a constant numeric value into a flow. It operates in two modes:</p>
<h4>Operation Modes</h4>
<ul>
<li><b>Startup Injection:</b> The constant value is automatically sent once after a 3-second delay when the flow starts</li>
<li><b>Triggered Injection:</b> The constant value is sent whenever the node receives an input message</li>
</ul>
<h4>Use Cases</h4>
<ul>
<li>Providing fixed setpoints or thresholds</li>
<li>Initializing variables in a flow</li>
<li>Creating reference values</li>
<li>Setting default parameters</li>
</ul>
<p>The node always converts the configured value to a number before sending it, ensuring consistent output type.</p>
</script>