@essenius/node-red-openhab4
Version:
OpenHAB 4 integration nodes for Node-RED
117 lines (104 loc) • 5.83 kB
HTML
<!--
Copyright 2025 Rik Essenius
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is
distributed on an "AS IS" BASIS WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and limitations under the License.
-->
<script type="text/x-red" data-template-name="openhab4-controller">
<div class="form-row">
<label for="node-config-input-name"><i class="fa fa-tag"></i> Name</label>
<input type="text" id="node-config-input-name" placeholder="Name">
</div>
<div class="form-row">
<label for="node-config-input-protocol"><i class="fa fa-unlock-alt"></i> Protocol</label>
<select id="node-config-input-protocol" name="node-config-input-protocol">
<option value="http">http</option>
<option value="https">https</option>
</select>
</div>
<div class="form-row" style="display: flex; align-items: center; flex-wrap: nowrap;">
<label for="node-config-input-allowSelfSigned" style="margin: 0; white-space: nowrap;"><i class="fa fa-certificate"></i> Certificates</label>
<div style="margin-left: 1em; display: flex; align-items: center; white-space: nowrap;">
<input type="checkbox" id="node-config-input-allowSelfSigned" style="margin-right: 0.5em;">
<span>Allow self signed</span>
</div>
</div>
<div class="form-row">
<label for="node-config-input-host"><i class="fa fa-globe"></i> Host</label>
<input type="text" id="node-config-input-host">
</div>
<div class="form-row">
<label for="node-config-input-port"><i class="fa fa-plug"></i> Port</label>
<input type="number" id="node-config-input-port">
</div>
<div class="form-row">
<label for="node-config-input-path"><i class="fa fa-random"></i> Base Path</label>
<input type="text" id="node-config-input-path">
</div>
<div class="form-row">
<label for="node-config-input-username"><i class="fa fa-user"></i> User name</label>
<input type="text" id="node-config-input-username">
</div>
<div class="form-row">
<label for="node-config-input-password"><i class="fa fa-user-secret"></i> Password</label>
<input type="password" id="node-config-input-password">
</div>
</script>
<script type="text/x-red" data-help-name="openhab4-controller">
<p>Configuration node for communication with an openHAB4 controller.</p>
<h3>Configuration</h3>
<dl class="message-properties">
<dt>Name <span class="property-type">string</span></dt>
<dd>Name for the configuration node (mandatory - referenced by other nodes)</dd>
<dt>Protocol <span class="property-type">string</span></dt>
<dd>Connection protocol: <code>http</code> or <code>https</code></dd>
<dt>Allow self-signed certificates <span class="property-type">boolean</span></dt>
<dd>Switch off certificate checking to support self-signed certificates for HTTPS connections (default: <code>false</code>)</dd>
<dt>Host <span class="property-type">string</span></dt>
<dd>The hostname or IP address of the openHAB server (default: <code>localhost</code>)</dd>
<dt>Port <span class="property-type">number</span></dt>
<dd>The port number for the openHAB REST API (default: <code>8080</code>)</dd>
<dt>Base Path <span class="property-type">string</span></dt>
<dd>Additional base path if openHAB is served from a subdirectory (optional)</dd>
<dt>User name <span class="property-type">string</span></dt>
<dd>Username for HTTP Basic Authentication (optional)</dd>
<dt>Password <span class="property-type">string</span></dt>
<dd>Password for HTTP Basic Authentication (optional)</dd>
</dl>
<h3>Details</h3>
<p>This configuration node defines the connection parameters for an openHAB4 server.
It is referenced by all other openHAB4 nodes in your flows.</p>
<p><strong>Connection URLs:</strong> The node constructs URLs in the format:</p>
<code>{protocol}://{host}:{port}{/path}/rest/</code>
<p><strong>Authentication:</strong> If username is provided,
HTTP Basic Authentication will be used for all requests to the openHAB server.</p>
<p><strong>Event Stream:</strong> The controller also manages the Server-Sent Events (SSE)
connection for real-time event monitoring used by events and health nodes.</p>
<p><strong>Multiple Controllers:</strong> You can create multiple controller configurations
to connect to different openHAB instances or use different authentication credentials.</p>
</script>
<script src="openhab4/ui-constants.js"></script>
<script type="text/javascript">
RED.nodes.registerType('openhab4-controller', {
category: 'config',
defaults: {
name: { value: "", required: true },
protocol: { value: "http", required: true },
allowSelfSigned: { value: false },
host: { value: "localhost", required: true },
port: { value: 8080, required: false },
path: { value: "", required: false },
},
credentials: {
username: { type: "text" },
password: { type: "password" }
},
paletteLabel: "openhab4-controller",
label: function () {
return this.name;
}
});
</script>