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
@@ -0,0 +1,56 @@
1
+ {
2
+ "info":{
3
+ "name":"Superhero",
4
+ "author":"HueMagic"
5
+ },
6
+ "steps":[
7
+ {
8
+ "delay":1000,
9
+ "animation":{
10
+ "hex":"#000000",
11
+ "brightness":1,
12
+ "transitionTime":2
13
+ }
14
+ },
15
+ {
16
+ "delay":500,
17
+ "animation":{
18
+ "hex":"#09387A",
19
+ "brightness":50,
20
+ "transitionTime":0.5
21
+ }
22
+ },
23
+ {
24
+ "delay":500,
25
+ "animation":{
26
+ "hex":"#126CB3",
27
+ "brightness":70,
28
+ "transitionTime":0.5
29
+ }
30
+ },
31
+ {
32
+ "delay":500,
33
+ "animation":{
34
+ "hex":"#D4E226",
35
+ "brightness":70,
36
+ "transitionTime":0.5
37
+ }
38
+ },
39
+ {
40
+ "delay":500,
41
+ "animation":{
42
+ "hex":"#FFF024",
43
+ "brightness":100,
44
+ "transitionTime":2
45
+ }
46
+ },
47
+ {
48
+ "delay":2000,
49
+ "animation":{
50
+ "hex":"#F5131F",
51
+ "brightness":100,
52
+ "transitionTime":0.5
53
+ }
54
+ }
55
+ ]
56
+ }
@@ -0,0 +1,52 @@
1
+ {
2
+ "info":{
3
+ "name":"Neon City",
4
+ "author":"HueMagic"
5
+ },
6
+ "specials":{
7
+ "randomOrder": true
8
+ },
9
+ "steps":
10
+ [
11
+ {
12
+ "delay":700,
13
+ "animation":{
14
+ "hex":"#fa448c",
15
+ "brightness":100,
16
+ "transitionTime":0.5
17
+ }
18
+ },
19
+ {
20
+ "delay":500,
21
+ "animation":{
22
+ "hex":"#fec859",
23
+ "brightness":100,
24
+ "transitionTime":0.5
25
+ }
26
+ },
27
+ {
28
+ "delay":1000,
29
+ "animation":{
30
+ "hex":"#0a1045",
31
+ "brightness":100,
32
+ "transitionTime":0.5
33
+ }
34
+ },
35
+ {
36
+ "delay":700,
37
+ "animation":{
38
+ "hex":"#43b5a0",
39
+ "brightness":100,
40
+ "transitionTime":0.5
41
+ }
42
+ },
43
+ {
44
+ "delay":1000,
45
+ "animation":{
46
+ "hex":"#491d88",
47
+ "brightness":90,
48
+ "transitionTime":0.6
49
+ }
50
+ }
51
+ ]
52
+ }
@@ -1,38 +1,41 @@
1
1
  <script type="text/x-red" data-template-name="hue-bridge">
2
2
  <div class="form-row">
3
3
  <label for="node-config-input-name"><i class="fa fa-tag"></i> <span data-i18n="hue-bridge-config.config.name"></span></label>
4
- <input type="text" id="node-config-input-name">
4
+ <input type="text" id="node-config-input-name" style="width: calc(100% - 105px)">
5
5
  </div>
6
6
  <div class="form-row">
7
7
  <label for="node-config-input-bridge"><i class="fa fa-server"></i> Bridge IP</label>
8
- <div style="display: inline-block; position: relative; width: 70%; height: 20px;">
9
- <div style="position: absolute; left: 0px; right: 40px;">
8
+ <div style="display: inline-flex; width: calc(100% - 105px)">
9
+ <div id="input-select-toggle" style="flex-grow: 1;">
10
10
  <input type="text" id="node-config-input-bridge" placeholder="X.X.X.X[:PORT]" style="width: 100%"/>
11
11
  </div>
12
- <a id="node-config-input-scan" class="editor-button" style="position: absolute; right: 0px; top: 0px;">
12
+ <button id="node-config-input-scan" type="button" class="red-ui-button" style="margin-left: 10px;">
13
13
  <i class="fa fa-search"></i>
14
- </a>
14
+ </button>
15
15
  </div>
16
16
  </div>
17
17
  <div class="form-row">
18
18
  <label for="node-config-input-key"><i class="fa fa-key"></i> <span data-i18n="hue-bridge-config.config.apikey"></span></label>
19
- <div style="display: inline-block; position: relative; width: 70%; height: 20px;">
20
- <div style="position: absolute; left: 0px; right: 40px;">
19
+ <div style="display: inline-flex; width: calc(100% - 105px)">
20
+ <div style="flex-grow: 1;">
21
21
  <input type="text" id="node-config-input-key" style="width: 100%"/>
