node-red-contrib-knx-ultimate 2.1.13 → 2.1.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -6,6 +6,10 @@
6
6
 
7
7
  # CHANGELOG
8
8
 
9
+ <p>
10
+ <b>Version 2.1.14</b> - June 2023<br/>
11
+ - Hue Light node: added day/night behaviour.<br/>
12
+ </p>
9
13
  <p>
10
14
  <b>Version 2.1.13</b> - June 2023<br/>
11
15
  - Hue Light node: fixed inversion in the color temp state.<br/>
@@ -52,6 +52,13 @@
52
52
  GALightColorCycle: { value: "" },
53
53
  dptLightColorCycle: { value: "" },
54
54
 
55
+ colorAtSwitchOnDayTime: { value: '{"red":255, "green":255, "blue":255}' },
56
+ colorAtSwitchOnNightTime: { value: '{"red":23, "green":4, "blue":0}' },
57
+
58
+ nameDaylightSensor: { value: "" },
59
+ GADaylightSensor: { value: "" },
60
+ dptDaylightSensor: { value: "" },
61
+
55
62
  hueDevice: { value: "" }
56
63
  },
57
64
  inputs: 0,
@@ -607,6 +614,53 @@
607
614
  // ########################
608
615
 
609
616
 
617
+ // DPT Day/Time sensor
618
+ // ########################
619
+ $.getJSON('knxUltimateDpts', (data) => {
620
+ data.forEach(dpt => {
621
+ if (dpt.value.startsWith("1.")) {
622
+ $("#node-input-dptDaylightSensor").append($("<option></option>")
623
+ .attr("value", dpt.value)
624
+ .text(dpt.text))
625
+ }
626
+ });
627
+ $("#node-input-dptDaylightSensor").val(this.dptDaylightSensor)
628
+ })
629
+
630
+ // Autocomplete suggestion with ETS csv File
631
+ $("#node-input-GADaylightSensor").autocomplete({
632
+ minLength: 1,
633
+ source: function (request, response) {
634
+ //$.getJSON("csv", request, function( data, status, xhr ) {
635
+ $.getJSON("knxUltimatecsv?nodeID=" + oNodeServer.id, (data) => {
636
+ response($.map(data, function (value, key) {
637
+ var sSearch = (value.ga + " (" + value.devicename + ") DPT" + value.dpt);
638
+ if (fullSearch(sSearch, request.term + " 1.")) {
639
+ return {
640
+ label: value.ga + " # " + value.devicename + " # " + value.dpt, // Label for Display
641
+ value: value.ga // Value
642
+ }
643
+ } else {
644
+ return null;
645
+ }
646
+ }));
647
+ });
648
+ }, select: function (event, ui) {
649
+ // Sets Datapoint and device name automatically
650
+ var sDevName = ui.item.label.split("#")[1].trim();
651
+ try {
652
+ sDevName = sDevName.substr(sDevName.indexOf(")") + 1).trim();
653
+ } catch (error) {
654
+ }
655
+ $('#node-input-nameDaylightSensor').val(sDevName);
656
+ var optVal = $("#node-input-dptDaylightSensor option:contains('" + ui.item.label.split("#")[2].trim() + "')").attr('value');
657
+ // Select the option value
658
+ $("#node-input-dptDaylightSensor").val(optVal);
659
+ }
660
+ });
661
+ // ########################
662
+
663
+
610
664
 
611
665
  // Autocomplete suggestion with HUE Lights
