node-red-contrib-huemagic 2.8.2 → 4.0.0

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.
Files changed (165) hide show
  1. package/CHANGELOG.md +229 -0
  2. package/README.md +806 -729
  3. package/examples/Hue Bridge.json +189 -35
  4. package/examples/Hue Brightness.json +124 -14
  5. package/examples/Hue Buttons.json +88 -0
  6. package/examples/Hue Group.json +575 -63
  7. package/examples/Hue Light.json +805 -58
  8. package/examples/Hue Magic.json +69 -24
  9. package/examples/Hue Motion.json +110 -42
  10. package/examples/Hue Rules.json +105 -37
  11. package/examples/Hue Scene.json +145 -28
  12. package/examples/Hue Temperature.json +124 -14
  13. package/huemagic/animations/001-sunny.json +22 -22
  14. package/huemagic/animations/002-cloudy.json +46 -46
  15. package/huemagic/animations/003-nightsky.json +20 -20
  16. package/huemagic/animations/004-sunrise.json +54 -54
  17. package/huemagic/animations/005-sunset.json +46 -46
  18. package/huemagic/animations/006-fireplace.json +74 -74
  19. package/huemagic/animations/007-spring.json +31 -31
  20. package/huemagic/animations/008-autmn.json +23 -23
  21. package/huemagic/animations/009-winter.json +23 -23
  22. package/huemagic/animations/010-dirtyfog.json +23 -23
  23. package/huemagic/animations/011-lgbt.json +49 -50
  24. package/huemagic/animations/012-rasta.json +28 -29
  25. package/huemagic/animations/013-strobo.json +30 -31
  26. package/huemagic/animations/014-randomrainbow.json +30 -31
  27. package/huemagic/animations/015-sos.json +158 -159
  28. package/huemagic/animations/016-milkyway.json +83 -0
  29. package/huemagic/animations/017-beach.json +40 -0
  30. package/huemagic/animations/018-forest.json +43 -0
  31. package/huemagic/animations/019-christmas.json +30 -0
  32. package/huemagic/animations/020-superhero.json +56 -0
  33. package/huemagic/animations/021-neoncity.json +52 -0
  34. package/huemagic/animations/previews/001-sunny.gif +0 -0
  35. package/huemagic/animations/previews/002-cloudy.gif +0 -0
  36. package/huemagic/animations/previews/003-nightsky.gif +0 -0
  37. package/huemagic/animations/previews/004-sunrise.gif +0 -0
  38. package/huemagic/animations/previews/005-sunset.gif +0 -0
  39. package/huemagic/animations/previews/006-fireplace.gif +0 -0
  40. package/huemagic/animations/previews/007-spring.gif +0 -0
  41. package/huemagic/animations/previews/008-autmn.gif +0 -0
  42. package/huemagic/animations/previews/009-winter.gif +0 -0
  43. package/huemagic/animations/previews/010-dirtyfog.gif +0 -0
  44. package/huemagic/animations/previews/011-lgbt.gif +0 -0
  45. package/huemagic/animations/previews/012-rasta.gif +0 -0
  46. package/huemagic/animations/previews/013-strobo.gif +0 -0
  47. package/huemagic/animations/previews/014-randomrainbow.gif +0 -0
  48. package/huemagic/animations/previews/015-sos.gif +0 -0
  49. package/huemagic/animations/previews/016-milkyway.gif +0 -0
  50. package/huemagic/animations/previews/017-beach.gif +0 -0
  51. package/huemagic/animations/previews/018-forest.gif +0 -0
  52. package/huemagic/animations/previews/019-christmas.gif +0 -0
  53. package/huemagic/animations/previews/020-superhero.gif +0 -0
  54. package/huemagic/animations/previews/021-neoncity.gif +0 -0
  55. package/huemagic/hue-bridge-config.html +105 -61
  56. package/huemagic/hue-bridge-config.js +629 -319
  57. package/huemagic/hue-bridge.html +41 -21
  58. package/huemagic/hue-bridge.js +191 -398
  59. package/huemagic/hue-brightness.html +130 -49
  60. package/huemagic/hue-brightness.js +131 -35
  61. package/huemagic/hue-buttons.html +197 -0
  62. package/huemagic/hue-buttons.js +152 -0
  63. package/huemagic/hue-group.html +137 -60
  64. package/huemagic/hue-group.js +394 -367
  65. package/huemagic/hue-light.html +133 -59
  66. package/huemagic/hue-light.js +551 -336
  67. package/huemagic/hue-magic.html +91 -237
  68. package/huemagic/hue-magic.js +57 -27
  69. package/huemagic/hue-motion.html +128 -50
  70. package/huemagic/hue-motion.js +116 -87
  71. package/huemagic/hue-rules.html +121 -50
  72. package/huemagic/hue-rules.js +84 -64
  73. package/huemagic/hue-scene.html +96 -115
  74. package/huemagic/hue-scene.js +65 -96
  75. package/huemagic/hue-temperature.html +130 -49
  76. package/huemagic/hue-temperature.js +136 -32
  77. package/huemagic/icons/hue-bridge.png +0 -0
  78. package/huemagic/icons/hue-bridge.svg +3 -0
  79. package/huemagic/icons/hue-brightness.png +0 -0
  80. package/huemagic/icons/hue-brightness.svg +11 -0
  81. package/huemagic/icons/hue-buttons.png +0 -0
  82. package/huemagic/icons/hue-buttons.svg +4 -0
  83. package/huemagic/icons/hue-group.png +0 -0
  84. package/huemagic/icons/hue-group.svg +12 -0
  85. package/huemagic/icons/hue-light.png +0 -0
  86. package/huemagic/icons/hue-light.svg +3 -0
  87. package/huemagic/icons/hue-magic.png +0 -0
  88. package/huemagic/icons/hue-magic.svg +3 -0
  89. package/huemagic/icons/hue-motion.png +0 -0
  90. package/huemagic/icons/hue-motion.svg +9 -0
  91. package/huemagic/icons/hue-rules.png +0 -0
  92. package/huemagic/icons/hue-rules.svg +4 -0
  93. package/huemagic/icons/hue-scene.png +0 -0
  94. package/huemagic/icons/hue-scene.svg +5 -0
  95. package/huemagic/icons/hue-temperature.png +0 -0
  96. package/huemagic/icons/hue-temperature.svg +7 -0
  97. package/huemagic/locales/de/hue-bridge-config.html +17 -12
  98. package/huemagic/locales/de/hue-bridge-config.json +7 -5
  99. package/huemagic/locales/de/hue-bridge.html +64 -145
  100. package/huemagic/locales/de/hue-bridge.json +6 -17
  101. package/huemagic/locales/de/hue-brightness.html +52 -38
  102. package/huemagic/locales/de/hue-brightness.json +7 -2
  103. package/huemagic/locales/de/hue-buttons.html +58 -0
  104. package/huemagic/locales/de/hue-buttons.json +28 -0
  105. package/huemagic/locales/de/hue-group.html +46 -122
  106. package/huemagic/locales/de/hue-group.json +4 -2
  107. package/huemagic/locales/de/hue-light.html +68 -116
  108. package/huemagic/locales/de/hue-light.json +5 -2
  109. package/huemagic/locales/de/hue-magic.html +65 -57
  110. package/huemagic/locales/de/hue-magic.json +2 -1
  111. package/huemagic/locales/de/hue-motion.html +48 -44
  112. package/huemagic/locales/de/hue-motion.json +6 -3
  113. package/huemagic/locales/de/hue-rules.html +68 -73
  114. package/huemagic/locales/de/hue-rules.json +5 -2
  115. package/huemagic/locales/de/hue-scene.html +23 -32
  116. package/huemagic/locales/de/hue-scene.json +5 -2
  117. package/huemagic/locales/de/hue-temperature.html +53 -36
  118. package/huemagic/locales/de/hue-temperature.json +7 -2
  119. package/huemagic/locales/en-US/hue-bridge-config.html +17 -12
  120. package/huemagic/locales/en-US/hue-bridge-config.json +5 -3
  121. package/huemagic/locales/en-US/hue-bridge.html +64 -145
  122. package/huemagic/locales/en-US/hue-bridge.json +5 -16
  123. package/huemagic/locales/en-US/hue-brightness.html +52 -38
  124. package/huemagic/locales/en-US/hue-brightness.json +10 -3
  125. package/huemagic/locales/en-US/hue-buttons.html +58 -0
  126. package/huemagic/locales/en-US/hue-buttons.json +34 -0
  127. package/huemagic/locales/en-US/hue-group.html +46 -122
  128. package/huemagic/locales/en-US/hue-group.json +7 -3
  129. package/huemagic/locales/en-US/hue-light.html +68 -116
  130. package/huemagic/locales/en-US/hue-light.json +8 -3
  131. package/huemagic/locales/en-US/hue-magic.html +65 -57
  132. package/huemagic/locales/en-US/hue-magic.json +3 -1
  133. package/huemagic/locales/en-US/hue-motion.html +48 -44
  134. package/huemagic/locales/en-US/hue-motion.json +9 -4
  135. package/huemagic/locales/en-US/hue-rules.html +68 -73
  136. package/huemagic/locales/en-US/hue-rules.json +5 -2
  137. package/huemagic/locales/en-US/hue-scene.html +23 -32
  138. package/huemagic/locales/en-US/hue-scene.json +5 -2
  139. package/huemagic/locales/en-US/hue-temperature.html +53 -36
  140. package/huemagic/locales/en-US/hue-temperature.json +10 -3
  141. package/huemagic/utils/api.js +290 -0
  142. package/huemagic/utils/color.js +382 -0
  143. package/{utils → huemagic/utils}/merge.js +9 -6
  144. package/huemagic/utils/messages.js +447 -0
  145. package/package.json +12 -12
  146. package/examples/Hue Switch.json +0 -40
  147. package/examples/Hue Tap.json +0 -40
  148. package/huemagic/assets/anime.js +0 -8
  149. package/huemagic/hue-switch.html +0 -119
  150. package/huemagic/hue-switch.js +0 -113
  151. package/huemagic/hue-tap.html +0 -119
  152. package/huemagic/hue-tap.js +0 -74
  153. package/huemagic/icons/hue-button.png +0 -0
  154. package/huemagic/icons/hue-switch.png +0 -0
  155. package/huemagic/icons/hue-tap.png +0 -0
  156. package/huemagic/locales/de/hue-switch.html +0 -50
  157. package/huemagic/locales/de/hue-switch.json +0 -31
  158. package/huemagic/locales/de/hue-tap.html +0 -41
  159. package/huemagic/locales/de/hue-tap.json +0 -23
  160. package/huemagic/locales/en-US/hue-switch.html +0 -50
  161. package/huemagic/locales/en-US/hue-switch.json +0 -31
  162. package/huemagic/locales/en-US/hue-tap.html +0 -41
  163. package/huemagic/locales/en-US/hue-tap.json +0 -23
  164. package/utils/messages.js +0 -571
  165. package/utils/rgb.js +0 -188
