UNPKG

@runnane/node-red-contrib-easee

Version:

Module for streaming Easee data. Based on node-red-contrib-signalrcore

117 lines (102 loc) 4.66 kB
<!-- 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/javascript"> (function () { RED.nodes.registerType("easee-configuration", { category: 'config', defaults: { username: { value: "", required: true }, debugLogging: { value: false, required: false }, debugToNodeWarn: { value: false, required: false } }, credentials: { password: { type: "password", required: true } }, inputs: 0, outputs: 0, label: function () { // For configuration nodes, we can't access credentials directly in the label function // Instead, we'll use the username from the node properties if available if (this.username) { return this.username; } // Fallback to a generic label return 'easee API configuration'; }, oneditprepare: function() { // Load the current values into the form $("#node-config-input-username").val(this.username || ''); $("#node-config-input-debug-logging").prop('checked', this.debugLogging); $("#node-config-input-debug-to-node-warn").prop('checked', this.debugToNodeWarn); }, oneditsave: function() { // Save the username as a regular property so it can be used in the label this.username = $("#node-config-input-username").val(); this.debugLogging = $("#node-config-input-debug-logging").prop('checked'); this.debugToNodeWarn = $("#node-config-input-debug-to-node-warn").prop('checked'); }, validate: function() { const username = $("#node-config-input-username").val()?.trim(); const password = $("#node-config-input-password").val()?.trim(); if (!username || username.length === 0) { return false; } if (!password || password.length === 0) { return false; } return true; } }); })(); </script> <script type="text/x-red" data-template-name="easee-configuration"> <div class="form-row"> <label for="node-config-input-username"><i class="fa fa-user"></i> Username</label> <input id="node-config-input-username" type="text" placeholder="Enter your Easee username" required /> <div class="form-tips"> <b>Required:</b> Your Easee account username/email </div> </div> <div class="form-row"> <label for="node-config-input-password"><i class="fa fa-lock"></i> Password</label> <input id="node-config-input-password" type="password" placeholder="Enter your Easee password" required /> <div class="form-tips"> <b>Required:</b> Your Easee account password </div> </div> <hr style="margin: 20px 0; border: none; border-top: 1px solid #ccc;" /> <div class="form-row"> <label style="width: auto; margin-right: 10px;"> <input type="checkbox" id="node-config-input-debug-logging" style="width: auto; margin-right: 5px;" /> <i class="fa fa-bug"></i> Enable debug logging </label> <div class="form-tips" style="margin-left: 20px;"> Enable detailed debug messages for troubleshooting authentication and API calls </div> </div> <div class="form-row"> <label style="width: auto; margin-right: 10px;"> <input type="checkbox" id="node-config-input-debug-to-node-warn" style="width: auto; margin-right: 5px;" /> <i class="fa fa-exclamation-triangle"></i> Output debug to node warnings </label> <div class="form-tips" style="margin-left: 20px;"> Also send debug messages to Node-RED's warn() output (visible in debug sidebar) </div> </div> <div class="form-tips"> <p><strong>Note:</strong> Both username and password are required for the Easee API authentication. The configuration will not be valid without both credentials.</p> <p><strong>Debug Logging:</strong> When enabled, detailed messages about authentication, token management, and API calls will be logged to help with troubleshooting.</p> </div> </script> <script type="text/x-red" data-help-name="easee-configuration"> <p>Configuration for use when talking to the Easee API</p> </script>