UNPKG

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

Version:
182 lines (161 loc) 7.6 kB
<script src="/nodered/utils.js"></script> <script type="text/javascript"> RED.nodes.registerType('input', { category: 'Strato Automation', color: '#f3b567', defaults: { ocn_server_node: { type: "ocn-server", required: true, label: "OCN Server" }, device_instance: { value: "", required: true, label: "Device Instance", validate: RED.validators.number() }, object_id: { value: "", required: true, label: "Object ID" }, topic: { value: "default", required: true, label: "Topic" }, source: { value: "mqtt", required: true, label: "Source" } }, inputs: 0, outputs: 2, icon: "input.svg", paletteLabel: function () { return "Input"; }, label: function () { return this.device_instance + " " + this.object_id; }, outputLabels: function (index) { if (index == 0) return this.topic; else return "status" }, oneditprepare: function () { var node = this; if (node.device_instance === "") $("#node-input-device_instance").val(localStorage.getItem('default_device_instance') || ""); if (node.object_id === "") $("#node-input-object_id").val(localStorage.getItem('default_in_obj_id') || ""); $("#node-input-topic").typedInput({ types: [ { value: "", options: topics() } ] }) }, oneditsave: function () { var node = this; if (node.device_instance !== "") localStorage.setItem('default_device_instance', node.device_instance); if (node.object_id !== "") localStorage.setItem('default_in_obj_id', node.object_id); } }); </script> <script type="text/html" data-template-name="input"> <!-- Connection Settings --> <div class="form-tips" style="margin-bottom: 20px;"> <b>Connection Settings</b> </div> <div class="form-row"> <label for="node-input-ocn_server_node"><i class="fa fa-server"></i> OCN Server</label> <input type="ocn-server" id="node-input-ocn_server_node"> </div> <!-- Device Settings --> <div class="form-tips" style="margin: 20px 0;"> <b>Device Settings</b> </div> <div style="padding-left: 10px; border-left: 3px solid #ddd;"> <div class="form-row"> <label for="node-input-device_instance"><i class="fa fa-microchip"></i> Device Instance</label> <input type="text" id="node-input-device_instance" placeholder="e.g., 1234"> </div> <div class="form-row"> <label for="node-input-object_id"><i class="fa fa-cube"></i> Object ID</label> <input type="text" id="node-input-object_id" placeholder="e.g., AV-1"> </div> </div> <!-- Communication Settings --> <div class="form-tips" style="margin: 20px 0;"> <b>Communication Settings</b> </div> <div style="padding-left: 10px; border-left: 3px solid #ddd;"> <div class="form-row"> <label for="node-input-source"><i class="fa fa-database"></i> Data Source</label> <select type="text" id="node-input-source" style="width: 70%;"> <option value="mqtt">MQTT (Recommended)</option> <option value="api">API (HTTPS)</option> </select> </div> <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: Device instance and object ID settings are saved as defaults for future nodes.</p> </div> </script> <script type="text/html" data-help-name="input"> <p>A node that reads values from BACnet objects and monitors their status flags.</p> <h3>Outputs</h3> <ol class="node-ports"> <li>Present Value <dl class="message-properties"> <dt>payload <span class="property-type">number</span></dt> <dd>The current value of the BACnet object</dd> <dt>topic <span class="property-type">string</span></dt> <dd>The configured topic name</dd> <dt>object_id <span class="property-type">string</span></dt> <dd>The BACnet object identifier (e.g., "AV-1")</dd> <dt>device_instance <span class="property-type">number</span></dt> <dd>The BACnet device instance number</dd> <dt>object_type <span class="property-type">string</span></dt> <dd>The BACnet object type (e.g., "AV")</dd> <dt>object_instance <span class="property-type">number</span></dt> <dd>The BACnet object instance number</dd> </dl> </li> <li>Status Flags <dl class="message-properties"> <dt>payload <span class="property-type">object</span></dt> <dd> BACnet status flags: <ul> <li><code>inAlarm</code> - Object is in alarm state</li> <li><code>fault</code> - Object has detected a fault</li> <li><code>overridden</code> - Object has been overridden</li> <li><code>outOfService</code> - Object is out of service</li> </ul> </dd> <dt>topic <span class="property-type">string</span></dt> <dd>Always set to "statusFlags"</dd> </dl> </li> </ol> <h3>Configuration</h3> <dl class="message-properties"> <dt>OCN Server <span class="property-type">config</span></dt> <dd>The OCN Server configuration node to use for communication</dd> <dt>Device Instance <span class="property-type">number</span></dt> <dd>The instance number of the BACnet device</dd> <dt>Object ID <span class="property-type">string</span></dt> <dd>The object identifier in format "type-instance" (e.g., "AV-1")</dd> <dt>Data Source <span class="property-type">string</span></dt> <dd> <ul> <li><code>MQTT</code> - Subscribe to real-time updates via MQTT (recommended)</li> <li><code>API</code> - Poll for updates via HTTP API every second</li> </ul> </dd> <dt>Topic <span class="property-type">string</span></dt> <dd>A topic name to identify this input's messages in the flow</dd> </dl> <h3>Status</h3> <dl class="message-properties"> <dt>Green dot</dt> <dd>Connected and receiving values</dd> <dt>Red ring</dt> <dd>Disconnected or error condition</dd> </dl> <h3>Details</h3> <p>This node monitors BACnet objects and provides both their present value and status flags. It can use either MQTT for real-time updates (recommended) or HTTP API polling.</p> <p>The node automatically saves the device instance and object ID as defaults when configured, making it easier to create multiple nodes for the same device.</p> </script>