@@ -1,33 +1,40 @@
1
1
  <script type="text/x-red" data-template-name="hue-light">
2
2
  <div class="form-row">
3
3
  <label for="node-input-name"><i class="fa fa-tag"></i> <span data-i18n="hue-light.config.name"></span></label>
4
- <input type="text" id="node-input-name" data-i18n="[placeholder]hue-light.config.input-name">
4
+ <input type="text" id="node-input-name" data-i18n="[placeholder]hue-light.config.input-name" style="width: calc(100% - 105px)">
5
5
  </div>
6
6
  <div class="form-row">
7
7
  <label for="node-input-bridge"><i class="fa fa-server"></i> Bridge</label>
8
- <input type="text" id="node-input-bridge">
8
+ <input type="text" id="node-input-bridge" style="width: calc(100% - 105px)">
9
9
  </div>
10
10
  <div class="form-row">
11
11
  <label for="node-input-lightid"><i class="fa fa-lightbulb-o"></i> <span data-i18n="hue-light.config.light"></span></label>
12
- <div style="display: inline-block; position: relative; width: 70%; height: 20px;">
13
- <div style="position: absolute; left: 0px; right: 40px;">
14
- <input type="text" id="node-input-lightid" placeholder="1" style="width: 100%"/>
12
+ <div style="display: inline-flex; width: calc(100% - 105px)">
13
+ <div id="input-select-toggle" style="flex-grow: 1;">
14
+ <input type="text" id="node-input-lightid" placeholder="00000000-0000-0000-0000-000000000000" style="width: 100%"/>
15
15
  </div>
