UNPKG

node-red-contrib-knx-ultimate

Version:

Control your KNX intallation via Node-Red! A bunch of KNX nodes, with integrated Philips HUE control and ETS group address importer. Easy to use and highly configurable.

271 lines (222 loc) 11.5 kB
<script type="text/javascript" src="resources/node-red-contrib-knx-ultimate/11f26b4500.js"></script> <script type="text/javascript" src="resources/node-red-contrib-knx-ultimate/htmlUtils.js"></script> <script type="text/javascript"> RED.nodes.registerType('knxUltimateHuedevice_software_update', { category: "KNX Ultimate", color: '#C0C7E9', defaults: { //buttonState: {value: true}, server: { type: "knxUltimate-config", required: false }, serverHue: { type: "hue-config", required: true }, name: { value: "" }, namedevice_software_update: { value: "" }, GAdevice_software_update: { value: "" }, dptdevice_software_update: { value: "" }, readStatusAtStartup: { value: "yes" }, hueDevice: { value: "" } }, inputs: 0, outputs: 1, icon: "node-hue-icon.svg", label: function () { return (this.name || "Hue Software Update"); }, paletteLabel: "Hue Software Update", // button: { // enabled: function() { // // return whether or not the button is enabled, based on the current // // configuration of the node // return !this.changed // }, // visible: function() { // // return whether or not the button is visible, based on the current // // configuration of the node // return this.hasButton // }, // //toggle: "buttonState", // onclick: function() {} // }, oneditprepare: function () { // Go to the help panel try { RED.sidebar.show("help"); } catch (error) { } var node = this; var oNodeServer = RED.nodes.node($("#node-input-server").val()); // Store the config-node var oNodeServerHue = RED.nodes.node($("#node-input-serverHue").val()); // Store the config-node // 19/02/2020 Used to get the server sooner als deploy. $("#node-input-server").change(function () { try { oNodeServer = RED.nodes.node($(this).val()); } catch (error) { } }); // 19/02/2020 Used to get the server sooner als deploy. $("#node-input-serverHue").change(function () { try { oNodeServerHue = RED.nodes.node($(this).val()); } catch (error) { } }); // DPT // ######################## $.getJSON('knxUltimateDpts?serverId=' + $("#node-input-server").val(), (data) => { data.forEach(dpt => { if (dpt.value.startsWith("1.")) { $("#node-input-dptdevice_software_update").append($("<option></option>") .attr("value", dpt.value) .text(dpt.text)) } }); $("#node-input-dptdevice_software_update").val(this.dptdevice_software_update) }) // Autocomplete suggestion with ETS csv File $("#node-input-GAdevice_software_update").autocomplete({ minLength: 0, source: function (request, response) { //$.getJSON("csv", request, function( data, status, xhr ) { $.getJSON("knxUltimatecsv?nodeID=" + oNodeServer.id, (data) => { response($.map(data, function (value, key) { var sSearch = (value.ga + " (" + value.devicename + ") DPT" + value.dpt); if (htmlUtilsfullCSVSearch(sSearch, request.term + " 1.")) { return { label: value.ga + " # " + value.devicename + " # " + value.dpt, // Label for Display value: value.ga // Value } } else { return null; } })); }); }, select: function (event, ui) { // Sets Datapoint and device name automatically var sDevName = ui.item.label.split("#")[1].trim(); try { sDevName = sDevName.substr(sDevName.indexOf(")") + 1).trim(); } catch (error) { } $('#node-input-namedevice_software_update').val(sDevName); var optVal = $("#node-input-dptdevice_software_update option:contains('" + ui.item.label.split("#")[2].trim() + "')").attr('value'); // Select the option value $("#node-input-dptdevice_software_update").val(optVal); } }).focus(function () { $(this).autocomplete('search', $(this).val() + 'exactmatch'); }); // ######################## // Autocomplete suggestion with HUE $("#node-input-name").autocomplete({ minLength: 0, source: function (request, response) { $.getJSON("KNXUltimateGetResourcesHUE?rtype=device_software_update&serverId=" + oNodeServerHue.id, (data) => { response($.map(data.devices, function (value, key) { //alert(JSON.stringify(value) + " "+ key) var sSearch = (value.name); if (htmlUtilsfullCSVSearch(sSearch, request.term)) { return { hueDevice: value.id, // Label for Display value: value.name // Value } } else { return null; } })); }); }, select: function (event, ui) { // Sets the fields $('#node-input-hueDevice').val(ui.item.hueDevice); } }).focus(function () { $(this).autocomplete('search', $(this).val() + 'exactmatch'); }); // ######################## }, oneditsave: function () { // Return to the info tab try { RED.sidebar.show("info"); } catch (error) { } }, oneditcancel: function () { // Return to the info tab try { RED.sidebar.show("info"); } catch (error) { } } }) </script> <script type="text/html" data-template-name="knxUltimateHuedevice_software_update"> <div class="form-row"> <b>HUE Device Software Update node</b>&nbsp&nbsp<span style="color:red" &nbsp &nbsp<i class="fa fa-youtube"></i></span>&nbsp<a target="_blank" href="https://youtu.be/jjEUI1J8bkA"><u>Youtube sample</u></a> <br /> <br /> <p align="center"> <i class="fa-solid fa-tower-broadcast fa-beat fa-4x"></i> </p> <br /> <label for="node-input-server" > <img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAKnRFWHRDcmVhdGlvbiBUaW1lAEZyIDYgQXVnIDIwMTAgMjE6NTI6MTkgKzAxMDD84aS8AAAAB3RJTUUH3gYYCicNV+4WIQAAAAlwSFlzAAALEgAACxIB0t1+/AAAAARnQU1BAACxjwv8YQUAAACUSURBVHjaY2CgFZg5c+Z/ZEyWAZ8+f/6/ZsWs/xoamqMGkGrA6Wla/1+fVARjEBuGsSoGmY4eZSCNL59d/g8DIDbIAHR14OgFGQByKjIGKX5+6/T///8gGMQGiV1+/B0Fg70GIkD+RMYgxf/O5/7//2MSmAZhkBi6OrgB6Bg5DGB4ajr3f2xqsYYLSDE2THJUDg0AAAqyDVd4tp4YAAAAAElFTkSuQmCC"></img> KNX GW </label> <input type="text" id="node-input-server" /> </div> <div class="form-row"> <label for="node-input-serverHue"> <img src="data:image/png;base64, iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAERlWElmTU0AKgAAAAgAAYdpAAQAAAABAAAAGgAAAAAAA6ABAAMAAAABAAEAAKACAAQAAAABAAAAEKADAAQAAAABAAAAEAAAAAA0VXHyAAABFUlEQVQ4EZWSsWoCQRCG1yiENEFEi6QSkjqWWoqFoBYJ+Br6JHkMn8Iibd4ihQpaJIhWNkry/ZtdGZY78Qa+m39nZ+dm9s4550awglNBluS/gVtAX6KgDclf68w2OThgfR9iT/jnoEv4TtByDThWTCDKW4SSZTf/zj9/eZbN+izTDuKGimu0vPF8B/YN8aC8LmcOj/AAn9CFTEs70Js/oGqy79C69bqJ5XbQI2kGO5N8QL9D08S8zBtBF5ZaVsznpCMoqJnVdjTpb1Db0fwIWmQV6BLXzFOYgA6/gDVfQN9bBWp2J2hdWDPoBV5FrKnAJutHikk/CHHR8i7x4iG7qQ720IYvu3GFbpHjx3pFrOFYkA354z/5bkK826phyAAAAABJRU5ErkJggg=="/> HUE Bridge </label> <input type="text" id="node-input-serverHue" /> </div> <br/> <p> <b>Philips HUE</b> </p> <div class="form-row"> <label for="node-input-hueDevice" > <i class="fa fa-play-circle"></i>&nbspHue Device</label> <input type="text" id="node-input-name" placeholder="Enter your hue device name" /> <input type="hidden" id="node-input-hueDevice" /> </div> <br/> <p> <b>KNX</b> </p> <div class="form-row"> <label for="node-input-namedevice_software_update" style="width:100px;"><i class="fa fa-play-circle-o"></i> Status</span></label> <label for="node-input-GAdevice_software_update" style="width:20px;">GA</label> <input type="text" id="node-input-GAdevice_software_update" placeholder="Ex: 1/1/1" style="width:70px;margin-left: 5px; text-align: left;"> <label for="node-input-dptdevice_software_update" style="width:40px; margin-left: 0px; text-align: right;">DPT</label> <select id="node-input-dptdevice_software_update" style="width:140px;"></select> <label for="node-input-namedevice_software_update" style="width:50px; margin-left: 0px; text-align: right;">Name</label> <input type="text" id="node-input-namedevice_software_update" style="width:200px;margin-left: 5px; text-align: left;"> </div> <div class="form-row"> <label style="width:180px" for="node-input-readStatusAtStartup"><i class="fa fa-play-circle"></i> Read status at startup</label> <select id="node-input-readStatusAtStartup"> <option value="no">No</option> <option value="yes">Yes, and emit KNX telegrams.</option> </select> </div> <br/> <br/> <br/> </script> <script type="text/markdown" data-help-name="knxUltimateHuedevice_software_update"> <p>This node monitors wether the selected device has a software update avaiable.</p> Start typing the name or group address of your KNX device in the GA field, the avaiable devices start showing up while you're typing. **General** |Property|Description| |--|--| | KNX GW | Select the KNX gateway to be used | | HUE Bridge | Select the HUE Bridge to be used | | Hue Device | HUE Device to be monitored for software update. The avaiable devices start showing up while you're typing.| |Property|Description| |--|--| | Status | The software update status KNX group address. The payload of this KNX group address will change to *true* if a device has a software update avaiable or is installing the update, or if the update is ready to be installed, otherwise *false*. | | Read status at startup | Read the status at startup and emit the event to the KNX bus at startup/reconnection. (Default "yes")| ### Outputs 1. Standard output : payload (boolean) : the standard output of the command. : status (string) : the text representing the status. It can be: **no_update, update_pending, ready_to_install, installing**. </script>