UNPKG

node-red-smithtek-hysteresis

Version:

Adds hysteresis function to node-red

161 lines (155 loc) 6.79 kB
<script type="text/javascript"> RED.nodes.registerType('smithtek_node_red_hysteresis', { category: 'Smithtek hysteresis', paletteLabel: 'Smithtek hysteresis', color: '#B9B6B8', defaults: { name: { value: '', }, ThresholdType: { value: 'fixed', }, //ThresholdRising: {value: "", required: true, validate: RED.validators.number()}, //ThresholdFalling: {value: "", required: true, validate: RED.validators.number()}, ThresholdRising: { value: '', }, ThresholdFalling: { value: '', }, TopicThreshold: { value: '', }, TopicCurrent: { value: '', }, //ThresholdDeltaRising: {value: "", validate: RED.validators.number()}, //ThresholdDeltaFalling: {value: "", validate: RED.validators.number()}, ThresholdDeltaRising: { value: '', }, ThresholdDeltaFalling: { value: '', }, InitialMessage: { checked: 'checked', }, OutRisingType: { value: '', }, OutRisingValue: { value: '', }, OutFallingType: { value: '', }, OutFallingValue: { value: '', }, OutTopicType: { value: '', }, OutTopicValue: { value: '', }, }, inputs: 1, outputs: 1, icon: 'smithtek.png', label: function () { return this.name || 'smithtek hysteresis'; }, labelStyle: function () { return this.name ? 'node_label_italic' : ''; }, oneditprepare: function () { $('#node-input-ThresholdType').change(function () { if ($(this).val() === 'fixed') { $('.form-row-ThresholdTypeFixed').show(); $('.form-row-ThresholdTypeDynamic').hide(); } else { $('.form-row-ThresholdTypeFixed').hide(); $('.form-row-ThresholdTypeDynamic').show(); } }); var optionOriginalPayload = { value: 'pay', label: 'Original Message', hasValue: false, }; var optionOriginalTopic = { value: 'top', label: 'Original Topic', hasValue: false, }; $('#node-input-OutRisingValue').typedInput({ default: 'pay', typeField: $('#node-input-OutRisingType'), types: ['str', 'num', 'bool', optionOriginalPayload], }); $('#node-input-OutFallingValue').typedInput({ default: 'pay', typeField: $('#node-input-OutFallingType'), types: ['str', 'num', 'bool', optionOriginalPayload], }); $('#node-input-OutTopicValue').typedInput({ default: 'top', typeField: $('#node-input-OutTopicType'), types: ['str', optionOriginalTopic], }); }, }); </script> <script type="text/x-red" data-template-name="smithtek_node_red_hysteresis"> <div class="form-row"> <label style="width: 140px !important" for="node-input-name"><i class="icon-tag"></i> Name</label> <input type="text" id="node-input-name" placeholder="name" style="width: 280px"> </div> <!-- Payload Options --> <div class="form-row"> <label style="width: 140px !important;"><h5><strong>Output Settings</strong></h5></label> </div> <div class="form-row"> <label style="width: 140px !important;" for="node-input-InitialMessage"> Send initial message</label> <input type="checkbox" id="node-input-InitialMessage" style="margin-left: 0px; vertical-align: middle; width: auto !important;"> </div> <div class="form-row"> <label style="width: 140px !important" for="node-input-OutRisingType"><i class="fa fa-sign-out"></i> Upper Threshold</label> <input type="hidden" id="node-input-OutRisingType"> <input type="text" id="node-input-OutRisingValue" style="width: 280px"> </div> <div class="form-row"> <label style="width: 140px !important" for="node-input-OutFallingType"><i class="fa fa-sign-out"></i> Lower Threshold</label> <input type="hidden" id="node-input-OutFallingType"> <input type="text" id="node-input-OutFallingValue" style="width: 280px"> </div> <div class="form-row"> <label style="width: 140px !important" for="node-input-OutTopicType"><i class="fa fa-sign-out"></i> Topic</label> <input type="hidden" id="node-input-OutTopicType"> <input type="text" id="node-input-OutTopicValue" style="width: 280px"> </div> </script> <script type="text/x-red" data-help-name="smithtek_node_red_hysteresis"> <p>Provides a hysteresis or deadband function.</p> <h3>Details</h3> <p>The Hysteresis node is used in industrial control systems to monitor, react, control hardware when changes in values happen. A classic example is a wastewater pit pumping system. The sewage water reaches a high setpoint the pump is activated. The sewage water falls to a low setpoint the pump is deactivated. Smithtek Hysteresis comes with a setpoint formatter node. This allows the operator to adjust the high and low setpoint remotely using MQTT or any other communications protocol. They simply inject the setpoint values to the formatter and this handles the interaction between the Hysteresis controller node. <p> <h3>Input</h3> <ul> <li>The input values are pre formatted in the threshold formatter nodes. The payload must be a string or number. The string can only be numerical</li> <li>The topic can be passed from the origional message or be manually entered within the node</li> <li> </li> </ul> <h5>Send initial message</h5> <p>When a restart of the device or node red occurs the send innitial message will check the first value recieved, if any are exceeded it will trigger the correct output setpoint payload. </p> <h4>Output</h4> <p><li>The upper and lower or High setpoint / Low setpoint output message can be string,bool or number .</li></p> </script>