16
- <a id="node-config-input-scan-lights" class="editor-button" style="position: absolute; right: 0px; top: 0px;">
16
+ <button id="node-config-input-scan-lights" type="button" class="red-ui-button" style="margin-left: 10px;">
17
17
  <i class="fa fa-search"></i>
18
- </a>
18
+ </button>
19
+ </div>
20
+ </div>
21
+ <div class="form-row" style="margin-top: 30px">
22
+ <div style="display: inline-flex; width: calc(100% - 105px)">
23
+ <input type="checkbox" id="node-input-colornamer" style="flex: 15px;">
24
+ <span data-i18n="hue-light.config.colornamer-info" style="width: 100%; margin-left: 10px;"></span>
19
25
  </div>
20
26
  </div>
21
27
  <div class="form-row">
22
- <label for="node-input-colornamer"><i class="fa fa-check-circle"></i> <span data-i18n="hue-light.config.colornamer"></span></label>
23
- <label for="node-input-colornamer" style="width:70%">
24
- <input type="checkbox" id="node-input-colornamer" style="display:inline-block; width:22px; vertical-align:baseline;"><span data-i18n="hue-light.config.colornamer-info"></span>
25
- </label>
28
+ <div style="display: inline-flex; width: calc(100% - 105px)">
29
+ <input type="checkbox" id="node-input-skipevents" style="flex: 15px;">
30
+ <span data-i18n="hue-light.config.skipevents-node" style="width: 100%; margin-left: 10px;"></span>
31
+ </div>
26
32
  </div>