612
666
  $("#node-input-name").autocomplete({
@@ -727,6 +781,33 @@
727
781
  <label for="node-input-nameLightState" style="width:50px; margin-left: 0px; text-align: right;"><span data-i18n="knxUltimateHueLight.node-input-name"></span></label>
728
782
  <input type="text" id="node-input-nameLightState" style="width:200px;margin-left: 5px; text-align: left;">
729
783
  </div>
784
+
785
+ <div class="form-row">
786
+ <label for="node-input-nameDaylightSensor" style="width:100px;"><i class="fa fa-clock-o"></i> Day/Night</label>
787
+
788
+ <label for="node-input-GADaylightSensor" style="width:20px;">GA</label>
789
+ <input type="text" id="node-input-GADaylightSensor" placeholder="Ex: 1/1/1" style="width:70px;margin-left: 5px; text-align: left;">
790
+
791
+ <label for="node-input-dptDaylightSensor" style="width:40px; margin-left: 0px; text-align: right;">DPT</label>
792
+ <select id="node-input-dptDaylightSensor" style="width:140px;"></select>
793
+
794
+ <label for="node-input-nameDaylightSensor" style="width:50px; margin-left: 0px; text-align: right;"><span data-i18n="knxUltimateHueLight.node-input-name"></span></label>
795
+ <input type="text" id="node-input-nameDaylightSensor" style="width:200px;margin-left: 5px; text-align: left;">
796
+ </div>
797
+
798
+ <div class="form-row">
799
+ <label for="node-input-colorAtSwitchOnDayTime" style="width:200px">
800
+ <i class="fa fa-sun-o"></i> Switch on color at Daytime
801
+ </label>
802
+ <input type="text" id="node-input-colorAtSwitchOnDayTime" placeholder='{"red":255, "green":255, "blue":255}' style="width:250px">
803
+ </div>
804
+ <div class="form-row">
805
+ <label for="node-input-colorAtSwitchOnNightTime" style="width:200px">
806
+ <i class="fa fa-moon-o"></i> Switch on color at Nighttime
807
+ </label>
808
+ <input type="text" id="node-input-colorAtSwitchOnNightTime" placeholder='{"red":100, "green":0, "blue":50}' style="width:250px">
809
+ </div>
810
+
730
811
  </p>
731
812
  </div>
732
813
  <div id="tabs-2">
@@ -891,7 +972,9 @@ Start typing in the GA field, the name or group address of your KNX device, the
891
972
  | Brightness Status| Link this to the light's brightness status group address |
892
973
  | Blink| *true* Blink the light, *false* Stop blinking. Blinks the light on and off. Useful for signalling. Works with all HUE lights. |
893
974
  | Color Cycle| *true* start cycle, *false* Stop cycle. Randomly changes the HUE light's color at regular interval. Works with all HUE lights having color capabilities. |
894
-
975
+ | Day/Night | *true* if daytime, *false* if nighttime. This GA is used to change some behaviours at day or night. |
976
+ | Switch on color at Daytime | You can choose the color/brightness of your light, at switch on, on night time. Set it as JSON object, like { "red": 255, "green": 255, "blue": 255 } |
977
+ | Switch on color at Nighttime | You can choose the color/brightness of your light, at switch on, on night time. Set it as JSON object, like { "red": 100, "green": 0, "blue": 0 } |
895
978
  <br/>
896
979
 
897
980
  [Find it useful?](https://www.paypal.me/techtoday)
@@ -27,6 +27,7 @@ module.exports = function (RED) {
27
27
  node.formatnegativevalue = 'leave'
28
28
  node.formatdecimalsvalue = 2
29
29
  node.currentHUEDevice = undefined
30
+ node.DayTime = true
30
31
 
31
32
  // Used to call the status update from the config node.
32
33
  node.setNodeStatus = ({ fill, shape, text, payload }) => {
@@ -45,7 +46,20 @@ module.exports = function (RED) {
45
46
  switch (msg.knx.destination) {
46
47
  case config.GALightSwitch:
47
48
  msg.payload = dptlib.fromBuffer(msg.knx.rawValue, dptlib.resolve(config.dptLightSwitch))
48
- state = msg.payload === true ? { on: { on: true },dimming: { brightness: 100 } } : { on: { on: false }, dimming: { brightness: 0 }}
49
+ if (msg.payload) {
50
+ let jColorChoosen = { red: 255, green: 255, blue: 255 }
51
+ if (node.DayTime) {
52
+ jColorChoosen = JSON.parse(config.colorAtSwitchOnDayTime || '{ "red": 255, "green": 255, "blue": 255 }')
53
+ } else {
54
+ jColorChoosen = JSON.parse(config.colorAtSwitchOnNightTime || '{ "red": 255, "green": 255, "blue": 255 }')
55
+ }
56
+ let dgamut = node.currentHUEDevice !== undefined ? node.currentHUEDevice.color.gamut_type : null
57
+ let dretXY = hueColorConverter.ColorConverter.rgbToXy(jColorChoosen.red, jColorChoosen.green, jColorChoosen.blue, dgamut)
58
+ let dbright = hueColorConverter.ColorConverter.getBrightnessFromRGB(jColorChoosen.red, jColorChoosen.green, jColorChoosen.blue)
59
+ state = dbright > 0 ? { on: { on: true }, dimming: { brightness: dbright }, color: { xy: dretXY } } : { on: { on: false } }
60
+ } else {
61
+ state = { on: { on: false } }
62
+ }
49
63
  node.serverHue.hueManager.writeHueQueueAdd(config.hueDevice, state, 'setLight')
50
64
  break
51
65
  case config.GALightDIM:
@@ -59,6 +73,9 @@ module.exports = function (RED) {
59
73
  node.startDimStopper('stop')
60
74
  }
61
75
  break
76
+ case config.GADaylightSensor:
77
+ node.DayTime = Boolean(dptlib.fromBuffer(msg.knx.rawValue, dptlib.resolve(config.dptDaylightSensor)))
78
+ break
62
79
  case config.GALightHSV:
63
80
  if (config.dptLightHSV === '3.007') {
64
81
  // MDT smartbutton will dim the color temperature
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "engines": {
4
4
  "node": ">=16.0.0"
5
5
  },
6
- "version": "2.1.13",
6
+ "version": "2.1.14",
7
7
  "description": "Control your KNX intallation via Node-Red! Single Node KNX IN/OUT with optional ETS group address importer. Easy to use and highly configurable. With integrated Philips HUE devices handling.",
8
8
  "dependencies": {
9
9
  "mkdirp": "1.0.4",