UNPKG

@strato-automation/node-red-contrib-strato-automation

Version:
133 lines (119 loc) 4.82 kB
<script type="text/javascript"> RED.nodes.registerType('unit-converter', { category: 'Strato Automation', color: '#f3b567', defaults: { name: { value: "", label: "name" }, option: { value: "cToF", required: true, label: "option" }, }, inputs: 1, outputs: 1, icon: "font-awesome/fa-retweet", paletteLabel: function() { return "Unit Converter"; }, label: function () { return (this.option || "Unit Converter") }, labelStyle: function () { return this.name ? "node_label_italic" : ""; }, outputLabels: function (index) { return this.topic; }, inputLabels: function (index) { return "Input"; }, oneditprepare: function () { var node = this; $("#node-input-option").typedInput({ types: [ { value: "", options: conversionOptions() } ] }) } }); </script> <script type="text/html" data-template-name="unit-converter"> <!-- 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 converter"> </div> <div class="form-row"> <label for="node-input-option"><i class="fa fa-exchange"></i> Conversion</label> <input type="text" id="node-input-option"> </div> <div class="form-tips" style="margin-top: 20px;"> <p><i class="fa fa-info-circle"></i> Tip: The node will automatically format output values to 2 decimal places.</p> </div> </script> <script type="text/html" data-help-name="unit-converter"> <p>A node that converts values between different units of measurement.</p> <h3>Inputs</h3> <dl class="message-properties"> <dt>payload <span class="property-type">number</span></dt> <dd>The value to convert</dd> </dl> <h3>Outputs</h3> <dl class="message-properties"> <dt>payload <span class="property-type">number</span></dt> <dd>The converted value</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>Conversion <span class="property-type">string</span></dt> <dd> Available conversion options: <h4>Temperature</h4> <ul> <li><code>cToF</code> - Celsius to Fahrenheit</li> <li><code>fToC</code> - Fahrenheit to Celsius</li> </ul> <h4>Pressure</h4> <ul> <li><code>psiToInHg</code> - PSI to inches of Mercury</li> <li><code>inHgToPsi</code> - Inches of Mercury to PSI</li> <li><code>psiToKPa</code> - PSI to Kilopascals</li> <li><code>kPaToPsi</code> - Kilopascals to PSI</li> </ul> <h4>Energy</h4> <ul> <li><code>btulbToKjkg</code> - BTU/lb to kJ/kg</li> <li><code>kjkgToBtulb</code> - kJ/kg to BTU/lb</li> </ul> </dd> </dl> <h3>Conversion Formulas</h3> <ul> <li>°F = °C × (9/5) + 32</li> <li>°C = (°F - 32) × (5/9)</li> <li>inHg = PSI ÷ 0.491154</li> <li>PSI = inHg × 0.491154</li> <li>kPa = PSI × 6.894757</li> <li>BTU/lb = kJ/kg ÷ 2.326</li> </ul> <h3>Status</h3> <dl class="message-properties"> <dt>Grey dot</dt> <dd>Shows the input and output values (to 2 decimal places)</dd> </dl> <h3>Example Uses</h3> <ul> <li>Converting temperature readings between Celsius and Fahrenheit</li> <li>Standardizing pressure measurements across different systems</li> <li>Converting energy units for HVAC calculations</li> <li>Adapting sensor readings to different unit requirements</li> </ul> <h3>Details</h3> <p>This node performs precise unit conversions using standard conversion factors. All calculations maintain accuracy to multiple decimal places, though the status display rounds to 2 decimal places for readability.</p> <p>The node preserves all other message properties, only modifying the <code>payload</code> value. Each conversion is performed using carefully selected conversion factors to ensure accuracy in technical applications.</p> </script>