27
33
  <div class="form-row">
28
- <label for="node-input-skipevents"><i class="fa fa-sign-out"></i> <span data-i18n="hue-light.config.skipevents"></span></label>
29
- <input type="checkbox" id="node-input-skipevents" style="display:inline-block; width:22px; vertical-align:baseline;"><span data-i18n="hue-light.config.skipevents-node"></span>
30
- </label>
34
+ <div style="display: inline-flex; width: calc(100% - 105px)">
35
+ <input type="checkbox" id="node-input-initevents" style="flex: 15px;">
36
+ <span data-i18n="hue-light.config.sendinitevents-node" style="width: 100%; margin-left: 10px;"></span>
37
+ </div>
31
38
  </div>
32
39
  </script>
33
40
 
@@ -36,95 +43,162 @@
36
43
  category: 'HueMagic',
37
44
  color: '#47c0e8',
38
45
  defaults: {
39
- name: {value:""},
40
- bridge: {type: "hue-bridge", required: true},
41
- lightid: {value:"", required: false, validate: function(id) {
42
- if(id.length < 1) { return true; }
43
- else if(!isNaN(id)) { return true; }
44
- else { return false; }
45
- }},
46
- colornamer: {value: true},
47
- skipevents: {value: false}
46
+ name: { value:"" },
47
+ bridge: { type: "hue-bridge", required: true },
48
+ lightid: { value:"", required: false },
49
+ colornamer: { value: true },
50
+ skipevents: { value: false },
51
+ initevents: { value: false }
48
52
  },
