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
|
@@ -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-
|
|
9
|
-
<div style="
|
|
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
|
-
<
|
|
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
|
-
</
|
|
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-
|
|
20
|
-
<div style="
|
|
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
|
-
<
|
|
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
|
-
</
|
|
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
|
-
<
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
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
|
-
|
|
48
|
-
|
|
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
|
-
|
|
62
|
+
const scope = this;
|
|
63
|
+
let options = [];
|
|
66
64
|
|
|
67
|
-
function
|
|
65
|
+
function manualInput()
|
|
68
66
|
{
|
|
67
|
+
// GET CURRENT SELECTED VALUE
|
|
69
68
|
var current = $('#node-config-input-bridge').val();
|
|
70
|
-
|
|
71
|
-
|
|
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
|
|
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
|
-
|
|
94
|
+
var allResources = JSON.parse(data);
|
|
95
|
+
if(allResources.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
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
102
|
+
// SET OPTIONS
|
|
103
|
+
allResources.forEach(function(resource)
|
|
104
|
+
{
|
|
105
|
+
options[resource.ip] = { value: resource.ip, label: resource.ip };
|
|
106
|
+
});
|
|
88
107
|
|
|
89
|
-
|
|
90
|
-
|
|
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
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
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
|
-
|
|
99
|
-
|
|
124
|
+
// CLOSE SEARCH NOTIFICATION
|
|
125
|
+
notification.close();
|
|
100
126
|
})
|
|
101
127
|
.fail(function()
|
|
102
128
|
{
|
|
103
|
-
|
|
129
|
+
notification.close();
|
|
130
|
+
RED.notify(scope._("hue-bridge-config.config.unknown-error"), "error");
|
|
104
131
|
});
|
|
105
132
|
}
|
|
106
133
|
|
|
107
|
-
|
|
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
|
-
|
|
110
|
-
if(currentBridgeIP.length >
|
|
138
|
+
let currentBridgeIP = $(e.currentTarget).val();
|
|
139
|
+
if(currentBridgeIP.length > 3)
|
|
111
140
|
{
|
|
112
|
-
|
|
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
|
-
|
|
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($('#
|
|
168
|
+
if($('#input-select-toggle').find(".red-ui-typedInput-container").length > 0)
|
|
169
|
+
{
|
|
170
|
+
manualInput();
|
|
171
|
+
}
|
|
172
|
+
else
|
|
127
173
|
{
|
|
128
|
-
|
|
129
|
-
} else {
|
|
130
|
-
manualBridgeIP();
|
|
174
|
+
searchAndSelect();
|
|
131
175
|
}
|
|
132
176
|
});
|
|
133
177
|
|