22
22
  </div>
23
- <a id="node-config-input-register" class="editor-button" style="position: absolute; right: 0px; top: 0px;">
23
+ <button id="node-config-input-register" type="button" class="red-ui-button" style="margin-left: 10px;">
24
24
  <i class="fa fa-user-circle-o"></i>
25
- </a>
25
+ </button>
26
26
  </div>
27
27
  </div>
28
+ <div class="form-row" style="margin-top: 30px">
29
+ <div style="display: inline-flex; width: calc(100% - 105px)">
30
+ <input type="checkbox" id="node-input-autoupdates" style="flex: 15px;">
31
+ <span data-i18n="hue-bridge-config.config.autoupdates" style="width: 100%; margin-left: 10px;"></span>
32
+ </div>
33
+ </div>
28
34
  <div class="form-row">
29
- <label for="node-config-input-interval"><i class="fa fa-clock-o"></i> <span data-i18n="hue-bridge-config.config.poll"></span></label>
30
- <input type="text" placeholder="3000" id="node-config-input-interval">
31
- </div>
32
- <div class="form-row">
33
- <label for="node-config-input-disableupdates"><i class="fa fa-sign-out"></i> <span data-i18n="hue-bridge-config.config.disable-events"></span></label>
34
- <input type="checkbox" id="node-config-input-disableupdates" style="display:inline-block; width:22px; vertical-align:baseline;"><span data-i18n="hue-bridge-config.config.disable-events-info"></span>
35
- </label>
35
+ <div style="display: inline-flex; width: calc(100% - 105px)">
36
+ <input type="checkbox" id="node-config-input-disableupdates" style="flex: 15px;">
37
+ <span data-i18n="hue-bridge-config.config.disable-events-info" style="width: 100%; margin-left: 10px;"></span>
38
+ </div>
36
39
  </div>
37
40
  </script>
38
41
 
@@ -41,93 +44,134 @@
41
44
  category: "config",
42
45
  color: '#c7d8d8',
43
46
  defaults: {
44
- name: {value:"Hue Bridge", required: true},
45
- bridge: {value:"", required: true},
46
- key: {value:"", required: true},
47
- interval: {
48
- value: 3000,
49
- required: true,
50
- validate: function(v) {
51
- return (/^[0-9]+/.test(v) && parseInt(v,10) >= 500);
52
- }
53
- },
54
- disableupdates: {value: false}
47
+ name: { value:"Hue Bridge", required: true },
48
+ bridge: { value:"", required: true },
49
+ key: { value:"", required: true },
50
+ autoupdates: { value: true },
51
+ disableupdates: { value: false }
55
52
  },
56
53
  icon: "hue-bridge-config.png",
57
- paletteLabel: function() {
58
- return this._("hue-bridge-config.node.title");
59
- },
60
54
  label: function() {
61
55
  return this.name;
62
56
  },
57
+ paletteLabel: function() {
58
+ return this._("hue-bridge-config.node.title");
59
+ },
63
60
  oneditprepare: function()