53
+ align: 'left',
54
+ icon: "hue-light.png",
49
55
  inputs: 1,
50
56
  outputs: 1,
57
+ label: function() {
58
+ return this.name || this._("hue-light.node.title");
59
+ },
60
+ paletteLabel: function() {
61
+ return this._("hue-light.node.title");
62
+ },
51
63
  inputLabels: function() {
52
64
  return this._("hue-light.node.input");
53
65
  },
54
66
  outputLabels: function() {
55
67
  return this._("hue-light.node.output");
56
68
  },
57
- align: 'right',
58
- icon: "hue-light.png",
59
- paletteLabel: function() {
60
- return this._("hue-light.node.title");
61
- },
62
- label: function() {
63
- return this.name || this._("hue-light.node.title");
64
- },
65
69
  oneditprepare: function()
66
70
  {
67
- var scope = this;
71
+ const scope = this;
72
+ let options = [];
68
73
 
69
- function manualLightID()
74
+ function manualInput()
70
75
  {
76
+ // GET CURRENT SELECTED VALUE
71
77
  var current = $('#node-input-lightid').val();
72
- $('#node-input-lightid').replaceWith('<input type="text" id="node-input-lightid" style="width: 100%"/>');
73
- $('#node-input-lightid').val(current);
78
+
79
+ // REMOVE SELECT FIELD
80
+ $('#input-select-toggle').empty();
81
+
82
+ // CREATE NEW INPUT FIELD
83
+ $('#input-select-toggle').append('<input type="text" id="node-input-lightid" placeholder="00000000-0000-0000-0000-000000000000" style="width: 100%" value="'+current+'" />');
84
+
85
+ // CHANGE BUTTON ICON
86
+ var button = $("#node-config-input-scan-lights");
87
+ var buttonIcon = button.find("i");
88
+ buttonIcon.removeClass("fa-pencil");
89
+ buttonIcon.addClass("fa-search");
74
90
  }
75
91
 
76
- function searchAndSelectLightID()
92
+ function searchAndSelect()
77
93
  {
94
+ // GET CURRENT BRIDGE CONFIGURATION
95
+ var bridgeConfig = RED.nodes.node($('#node-input-bridge option:selected').val());
96
+ if(!bridgeConfig) { return false; }
97
+
98
+ // GET CURRENT SELECTED VALUE
78
99
  var current = $('#node-input-lightid').val();
79
- $('#node-input-lightid').replaceWith('<select id="node-input-lightid" style="width: 100%"></select>');
80
- $('#node-input-lightid').append('<option selected="selected" value="null">'+scope._("hue-light.config.searching")+'</option>');
81
100
 
82
- var bridgeConfig = RED.nodes.node($('#node-input-bridge option:selected').val());
83
- $.get('hue/lights', {bridge: bridgeConfig.bridge, key: bridgeConfig.key, type: "ZLLPresence"})
84
- .done(function(data) {
85
- var lightBulbs = JSON.parse(data);
101
+ // TRIGGER SEARCHING NOTIFICATION
102
+ var notification = RED.notify(scope._("hue-light.config.searching"), { type: "compact", modal: true, fixed: true });
86
103
 
87
- if(lightBulbs.length <= 0)
104
+ // GET THE LIGHTS
105
+ $.get('hue/ressources', { bridge: bridgeConfig.bridge, key: bridgeConfig.key, type: "light" })
106
+ .done( function(data) {
107
+ var allRessources = JSON.parse(data);
108
+ if(allRessources.length <= 0)
88
109
  {
89
- RED.notify(scope._("hue-light.config.none-found"), "error");
110
+ notification.close();
111
+ RED.notify(scope._("hue-light.config.none-found"), { type: "error" });
112
+ return false;
90
113
  }
91
114
 
92
- // RESET OPTIONS
93
- $('#node-input-lightid').empty();
94
-
95
- // SET LIGHTS AS OPTIONS
96
- lightBulbs.forEach(function(light)
115
+ // SET OPTIONS
116
+ allRessources.forEach(function(ressource)
97
117
  {
98
- $('#node-input-lightid').append('<option value="' + light.id + '">' + light.name + '</option>');
118
+ if(ressource.model)
119
+ {
120
+ options[ressource.id] = { value: ressource.id, label: ressource.name + " ("+ressource.model+")" };
121
+ }
122
+ else
123
+ {
124
+ options[ressource.id] = { value: ressource.id, label: ressource.name };
125
+ }
99
126
  });
100
127
 
101
128
  // SELECT CURRENT VALUE
102
- $('#node-input-lightid').val(current);
129
+ $("#node-input-lightid").typedInput({
130
+ types: [
131
+ {
132
+ value: current,
133
+ options: Object.values(options)
134
+ }
135
+ ]
136
+ });
137
+
138
+ // CHANGE BUTTON ICON
139
+ var button = $("#node-config-input-scan-lights");
140
+ var buttonIcon = button.find("i");
141
+ buttonIcon.removeClass("fa-search");
142
+ buttonIcon.addClass("fa-pencil");
143
+
144
+ // CLOSE SEARCH NOTIFICATION
145
+ notification.close();
103
146
  })
104
147
  .fail(function()
105
148
  {
149
+ notification.close();
106
150
  RED.notify(scope._("hue-light.config.unknown-error"), "error");
107
151
  });
108
152
  }
109
153
 
110
- $(document).on('change', '#node-input-lightid', function()
154
+ // CHANGED LIGHT ID? -> REPLACE NAME (IF POSSIBLE)
155
+ $(document).on('change', '#node-input-lightid', function(e)
111
156
  {
112
- var lightName = $('#node-input-lightid option:selected').text();
113
- if(lightName.length > 0)
157
+ let currentSelectedOptionID = $(e.currentTarget).val();
158
+ let currentSelectedOptionValue = (currentSelectedOptionID.length > 0 && options[currentSelectedOptionID]) ? options[currentSelectedOptionID].label : false;
159
+
160
+ if(currentSelectedOptionValue !== false)
114
161
  {
115
- $('#node-input-name').val(lightName);
162
+ $('#node-input-name').val(currentSelectedOptionValue.split(" (")[0]);
116
163
  }
117
164
  });
118
165
 
166
+ // TOGGLE SELECT/INPUT FIELD
119
167
  $('#node-config-input-scan-lights').click(function()
120
168
  {
121
- if($('#node-input-lightid').prop("tagName") === "INPUT")
169
+ if($('#input-select-toggle').find(".red-ui-typedInput-container").length > 0)
170
+ {
171
+ manualInput();
172
+ }
173
+ else
122
174
  {
123
- searchAndSelectLightID();
124
- } else {
125
- manualLightID();
175
+ searchAndSelect();
126
176
  }
127
177
  });
178
+ },
179
+ button: {
180
+ enabled: function() {
181
+ return (this.lightid && this.lightid.length > 1)
182
+ },
183
+ visible: function() {
184
+ return (this.lightid && this.lightid.length > 1)
185
+ },
186
+ onclick: function()
187
+ {
188
+ const node = this;
189
+ if(node.bridge)
190
+ {
191
+ $.ajax({
192
+ url: "inject/" + node.id,
193
+ type: "POST",
194
+ data: JSON.stringify({ __user_inject_props__: "status"}),
195
+ contentType: "application/json; charset=utf-8",
196
+ success: function (resp) {
197
+ RED.notify(node.name + ": " + node._("hue-light.node.statusmsg"), { type: "success", id: "status", timeout: 2000 });
198
+ }
199
+ });
200
+ }
201
+ }
128
202
  }
129
203
  });
130
204
  </script>