node-red-contrib-huemagic 3.0.0 → 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 (138) hide show
  1. package/README.md +764 -603
  2. package/examples/Hue Bridge.json +189 -35
  3. package/examples/Hue Brightness.json +124 -14
  4. package/examples/Hue Buttons.json +88 -0
  5. package/examples/Hue Group.json +575 -63
  6. package/examples/Hue Light.json +805 -58
  7. package/examples/Hue Magic.json +69 -24
  8. package/examples/Hue Motion.json +110 -42
  9. package/examples/Hue Rules.json +105 -37
  10. package/examples/Hue Scene.json +145 -28
  11. package/examples/Hue Temperature.json +124 -14
  12. package/huemagic/animations/019-christmas.json +30 -0
  13. package/huemagic/animations/020-superhero.json +56 -0
  14. package/huemagic/animations/021-neoncity.json +52 -0
  15. package/huemagic/animations/previews/006-fireplace.gif +0 -0
  16. package/huemagic/animations/previews/013-strobo.gif +0 -0
  17. package/huemagic/animations/previews/014-randomrainbow.gif +0 -0
  18. package/huemagic/animations/previews/016-milkyway.gif +0 -0
  19. package/huemagic/animations/previews/018-forest.gif +0 -0
  20. package/huemagic/animations/previews/019-christmas.gif +0 -0
  21. package/huemagic/animations/previews/020-superhero.gif +0 -0
  22. package/huemagic/animations/previews/021-neoncity.gif +0 -0
  23. package/huemagic/hue-bridge-config.html +105 -61
  24. package/huemagic/hue-bridge-config.js +628 -319
  25. package/huemagic/hue-bridge.html +41 -21
  26. package/huemagic/hue-bridge.js +190 -396
  27. package/huemagic/hue-brightness.html +127 -59
  28. package/huemagic/hue-brightness.js +105 -55
  29. package/huemagic/hue-buttons.html +197 -0
  30. package/huemagic/hue-buttons.js +152 -0
  31. package/huemagic/hue-group.html +137 -66
  32. package/huemagic/hue-group.js +387 -403
  33. package/huemagic/hue-light.html +132 -64
  34. package/huemagic/hue-light.js +544 -378
  35. package/huemagic/hue-magic.html +36 -20
  36. package/huemagic/hue-magic.js +49 -27
  37. package/huemagic/hue-motion.html +127 -59
  38. package/huemagic/hue-motion.js +99 -101
  39. package/huemagic/hue-rules.html +121 -50
  40. package/huemagic/hue-rules.js +83 -63
  41. package/huemagic/hue-scene.html +95 -114
  42. package/huemagic/hue-scene.js +64 -95
  43. package/huemagic/hue-temperature.html +127 -59
  44. package/huemagic/hue-temperature.js +114 -56
  45. package/huemagic/icons/hue-bridge.png +0 -0
  46. package/huemagic/icons/hue-bridge.svg +3 -0
  47. package/huemagic/icons/hue-brightness.png +0 -0
  48. package/huemagic/icons/hue-brightness.svg +11 -0
  49. package/huemagic/icons/hue-buttons.png +0 -0
  50. package/huemagic/icons/hue-buttons.svg +4 -0
  51. package/huemagic/icons/hue-group.png +0 -0
  52. package/huemagic/icons/hue-group.svg +12 -0
  53. package/huemagic/icons/hue-light.png +0 -0
  54. package/huemagic/icons/hue-light.svg +3 -0
  55. package/huemagic/icons/hue-magic.png +0 -0
  56. package/huemagic/icons/hue-magic.svg +3 -0
  57. package/huemagic/icons/hue-motion.png +0 -0
  58. package/huemagic/icons/hue-motion.svg +9 -0
  59. package/huemagic/icons/hue-rules.png +0 -0
  60. package/huemagic/icons/hue-rules.svg +4 -0
  61. package/huemagic/icons/hue-scene.png +0 -0
  62. package/huemagic/icons/hue-scene.svg +5 -0
  63. package/huemagic/icons/hue-temperature.png +0 -0
  64. package/huemagic/icons/hue-temperature.svg +7 -0
  65. package/huemagic/locales/de/hue-bridge-config.html +17 -12
  66. package/huemagic/locales/de/hue-bridge-config.json +7 -5
  67. package/huemagic/locales/de/hue-bridge.html +64 -145
  68. package/huemagic/locales/de/hue-bridge.json +6 -17
  69. package/huemagic/locales/de/hue-brightness.html +50 -50
  70. package/huemagic/locales/de/hue-brightness.json +6 -5
  71. package/huemagic/locales/de/hue-buttons.html +58 -0
  72. package/huemagic/locales/de/{hue-button.json → hue-buttons.json} +7 -11
  73. package/huemagic/locales/de/hue-group.html +46 -122
  74. package/huemagic/locales/de/hue-group.json +5 -5
  75. package/huemagic/locales/de/hue-light.html +68 -116
  76. package/huemagic/locales/de/hue-light.json +5 -5
  77. package/huemagic/locales/de/hue-magic.html +65 -57
  78. package/huemagic/locales/de/hue-magic.json +2 -1
  79. package/huemagic/locales/de/hue-motion.html +47 -50
  80. package/huemagic/locales/de/hue-motion.json +5 -5
  81. package/huemagic/locales/de/hue-rules.html +68 -73
  82. package/huemagic/locales/de/hue-rules.json +5 -2
  83. package/huemagic/locales/de/hue-scene.html +23 -32
  84. package/huemagic/locales/de/hue-scene.json +5 -2
  85. package/huemagic/locales/de/hue-temperature.html +51 -48
  86. package/huemagic/locales/de/hue-temperature.json +6 -5
  87. package/huemagic/locales/en-US/hue-bridge-config.html +17 -12
  88. package/huemagic/locales/en-US/hue-bridge-config.json +5 -3
  89. package/huemagic/locales/en-US/hue-bridge.html +64 -145
  90. package/huemagic/locales/en-US/hue-bridge.json +5 -16
  91. package/huemagic/locales/en-US/hue-brightness.html +50 -50
  92. package/huemagic/locales/en-US/hue-brightness.json +5 -2
  93. package/huemagic/locales/en-US/hue-buttons.html +58 -0
  94. package/huemagic/locales/en-US/{hue-button.json → hue-buttons.json} +6 -4
  95. package/huemagic/locales/en-US/hue-group.html +46 -122
  96. package/huemagic/locales/en-US/hue-group.json +4 -2
  97. package/huemagic/locales/en-US/hue-light.html +68 -116
  98. package/huemagic/locales/en-US/hue-light.json +4 -2
  99. package/huemagic/locales/en-US/hue-magic.html +65 -57
  100. package/huemagic/locales/en-US/hue-magic.json +3 -1
  101. package/huemagic/locales/en-US/hue-motion.html +47 -50
  102. package/huemagic/locales/en-US/hue-motion.json +4 -2
  103. package/huemagic/locales/en-US/hue-rules.html +68 -73
  104. package/huemagic/locales/en-US/hue-rules.json +5 -2
  105. package/huemagic/locales/en-US/hue-scene.html +23 -32
  106. package/huemagic/locales/en-US/hue-scene.json +5 -2
  107. package/huemagic/locales/en-US/hue-temperature.html +51 -48
  108. package/huemagic/locales/en-US/hue-temperature.json +5 -2
  109. package/huemagic/utils/api.js +290 -0
  110. package/huemagic/utils/color.js +382 -0
  111. package/{utils → huemagic/utils}/merge.js +4 -6
  112. package/huemagic/utils/messages.js +447 -0
  113. package/package.json +9 -15
  114. package/examples/Hue Button.json +0 -40
  115. package/examples/Hue Switch.json +0 -40
  116. package/examples/Hue Tap.json +0 -40
  117. package/huemagic/hue-button.html +0 -132
  118. package/huemagic/hue-button.js +0 -143
  119. package/huemagic/hue-switch.html +0 -132
  120. package/huemagic/hue-switch.js +0 -163
  121. package/huemagic/hue-tap.html +0 -132
  122. package/huemagic/hue-tap.js +0 -123
  123. package/huemagic/icons/hue-button.png +0 -0
  124. package/huemagic/icons/hue-switch.png +0 -0
  125. package/huemagic/icons/hue-tap.png +0 -0
  126. package/huemagic/locales/de/hue-button.html +0 -64
  127. package/huemagic/locales/de/hue-switch.html +0 -64
  128. package/huemagic/locales/de/hue-switch.json +0 -35
  129. package/huemagic/locales/de/hue-tap.html +0 -55
  130. package/huemagic/locales/de/hue-tap.json +0 -27
  131. package/huemagic/locales/en-US/hue-button.html +0 -64
  132. package/huemagic/locales/en-US/hue-switch.html +0 -64
  133. package/huemagic/locales/en-US/hue-switch.json +0 -35
  134. package/huemagic/locales/en-US/hue-tap.html +0 -55
  135. package/huemagic/locales/en-US/hue-tap.json +0 -27
  136. package/utils/color.js +0 -9
  137. package/utils/messages.js +0 -658
  138. 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
- }