64
61
  {
65
- var scope = this;
62
+ const scope = this;
63
+ let options = [];
66
64
 
67
- function manualBridgeIP()
65
+ function manualInput()
68
66
  {
67
+ // GET CURRENT SELECTED VALUE
69
68
  var current = $('#node-config-input-bridge').val();
70
- $('#node-config-input-bridge').replaceWith('<input type="text" id="node-config-input-bridge" style="width: 100%"/>');
71
- $('#node-config-input-bridge').val(current);
69
+
70
+ // REMOVE SELECT FIELD
71
+ $('#input-select-toggle').empty();
72
+
73
+ // CREATE NEW INPUT FIELD
74
+ $('#input-select-toggle').append('<input type="text" id="node-config-input-bridge" placeholder="X.X.X.X[:PORT]" style="width: 100%" value="'+current+'" />');
75
+
76
+ // CHANGE BUTTON ICON
77
+ var button = $("#node-config-input-scan");
78
+ var buttonIcon = button.find("i");
79
+ buttonIcon.removeClass("fa-pencil");
80
+ buttonIcon.addClass("fa-search");
72
81
  }
73
82
 
74
- function searchAndSelectBridge()
83
+ function searchAndSelect()
75
84
  {
85
+ // GET CURRENT SELECTED VALUE
76
86
  var current = $('#node-config-input-bridge').val();
77
- $('#node-config-input-bridge').replaceWith('<select id="node-config-input-bridge" style="width: 100%"></select>');
78
- $('#node-config-input-bridge').append('<option selected="selected" value="null">'+scope._("hue-bridge-config.config.searching")+'</option>');
79
87
 
88
+ // TRIGGER SEARCHING NOTIFICATION
89
+ var notification = RED.notify(scope._("hue-bridge-config.config.searching"), { type: "compact", modal: true, fixed: true });
90
+
91
+ // GET THE SENSORS
80
92
  $.get('hue/bridges')
81
93
  .done( function(data) {
82
- var bridges = JSON.parse(data);
94
+ var allRessources = JSON.parse(data);
95
+ if(allRessources.length <= 0)
96
+ {
97
+ notification.close();
98
+ RED.notify(scope._("hue-bridge-config.config.none-found"), { type: "error" });
99
+ return false;
100
+ }
83
101
 
84
- if(bridges.length <= 0)
85
- {
86
- RED.notify(scope._("hue-bridge-config.config.none-found"), "error");
87
- }
102
+ // SET OPTIONS
103
+ allRessources.forEach(function(ressource)
104
+ {
105
+ options[ressource.ip] = { value: ressource.ip, label: ressource.ip };
106
+ });
88
107
 
89
- // RESET OPTIONS
90
- $('#node-config-input-bridge').empty();
108
+ // SELECT CURRENT VALUE
109
+ $("#node-config-input-bridge").typedInput({
110
+ types: [
111
+ {
112
+ value: current,
113
+ options: Object.values(options)
114
+ }
115
+ ]
116
+ });
91
117
 
92
- // SET BRIDGES AS OPTIONS
93
- bridges.forEach(function(bridge)
94
- {
95
- $('#node-config-input-bridge').append('<option value="' + bridge.ip + '">' + bridge.ip + '</option>');
96
- });
118
+ // CHANGE BUTTON ICON
119
+ var button = $("#node-config-input-scan");
120
+ var buttonIcon = button.find("i");
121
+ buttonIcon.removeClass("fa-search");
122
+ buttonIcon.addClass("fa-pencil");
97
123
 
98
- // SELECT CURRENT VALUE
99
- $('#node-config-input-bridge').val(current);
124
+ // CLOSE SEARCH NOTIFICATION
125
+ notification.close();
100
126
  })
101
127
  .fail(function()
102
128
  {
103
- RED.notify(scope._("hue-bridge-config.config.unknown-error"), "error");
129
+ notification.close();
130
+ RED.notify(scope._("hue-bridge-config.config.unknown-error"), "error");
104
131
  });
105
132
  }
106
133
 
107
- $(document).on('change', '#node-config-input-bridge', function()
134
+ // CHANGED BRIDGE IP? -> GET NAME (IF POSSIBLE)
135
+ $(document).off('change', '#node-config-input-bridge');
136
+ $(document).on('change', '#node-config-input-bridge', function(e)
108
137
  {
109
- var currentBridgeIP = $('#node-config-input-bridge').val();
110
- if(currentBridgeIP.length > 6)
138
+ let currentBridgeIP = $(e.currentTarget).val();
139
+ if(currentBridgeIP.length > 3)
111
140
  {
112
- $.get('hue/name', { ip: currentBridgeIP } )
141
+ // TRIGGER SEARCHING NOTIFICATION
142
+ var notification = RED.notify(scope._("hue-bridge-config.config.connecting"), { type: "compact", modal: true, fixed: true });
143
+
144
+ $.ajax({
145
+ url: 'hue/name',
146
+ type: "GET",
147
+ data: { ip: currentBridgeIP },
148
+ timeout: 3000
149
+ })
113
150
  .done( function(data)
114
151
  {
115
152
  $('#node-config-input-name').val(data);
153
+ setTimeout(function() { notification.close(); }, 500);
116
154
  })
117
155
  .fail(function(err)
118
156
  {
119
- RED.notify(scope._("hue-bridge-config.config.invalid") + err, "error");
157
+ // CLOSE SEARCH NOTIFICATION
158
+ notification.close();
159
+
160
+ RED.notify(scope._("hue-bridge-config.config.invalid") + err.statusText, "error");
120
161
  });
121
162
  }
122
163
  });
123
164
 
165
+ // TOGGLE SELECT/INPUT FIELD
124
166
  $('#node-config-input-scan').click(function()
125
167
  {
126
- if($('#node-config-input-bridge').prop("tagName") === "INPUT")
168
+ if($('#input-select-toggle').find(".red-ui-typedInput-container").length > 0)
169
+ {
170
+ manualInput();
171
+ }
172
+ else
127
173
  {
128
- searchAndSelectBridge();
129
- } else {
130
- manualBridgeIP();
174
+ searchAndSelect();
131
175
  }
132
176
  });
133
177