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
package/utils/rgb.js DELETED
@@ -1,188 +0,0 @@
1
- var colorPointsGamut_A = [[0.703, 0.296], [0.214, 0.709], [0.139, 0.081]];
2
- var colorPointsGamut_B = [[0.674, 0.322], [0.408, 0.517], [0.168, 0.041]];
3
- var colorPointsGamut_C = [[0.692, 0.308], [0.17, 0.7], [0.153, 0.048]];
4
- var colorPointsDefault = [[1.0, 0.0], [0.0, 1.0], [0.0, 0.0]];
5
-
6
- var GAMUT_A_BULBS_LIST = ["LLC001", "LLC005", "LLC006", "LLC007", "LLC010", "LLC011", "LLC012", "LLC014", "LLC013", "LST001"];
7
- var GAMUT_B_BULBS_LIST = ["LCT001", "LCT002", "LCT003", "LCT004", "LLM001", "LCT005", "LCT006", "LCT007"];
8
- var GAMUT_C_BULBS_LIST = ["LCT010", "LCT011", "LCT012", "LCT014", "LCT015", "LCT016", "LLC020", "LST002"];
9
- var MULTI_SOURCE_LUMINAIRES = ["HBL001", "HBL002", "HBL003", "HIL001", "HIL002", "HEL001", "HEL002"];
10
-
11
- module.exports = {
12
- convertXYtoRGB: _getRGBFromXYState,
13
- convertRGBtoXY: function(rgb, model)
14
- {
15
- var red = rgb[0];
16
- var green = rgb[1];
17
- var blue = rgb[2];
18
- red = red / 255;
19
- green = green / 255;
20
- blue = blue / 255;
21
- var r = red > 0.04045 ? Math.pow(((red + 0.055) / 1.055), 2.4000000953674316) : red / 12.92;
22
- var g = green > 0.04045 ? Math.pow(((green + 0.055) / 1.055), 2.4000000953674316) : green / 12.92;
23
- var b = blue > 0.04045 ? Math.pow(((blue + 0.055) / 1.055), 2.4000000953674316) : blue / 12.92;
24
- var x = r * 0.664511 + g * 0.154324 + b * 0.162028;
25
- var y = r * 0.283881 + g * 0.668433 + b * 0.047685;
26
- var z = r * 8.8E-5 + g * 0.07231 + b * 0.986039;
27
- var xy = [x / (x + y + z), y / (x + y + z)];
28
- if (isNaN(xy[0]))
29
- {
30
- xy[0] = 0.0;
31
- }
32
-
33
- if (isNaN(xy[1]))
34
- {
35
- xy[1] = 0.0;
36
- }
37
-
38
- var colorPoints = colorPointsForModel(model);
39
- var inReachOfLamps = checkPointInLampsReach(xy, colorPoints);
40
- if (!inReachOfLamps)
41
- {
42
- var pAB = getClosestPointToPoints(colorPoints[0], colorPoints[1], xy);
43
- var pAC = getClosestPointToPoints(colorPoints[2], colorPoints[0], xy);
44
- var pBC = getClosestPointToPoints(colorPoints[1], colorPoints[2], xy);
45
- var dAB = getDistanceBetweenTwoPoints(xy, pAB);
46
- var dAC = getDistanceBetweenTwoPoints(xy, pAC);
47
- var dBC = getDistanceBetweenTwoPoints(xy, pBC);
48
- var lowest = dAB;
49
- var closestPoint = pAB;
50
- if (dAC < dAB)
51
- {
52
- lowest = dAC;
53
- closestPoint = pAC;
54
- }
55
-
56
- if (dBC < lowest)
57
- {
58
- closestPoint = pBC;
59
- }
60
-
61
- xy[0] = closestPoint[0];
62
- xy[1] = closestPoint[1];
63
- }
64
-
65
- xy[0] = precision(xy[0]);
66
- xy[1] = precision(xy[1]);
67
- return xy;
68
- }
69
- };
70
-
71
- function colorPointsForModel(model)
72
- {
73
- if (model == null)
74
- {
75
- model = " ";
76
- }
77
-
78
- if (GAMUT_B_BULBS_LIST.indexOf(model) == -1 && MULTI_SOURCE_LUMINAIRES.indexOf(model) == -1)
79
- {
80
- if(GAMUT_A_BULBS_LIST.indexOf(model) >= 0)
81
- {
82
- return colorPointsGamut_A;
83
- }
84
- else if(GAMUT_C_BULBS_LIST.indexOf(model) >= 0)
85
- {
86
- return colorPointsGamut_C;
87
- }
88
- else
89
- {
90
- return colorPointsDefault;
91
- }
92
- }
93
- else
94
- {
95
- return colorPointsGamut_B;
96
- }
97
- }
98
-
99
- function checkPointInLampsReach(point, colorPoints)
100
- {
101
- if (point != null && colorPoints != null)
102
- {
103
- var red = colorPoints[0];
104
- var green = colorPoints[1];
105
- var blue = colorPoints[2];
106
- var v1 = [green[0] - red[0], green[1] - red[1]];
107
- var v2 = [blue[0] - red[0], blue[1] - red[1]];
108
- var q = [point[0] - red[0], point[1] - red[1]];
109
- var s = crossProduct(q, v2) / crossProduct(v1, v2);
110
- var t = crossProduct(v1, q) / crossProduct(v1, v2);
111
- return s >= 0.0 && t >= 0.0 && s + t <= 1.0;
112
- }
113
- else
114
- {
115
- return false;
116
- }
117
- }
118
-
119
- function crossProduct(point1, point2)
120
- {
121
- return point1[0] * point2[1] - point1[1] * point2[0];
122
- }
123
-
124
- function getClosestPointToPoints(pointA, pointB, pointP)
125
- {
126
- if (pointA != null && pointB != null && pointP != null)
127
- {
128
- var pointAP = [pointP[0] - pointA[0], pointP[1] - pointA[1]];
129
- var pointAB = [pointB[0] - pointA[0], pointB[1] - pointA[1]];
130
- var ab2 = pointAB[0] * pointAB[0] + pointAB[1] * pointAB[1];
131
- var apAb = pointAP[0] * pointAB[0] + pointAP[1] * pointAB[1];
132
- var t = apAb / ab2;
133
- if(t < 0.0)
134
- {
135
- t = 0.0;
136
- }
137
- else if(t > 1.0)
138
- {
139
- t = 1.0;
140
- }
141
-
142
- return [pointA[0] + pointAB[0] * t, pointA[1] + pointAB[1] * t];
143
- }
144
- else
145
- {
146
- return null;
147
- }
148
- }
149
-
150
- function getDistanceBetweenTwoPoints(pointA, pointB)
151
- {
152
- var dx = pointA[0] - pointB[0];
153
- var dy = pointA[1] - pointB[1];
154
- var dist = Math.sqrt(dx * dx + dy * dy);
155
- return dist;
156
- }
157
-
158
- function precision(d)
159
- {
160
- return Math.round(10000.0 * d) / 10000.0;
161
- }
162
-
163
- function _getRGBFromXYState(x, y, brightness)
164
- {
165
- var Y = brightness
166
- , X = (Y / y) * x
167
- , Z = (Y / y) * (1 - x - y)
168
- , rgb = [
169
- X * 1.612 - Y * 0.203 - Z * 0.302,
170
- -X * 0.509 + Y * 1.412 + Z * 0.066,
171
- X * 0.026 - Y * 0.072 + Z * 0.962
172
- ];
173
-
174
- rgb = rgb.map(function (x) {
175
- return (x <= 0.0031308) ? (12.92 * x) : ((1.0 + 0.055) * Math.pow(x, (1.0 / 2.4)) - 0.055);
176
- });
177
-
178
- rgb = rgb.map(function (x) { return Math.max(0, x); });
179
- var max = Math.max(rgb[0], rgb[1], rgb[2]);
180
- if (max > 1)
181
- {
182
- rgb = rgb.map(function (x) { return x / max; });
183
- }
184
-
185
- rgb = rgb.map(function (x) { return Math.floor(x * 255); });
186
-
187
- return rgb;
188
- }