node-red-contrib-huemagic 3.0.0 → 4.0.3
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/README.md +764 -603
- package/examples/Hue Bridge.json +189 -35
- package/examples/Hue Brightness.json +124 -14
- package/examples/Hue Buttons.json +88 -0
- package/examples/Hue Group.json +575 -63
- package/examples/Hue Light.json +805 -58
- package/examples/Hue Magic.json +69 -24
- package/examples/Hue Motion.json +110 -42
- package/examples/Hue Rules.json +105 -37
- package/examples/Hue Scene.json +145 -28
- package/examples/Hue Temperature.json +124 -14
- package/huemagic/animations/019-christmas.json +30 -0
- package/huemagic/animations/020-superhero.json +56 -0
- package/huemagic/animations/021-neoncity.json +52 -0
- package/huemagic/animations/previews/006-fireplace.gif +0 -0
- package/huemagic/animations/previews/013-strobo.gif +0 -0
- package/huemagic/animations/previews/014-randomrainbow.gif +0 -0
- package/huemagic/animations/previews/016-milkyway.gif +0 -0
- package/huemagic/animations/previews/018-forest.gif +0 -0
- package/huemagic/animations/previews/019-christmas.gif +0 -0
- package/huemagic/animations/previews/020-superhero.gif +0 -0
- package/huemagic/animations/previews/021-neoncity.gif +0 -0
- package/huemagic/hue-bridge-config.html +105 -61
- package/huemagic/hue-bridge-config.js +631 -319
- package/huemagic/hue-bridge.html +41 -21
- package/huemagic/hue-bridge.js +190 -396
- package/huemagic/hue-brightness.html +127 -59
- package/huemagic/hue-brightness.js +111 -55
- package/huemagic/hue-buttons.html +197 -0
- package/huemagic/hue-buttons.js +158 -0
- package/huemagic/hue-group.html +137 -66
- package/huemagic/hue-group.js +387 -403
- package/huemagic/hue-light.html +132 -64
- package/huemagic/hue-light.js +544 -378
- package/huemagic/hue-magic.html +36 -20
- package/huemagic/hue-magic.js +49 -27
- package/huemagic/hue-motion.html +127 -59
- package/huemagic/hue-motion.js +105 -101
- package/huemagic/hue-rules.html +121 -50
- package/huemagic/hue-rules.js +89 -63
- package/huemagic/hue-scene.html +95 -114
- package/huemagic/hue-scene.js +64 -95
- package/huemagic/hue-temperature.html +127 -59
- package/huemagic/hue-temperature.js +120 -56
- package/huemagic/icons/hue-bridge.png +0 -0
- package/huemagic/icons/hue-bridge.svg +3 -0
- package/huemagic/icons/hue-brightness.png +0 -0
- package/huemagic/icons/hue-brightness.svg +11 -0
- package/huemagic/icons/hue-buttons.png +0 -0
- package/huemagic/icons/hue-buttons.svg +4 -0
- package/huemagic/icons/hue-group.png +0 -0
- package/huemagic/icons/hue-group.svg +12 -0
- package/huemagic/icons/hue-light.png +0 -0
- package/huemagic/icons/hue-light.svg +3 -0
- package/huemagic/icons/hue-magic.png +0 -0
- package/huemagic/icons/hue-magic.svg +3 -0
- package/huemagic/icons/hue-motion.png +0 -0
- package/huemagic/icons/hue-motion.svg +9 -0
- package/huemagic/icons/hue-rules.png +0 -0
- package/huemagic/icons/hue-rules.svg +4 -0
- package/huemagic/icons/hue-scene.png +0 -0
- package/huemagic/icons/hue-scene.svg +5 -0
- package/huemagic/icons/hue-temperature.png +0 -0
- package/huemagic/icons/hue-temperature.svg +7 -0
- package/huemagic/locales/de/hue-bridge-config.html +17 -12
- package/huemagic/locales/de/hue-bridge-config.json +7 -5
- package/huemagic/locales/de/hue-bridge.html +64 -145
- package/huemagic/locales/de/hue-bridge.json +6 -17
- package/huemagic/locales/de/hue-brightness.html +50 -50
- package/huemagic/locales/de/hue-brightness.json +6 -5
- package/huemagic/locales/de/hue-buttons.html +58 -0
- package/huemagic/locales/de/{hue-button.json → hue-buttons.json} +7 -11
- package/huemagic/locales/de/hue-group.html +46 -122
- package/huemagic/locales/de/hue-group.json +5 -5
- package/huemagic/locales/de/hue-light.html +68 -116
- package/huemagic/locales/de/hue-light.json +5 -5
- package/huemagic/locales/de/hue-magic.html +65 -57
- package/huemagic/locales/de/hue-magic.json +2 -1
- package/huemagic/locales/de/hue-motion.html +47 -50
- package/huemagic/locales/de/hue-motion.json +5 -5
- package/huemagic/locales/de/hue-rules.html +68 -73
- package/huemagic/locales/de/hue-rules.json +5 -2
- package/huemagic/locales/de/hue-scene.html +23 -32
- package/huemagic/locales/de/hue-scene.json +5 -2
- package/huemagic/locales/de/hue-temperature.html +51 -48
- package/huemagic/locales/de/hue-temperature.json +6 -5
- package/huemagic/locales/en-US/hue-bridge-config.html +17 -12
- package/huemagic/locales/en-US/hue-bridge-config.json +5 -3
- package/huemagic/locales/en-US/hue-bridge.html +64 -145
- package/huemagic/locales/en-US/hue-bridge.json +5 -16
- package/huemagic/locales/en-US/hue-brightness.html +50 -50
- package/huemagic/locales/en-US/hue-brightness.json +5 -2
- package/huemagic/locales/en-US/hue-buttons.html +58 -0
- package/huemagic/locales/en-US/{hue-button.json → hue-buttons.json} +6 -4
- package/huemagic/locales/en-US/hue-group.html +46 -122
- package/huemagic/locales/en-US/hue-group.json +4 -2
- package/huemagic/locales/en-US/hue-light.html +68 -116
- package/huemagic/locales/en-US/hue-light.json +4 -2
- package/huemagic/locales/en-US/hue-magic.html +65 -57
- package/huemagic/locales/en-US/hue-magic.json +3 -1
- package/huemagic/locales/en-US/hue-motion.html +47 -50
- package/huemagic/locales/en-US/hue-motion.json +4 -2
- package/huemagic/locales/en-US/hue-rules.html +68 -73
- package/huemagic/locales/en-US/hue-rules.json +5 -2
- package/huemagic/locales/en-US/hue-scene.html +23 -32
- package/huemagic/locales/en-US/hue-scene.json +5 -2
- package/huemagic/locales/en-US/hue-temperature.html +51 -48
- package/huemagic/locales/en-US/hue-temperature.json +5 -2
- package/huemagic/utils/api.js +290 -0
- package/huemagic/utils/color.js +382 -0
- package/{utils → huemagic/utils}/merge.js +4 -6
- package/huemagic/utils/messages.js +447 -0
- package/package.json +9 -15
- package/examples/Hue Button.json +0 -40
- package/examples/Hue Switch.json +0 -40
- package/examples/Hue Tap.json +0 -40
- package/huemagic/hue-button.html +0 -132
- package/huemagic/hue-button.js +0 -143
- package/huemagic/hue-switch.html +0 -132
- package/huemagic/hue-switch.js +0 -163
- package/huemagic/hue-tap.html +0 -132
- package/huemagic/hue-tap.js +0 -123
- package/huemagic/icons/hue-button.png +0 -0
- package/huemagic/icons/hue-switch.png +0 -0
- package/huemagic/icons/hue-tap.png +0 -0
- package/huemagic/locales/de/hue-button.html +0 -64
- package/huemagic/locales/de/hue-switch.html +0 -64
- package/huemagic/locales/de/hue-switch.json +0 -35
- package/huemagic/locales/de/hue-tap.html +0 -55
- package/huemagic/locales/de/hue-tap.json +0 -27
- package/huemagic/locales/en-US/hue-button.html +0 -64
- package/huemagic/locales/en-US/hue-switch.html +0 -64
- package/huemagic/locales/en-US/hue-switch.json +0 -35
- package/huemagic/locales/en-US/hue-tap.html +0 -55
- package/huemagic/locales/en-US/hue-tap.json +0 -27
- package/utils/color.js +0 -9
- package/utils/messages.js +0 -658
- package/utils/rgb.js +0 -188
package/huemagic/hue-light.html
CHANGED
|
@@ -1,38 +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-
|
|
13
|
-
<div style="
|
|
14
|
-
<input type="text" id="node-input-lightid" placeholder="
|
|
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
|
-
<
|
|
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
|
-
</
|
|
18
|
+
</button>
|
|
19
19
|
</div>
|
|
20
20
|
</div>
|
|
21
|
-
<div class="form-row">
|
|
22
|
-
<
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
</
|
|
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>
|
|
25
|
+
</div>
|
|
26
26
|
</div>
|
|
27
27
|
<div class="form-row">
|
|
28
|
-
<
|
|
29
|
-
|
|
30
|
-
|
|
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>
|
|
31
32
|
</div>
|
|
32
33
|
<div class="form-row">
|
|
33
|
-
<
|
|
34
|
-
|
|
35
|
-
|
|
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>
|
|
36
38
|
</div>
|
|
37
39
|
</script>
|
|
38
40
|
|
|
@@ -41,96 +43,162 @@
|
|
|
41
43
|
category: 'HueMagic',
|
|
42
44
|
color: '#47c0e8',
|
|
43
45
|
defaults: {
|
|
44
|
-
name: {value:""},
|
|
45
|
-
bridge: {type: "hue-bridge", required: true},
|
|
46
|
-
lightid: {value:"", required: false,
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
}},
|
|
51
|
-
colornamer: {value: true},
|
|
52
|
-
skipevents: {value: false},
|
|
53
|
-
universalevents: {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 }
|
|
54
52
|
},
|
|
53
|
+
align: 'left',
|
|
54
|
+
icon: "hue-light.png",
|
|
55
55
|
inputs: 1,
|
|
56
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
|
+
},
|
|
57
63
|
inputLabels: function() {
|
|
58
64
|
return this._("hue-light.node.input");
|
|
59
65
|
},
|
|
60
66
|
outputLabels: function() {
|
|
61
67
|
return this._("hue-light.node.output");
|
|
62
68
|
},
|
|
63
|
-
align: 'right',
|
|
64
|
-
icon: "hue-light.png",
|
|
65
|
-
paletteLabel: function() {
|
|
66
|
-
return this._("hue-light.node.title");
|
|
67
|
-
},
|
|
68
|
-
label: function() {
|
|
69
|
-
return this.name || this._("hue-light.node.title");
|
|
70
|
-
},
|
|
71
69
|
oneditprepare: function()
|
|
72
70
|
{
|
|
73
|
-
|
|
71
|
+
const scope = this;
|
|
72
|
+
let options = [];
|
|
74
73
|
|
|
75
|
-
function
|
|
74
|
+
function manualInput()
|
|
76
75
|
{
|
|
76
|
+
// GET CURRENT SELECTED VALUE
|
|
77
77
|
var current = $('#node-input-lightid').val();
|
|
78
|
-
|
|
79
|
-
|
|
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");
|
|
80
90
|
}
|
|
81
91
|
|
|
82
|
-
function
|
|
92
|
+
function searchAndSelect()
|
|
83
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
|
|
84
99
|
var current = $('#node-input-lightid').val();
|
|
85
|
-
$('#node-input-lightid').replaceWith('<select id="node-input-lightid" style="width: 100%"></select>');
|
|
86
|
-
$('#node-input-lightid').append('<option selected="selected" value="null">'+scope._("hue-light.config.searching")+'</option>');
|
|
87
100
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
.done(function(data) {
|
|
91
|
-
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 });
|
|
92
103
|
|
|
93
|
-
|
|
104
|
+
// GET THE LIGHTS
|
|
105
|
+
$.get('hue/resources', { bridge: bridgeConfig.bridge, key: bridgeConfig.key, type: "light" })
|
|
106
|
+
.done( function(data) {
|
|
107
|
+
var allResources = JSON.parse(data);
|
|
108
|
+
if(allResources.length <= 0)
|
|
94
109
|
{
|
|
95
|
-
|
|
110
|
+
notification.close();
|
|
111
|
+
RED.notify(scope._("hue-light.config.none-found"), { type: "error" });
|
|
112
|
+
return false;
|
|
96
113
|
}
|
|
97
114
|
|
|
98
|
-
//
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
// SET LIGHTS AS OPTIONS
|
|
102
|
-
lightBulbs.forEach(function(light)
|
|
115
|
+
// SET OPTIONS
|
|
116
|
+
allResources.forEach(function(resource)
|
|
103
117
|
{
|
|
104
|
-
|
|
118
|
+
if(resource.model)
|
|
119
|
+
{
|
|
120
|
+
options[resource.id] = { value: resource.id, label: resource.name + " ("+resource.model+")" };
|
|
121
|
+
}
|
|
122
|
+
else
|
|
123
|
+
{
|
|
124
|
+
options[resource.id] = { value: resource.id, label: resource.name };
|
|
125
|
+
}
|
|
105
126
|
});
|
|
106
127
|
|
|
107
128
|
// SELECT CURRENT VALUE
|
|
108
|
-
$(
|
|
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();
|
|
109
146
|
})
|
|
110
147
|
.fail(function()
|
|
111
148
|
{
|
|
149
|
+
notification.close();
|
|
112
150
|
RED.notify(scope._("hue-light.config.unknown-error"), "error");
|
|
113
151
|
});
|
|
114
152
|
}
|
|
115
153
|
|
|
116
|
-
|
|
154
|
+
// CHANGED LIGHT ID? -> REPLACE NAME (IF POSSIBLE)
|
|
155
|
+
$(document).on('change', '#node-input-lightid', function(e)
|
|
117
156
|
{
|
|
118
|
-
|
|
119
|
-
|
|
157
|
+
let currentSelectedOptionID = $(e.currentTarget).val();
|
|
158
|
+
let currentSelectedOptionValue = (currentSelectedOptionID.length > 0 && options[currentSelectedOptionID]) ? options[currentSelectedOptionID].label : false;
|
|
159
|
+
|
|
160
|
+
if(currentSelectedOptionValue !== false)
|
|
120
161
|
{
|
|
121
|
-
$('#node-input-name').val(
|
|
162
|
+
$('#node-input-name').val(currentSelectedOptionValue.split(" (")[0]);
|
|
122
163
|
}
|
|
123
164
|
});
|
|
124
165
|
|
|
166
|
+
// TOGGLE SELECT/INPUT FIELD
|
|
125
167
|
$('#node-config-input-scan-lights').click(function()
|
|
126
168
|
{
|
|
127
|
-
if($('#
|
|
169
|
+
if($('#input-select-toggle').find(".red-ui-typedInput-container").length > 0)
|
|
170
|
+
{
|
|
171
|
+
manualInput();
|
|
172
|
+
}
|
|
173
|
+
else
|
|
128
174
|
{
|
|
129
|
-
|
|
130
|
-
} else {
|
|
131
|
-
manualLightID();
|
|
175
|
+
searchAndSelect();
|
|
132
176
|
}
|
|
133
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
|
+
}
|
|
134
202
|
}
|
|
135
203
|
});
|
|
136
204
|
</script>
|