@hurenkam/hue-services 0.6.2 → 0.6.4
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/.nyc_output/badbd0a1-e95b-4210-b112-988173b5b131.json +1 -0
- package/.nyc_output/processinfo/badbd0a1-e95b-4210-b112-988173b5b131.json +1 -0
- package/.nyc_output/processinfo/index.json +1 -1
- package/README.md +7 -2
- package/coverage/index.html +56 -11
- package/coverage/src/RestApi.js.html +1 -1
- package/coverage/src/clip/ClipApi.js.html +1 -1
- package/coverage/src/clip/Resource.js.html +1 -1
- package/coverage/src/clip/index.html +1 -1
- package/coverage/src/index.html +1 -1
- package/coverage/src/nodes/BaseNode.js.html +32 -32
- package/coverage/src/nodes/BridgeConfigNode.js.html +1 -1
- package/coverage/src/nodes/ButtonNode.js.html +1 -1
- package/coverage/src/nodes/DevicePowerNode.js.html +1 -1
- package/coverage/src/nodes/GroupedLightNode.js.html +1 -1
- package/coverage/src/nodes/LightLevelNode.js.html +1 -1
- package/coverage/src/nodes/LightNode.js.html +1 -1
- package/coverage/src/nodes/MotionNode.js.html +1 -1
- package/coverage/src/nodes/RelativeRotaryNode.js.html +1 -1
- package/coverage/src/nodes/ResourceNode.js.html +83 -47
- package/coverage/src/nodes/SceneNode.js.html +1 -1
- package/coverage/src/nodes/ServiceNode.js.html +1 -1
- package/coverage/src/nodes/TemperatureNode.js.html +1 -1
- package/coverage/src/nodes/ZigbeeConnectivityNode.js.html +1 -1
- package/coverage/src/nodes/index.html +18 -18
- package/package.json +3 -3
- package/src/nodes/ResourceNode.js +13 -0
- package/src/ui/BaseUI.js +1 -3
- package/src/ui/ResourceUI.js +7 -3
- package/src/ui/ServiceUI.js +9 -5
- package/test/ResourceNode_spec.js +53 -0
- package/.nyc_output/ecb1b16f-015c-458b-96d5-32cb9569c1e8.json +0 -1
- package/.nyc_output/processinfo/ecb1b16f-015c-458b-96d5-32cb9569c1e8.json +0 -1
|
@@ -109,7 +109,7 @@ module.exports = ServiceNode;
|
|
|
109
109
|
<div class='footer quiet pad2 space-top1 center small'>
|
|
110
110
|
Code coverage generated by
|
|
111
111
|
<a href="https://istanbul.js.org/" target="_blank" rel="noopener noreferrer">istanbul</a>
|
|
112
|
-
at
|
|
112
|
+
at 2023-02-03T22:21:29.454Z
|
|
113
113
|
</div>
|
|
114
114
|
<script src="../../prettify.js"></script>
|
|
115
115
|
<script>
|
|
@@ -187,7 +187,7 @@ module.exports = TemperatureNode;
|
|
|
187
187
|
<div class='footer quiet pad2 space-top1 center small'>
|
|
188
188
|
Code coverage generated by
|
|
189
189
|
<a href="https://istanbul.js.org/" target="_blank" rel="noopener noreferrer">istanbul</a>
|
|
190
|
-
at
|
|
190
|
+
at 2023-02-03T22:21:29.454Z
|
|
191
191
|
</div>
|
|
192
192
|
<script src="../../prettify.js"></script>
|
|
193
193
|
<script>
|
|
@@ -184,7 +184,7 @@ module.exports = ZigbeeConnectivityNode;
|
|
|
184
184
|
<div class='footer quiet pad2 space-top1 center small'>
|
|
185
185
|
Code coverage generated by
|
|
186
186
|
<a href="https://istanbul.js.org/" target="_blank" rel="noopener noreferrer">istanbul</a>
|
|
187
|
-
at
|
|
187
|
+
at 2023-02-03T22:21:29.454Z
|
|
188
188
|
</div>
|
|
189
189
|
<script src="../../prettify.js"></script>
|
|
190
190
|
<script>
|
|
@@ -23,30 +23,30 @@
|
|
|
23
23
|
<div class='clearfix'>
|
|
24
24
|
|
|
25
25
|
<div class='fl pad1y space-right2'>
|
|
26
|
-
<span class="strong">98.
|
|
26
|
+
<span class="strong">98.87% </span>
|
|
27
27
|
<span class="quiet">Statements</span>
|
|
28
|
-
<span class='fraction'>
|
|
28
|
+
<span class='fraction'>353/357</span>
|
|
29
29
|
</div>
|
|
30
30
|
|
|
31
31
|
|
|
32
32
|
<div class='fl pad1y space-right2'>
|
|
33
|
-
<span class="strong">
|
|
33
|
+
<span class="strong">99.13% </span>
|
|
34
34
|
<span class="quiet">Branches</span>
|
|
35
|
-
<span class='fraction'>
|
|
35
|
+
<span class='fraction'>115/116</span>
|
|
36
36
|
</div>
|
|
37
37
|
|
|
38
38
|
|
|
39
39
|
<div class='fl pad1y space-right2'>
|
|
40
|
-
<span class="strong">
|
|
40
|
+
<span class="strong">97.05% </span>
|
|
41
41
|
<span class="quiet">Functions</span>
|
|
42
|
-
<span class='fraction'>
|
|
42
|
+
<span class='fraction'>66/68</span>
|
|
43
43
|
</div>
|
|
44
44
|
|
|
45
45
|
|
|
46
46
|
<div class='fl pad1y space-right2'>
|
|
47
|
-
<span class="strong">98% </span>
|
|
47
|
+
<span class="strong">98.87% </span>
|
|
48
48
|
<span class="quiet">Lines</span>
|
|
49
|
-
<span class='fraction'>
|
|
49
|
+
<span class='fraction'>351/355</span>
|
|
50
50
|
</div>
|
|
51
51
|
|
|
52
52
|
|
|
@@ -215,17 +215,17 @@
|
|
|
215
215
|
|
|
216
216
|
<tr>
|
|
217
217
|
<td class="file high" data-value="ResourceNode.js"><a href="ResourceNode.js.html">ResourceNode.js</a></td>
|
|
218
|
-
<td data-value="
|
|
219
|
-
<div class="chart"><div class="cover-fill" style="width:
|
|
218
|
+
<td data-value="97.95" class="pic high">
|
|
219
|
+
<div class="chart"><div class="cover-fill" style="width: 97%"></div><div class="cover-empty" style="width: 3%"></div></div>
|
|
220
220
|
</td>
|
|
221
|
+
<td data-value="97.95" class="pct high">97.95%</td>
|
|
222
|
+
<td data-value="49" class="abs high">48/49</td>
|
|
223
|
+
<td data-value="100" class="pct high">100%</td>
|
|
224
|
+
<td data-value="20" class="abs high">20/20</td>
|
|
221
225
|
<td data-value="90.9" class="pct high">90.9%</td>
|
|
222
|
-
<td data-value="
|
|
223
|
-
<td data-value="
|
|
224
|
-
<td data-value="
|
|
225
|
-
<td data-value="88.88" class="pct high">88.88%</td>
|
|
226
|
-
<td data-value="9" class="abs high">8/9</td>
|
|
227
|
-
<td data-value="90.9" class="pct high">90.9%</td>
|
|
228
|
-
<td data-value="44" class="abs high">40/44</td>
|
|
226
|
+
<td data-value="11" class="abs high">10/11</td>
|
|
227
|
+
<td data-value="97.95" class="pct high">97.95%</td>
|
|
228
|
+
<td data-value="49" class="abs high">48/49</td>
|
|
229
229
|
</tr>
|
|
230
230
|
|
|
231
231
|
<tr>
|
|
@@ -296,7 +296,7 @@
|
|
|
296
296
|
<div class='footer quiet pad2 space-top1 center small'>
|
|
297
297
|
Code coverage generated by
|
|
298
298
|
<a href="https://istanbul.js.org/" target="_blank" rel="noopener noreferrer">istanbul</a>
|
|
299
|
-
at
|
|
299
|
+
at 2023-02-03T22:21:29.454Z
|
|
300
300
|
</div>
|
|
301
301
|
<script src="../../prettify.js"></script>
|
|
302
302
|
<script>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hurenkam/hue-services",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.4",
|
|
4
4
|
"description": "Custom node-red nodes for interfacing with philips hue devices",
|
|
5
5
|
"author": "Mark Hurenkamp",
|
|
6
6
|
"license": "Apache 2.0",
|
|
@@ -44,10 +44,10 @@
|
|
|
44
44
|
"access": "public"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
|
+
"mocha": "^10.1.0",
|
|
47
48
|
"node-red": "^2.2.3",
|
|
48
49
|
"node-red-node-test-helper": "^0.2.7",
|
|
49
|
-
"mocha": "^10.1.0",
|
|
50
50
|
"nyc": "^15.1.0",
|
|
51
|
-
"sinon": "^15.0.
|
|
51
|
+
"sinon": "^15.0.1"
|
|
52
52
|
}
|
|
53
53
|
}
|
|
@@ -40,6 +40,10 @@ class ResourceNode extends BaseNode {
|
|
|
40
40
|
instance.onUpdate(event);
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
+
if (this.startevent()==true) {
|
|
44
|
+
this.onStartup(resource.data())
|
|
45
|
+
}
|
|
46
|
+
|
|
43
47
|
this.resource().on('update',this.#onUpdate);
|
|
44
48
|
this.updateStatus();
|
|
45
49
|
}
|
|
@@ -59,10 +63,19 @@ class ResourceNode extends BaseNode {
|
|
|
59
63
|
return this.config.uuid;
|
|
60
64
|
}
|
|
61
65
|
|
|
66
|
+
startevent() {
|
|
67
|
+
return this.config.startevent;
|
|
68
|
+
}
|
|
69
|
+
|
|
62
70
|
bridge() {
|
|
63
71
|
return BaseNode.nodeAPI.nodes.getNode(this.config.bridge);
|
|
64
72
|
}
|
|
65
73
|
|
|
74
|
+
onStartup(event) {
|
|
75
|
+
this.#trace("onStartup()");
|
|
76
|
+
this.send({ payload: event });
|
|
77
|
+
}
|
|
78
|
+
|
|
66
79
|
onUpdate(event) {
|
|
67
80
|
this.#trace("onUpdate()");
|
|
68
81
|
this.send({ payload: event });
|
package/src/ui/BaseUI.js
CHANGED
|
@@ -75,9 +75,7 @@ export class BaseUI {
|
|
|
75
75
|
item.setAttribute("id","node-container-" + id);
|
|
76
76
|
item.innerHTML = '\
|
|
77
77
|
<div style="display: inline-flex; width: calc(100% - 105px)">\
|
|
78
|
-
<
|
|
79
|
-
<input type="checkbox" id="' + prefix + id +'" style="flex: 15px;">\
|
|
80
|
-
</div>\
|
|
78
|
+
<input type="checkbox" id="' + prefix + id +'" style="flex: 15px;">\
|
|
81
79
|
<span style="width: 100%; margin-left: 10px;">\
|
|
82
80
|
'+ label +'\
|
|
83
81
|
</span>\
|
package/src/ui/ResourceUI.js
CHANGED
|
@@ -8,9 +8,10 @@ export class ResourceUI extends BaseUI {
|
|
|
8
8
|
super(label,category);
|
|
9
9
|
console.log("ResourceUI.constructor()");
|
|
10
10
|
|
|
11
|
-
this.config.defaults.name =
|
|
12
|
-
this.config.defaults.bridge =
|
|
13
|
-
this.config.defaults.uuid =
|
|
11
|
+
this.config.defaults.name = { value:"" };
|
|
12
|
+
this.config.defaults.bridge = { type: "@hurenkam/hue-services/BridgeConfigNode", required: true };
|
|
13
|
+
this.config.defaults.uuid = { value:"", required: true };
|
|
14
|
+
this.config.defaults.startevent = { value: false };
|
|
14
15
|
|
|
15
16
|
this.config.inputs = 1;
|
|
16
17
|
this.config.color = "#EEEEEE";
|
|
@@ -29,6 +30,8 @@ Select the hue bridge for your device or resource.\n\n\
|
|
|
29
30
|
Select the device or service by UUID, you can toggle between search \
|
|
30
31
|
and manual input. The search will query the bridge for suitable devices \
|
|
31
32
|
and present them as a selection list.\n\n\
|
|
33
|
+
#### Send current state event at startup\n\
|
|
34
|
+
When this flag is enabled the node will send an event at startup with its initial state.\n\
|
|
32
35
|
";
|
|
33
36
|
return help;
|
|
34
37
|
}
|
|
@@ -38,6 +41,7 @@ and present them as a selection list.\n\n\
|
|
|
38
41
|
console.log("ResourceUI.ui()");
|
|
39
42
|
text += this.uiTextInput("bridge","Bridge");
|
|
40
43
|
text += this.uiSelectInput("uuid","UUID");
|
|
44
|
+
text += this.uiCheckboxInput("startevent","Send current state event at startup");
|
|
41
45
|
return text;
|
|
42
46
|
}
|
|
43
47
|
|
package/src/ui/ServiceUI.js
CHANGED
|
@@ -5,11 +5,12 @@ export class ServiceUI extends BaseUI {
|
|
|
5
5
|
super(label,category);
|
|
6
6
|
console.log("ServiceUI.constructor(",label,category,rtype,")");
|
|
7
7
|
|
|
8
|
-
this.config.defaults.name =
|
|
9
|
-
this.config.defaults.bridge =
|
|
10
|
-
this.config.defaults.rtype =
|
|
11
|
-
this.config.defaults.owner =
|
|
12
|
-
this.config.defaults.uuid =
|
|
8
|
+
this.config.defaults.name = { value:"" };
|
|
9
|
+
this.config.defaults.bridge = { type: "@hurenkam/hue-services/BridgeConfigNode", required: true };
|
|
10
|
+
this.config.defaults.rtype = { value:rtype, required: true };
|
|
11
|
+
this.config.defaults.owner = { value:"", required: true };
|
|
12
|
+
this.config.defaults.uuid = { value:"", required: true };
|
|
13
|
+
this.config.defaults.startevent = { value: false };
|
|
13
14
|
|
|
14
15
|
this.config.inputs = 1;
|
|
15
16
|
this.config.color = "#EEEEEE";
|
|
@@ -35,6 +36,8 @@ this field is hidden, and the one choice is automatically selected. \n\n\
|
|
|
35
36
|
If not, then it offers you a choice of either filling in the UUID of the service \
|
|
36
37
|
to be selected, or you can select one from the list which is offered. \
|
|
37
38
|
\n\n\
|
|
39
|
+
#### Send current state event at startup\n\
|
|
40
|
+
When this flag is enabled the node will send an event at startup with its initial state.\n\
|
|
38
41
|
";
|
|
39
42
|
return help;
|
|
40
43
|
}
|
|
@@ -47,6 +50,7 @@ to be selected, or you can select one from the list which is offered. \
|
|
|
47
50
|
text += this.uiSelectInput("rtype","Type");
|
|
48
51
|
text += this.uiSelectInput("owner","Owner");
|
|
49
52
|
text += this.uiSelectInput("uuid","UUID");
|
|
53
|
+
text += this.uiCheckboxInput("startevent","Send current state event at startup");
|
|
50
54
|
return text;
|
|
51
55
|
}
|
|
52
56
|
|
|
@@ -104,6 +104,38 @@ describe('Resource Node', function () {
|
|
|
104
104
|
});
|
|
105
105
|
});
|
|
106
106
|
|
|
107
|
+
it('should call onStartup() when start() is called and startevent() returns true', function (done) {
|
|
108
|
+
var flow = [{
|
|
109
|
+
id: "n1",
|
|
110
|
+
type: "ResourceNode",
|
|
111
|
+
}];
|
|
112
|
+
|
|
113
|
+
const fakeRequestStartup = sandbox.fake(() => {
|
|
114
|
+
return { requestStartup: function(resource) {} };
|
|
115
|
+
});
|
|
116
|
+
const fakeStartevent = sandbox.fake(() => {
|
|
117
|
+
return true;
|
|
118
|
+
});
|
|
119
|
+
const fakeOnStartup = sandbox.fake(() => {
|
|
120
|
+
done();
|
|
121
|
+
});
|
|
122
|
+
sandbox.replace(ResourceNode.prototype,'bridge',fakeRequestStartup);
|
|
123
|
+
sandbox.replace(ResourceNode.prototype,'startevent',fakeStartevent);
|
|
124
|
+
sandbox.replace(ResourceNode.prototype,'onStartup',fakeOnStartup);
|
|
125
|
+
|
|
126
|
+
helper.load(testnodes, flow, function () {
|
|
127
|
+
var n1 = helper.getNode("n1");
|
|
128
|
+
n1.start({
|
|
129
|
+
on: function(event,callback) {
|
|
130
|
+
assert.equal(event,'update');
|
|
131
|
+
},
|
|
132
|
+
data: function(event,callback) {
|
|
133
|
+
return { brightness: 100 };
|
|
134
|
+
}
|
|
135
|
+
});
|
|
136
|
+
});
|
|
137
|
+
});
|
|
138
|
+
|
|
107
139
|
it('should return resource provided in start(resource) call when resource() is called', function (done) {
|
|
108
140
|
var flow = [{
|
|
109
141
|
id: "n1",
|
|
@@ -153,6 +185,27 @@ describe('Resource Node', function () {
|
|
|
153
185
|
// Todo:
|
|
154
186
|
// - bridge()
|
|
155
187
|
|
|
188
|
+
it('should call send() when onStartup(event) is called', function (done) {
|
|
189
|
+
var uuid = "c9f1b449-d9de-41c6-8bd4-46368eedd447";
|
|
190
|
+
var flow = [{
|
|
191
|
+
id: "n1",
|
|
192
|
+
type: "ResourceNode",
|
|
193
|
+
wires: [["n2"]]
|
|
194
|
+
},{
|
|
195
|
+
id: "n2",
|
|
196
|
+
type: "helper"
|
|
197
|
+
}];
|
|
198
|
+
|
|
199
|
+
helper.load(testnodes, flow, function () {
|
|
200
|
+
var n1 = helper.getNode("n1");
|
|
201
|
+
var n2 = helper.getNode("n2");
|
|
202
|
+
n2.on("input", function (msg) {
|
|
203
|
+
done();
|
|
204
|
+
});
|
|
205
|
+
n1.onStartup({ name: "event" });
|
|
206
|
+
});
|
|
207
|
+
});
|
|
208
|
+
|
|
156
209
|
it('should call send() when onUpdate(event) is called', function (done) {
|
|
157
210
|
var uuid = "c9f1b449-d9de-41c6-8bd4-46368eedd447";
|
|
158
211
|
var flow = [{
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"parent":null,"pid":1610421,"argv":["/usr/bin/node","/home/hurenkam/Workspace/node-red-contrib-mh-hue/node_modules/.bin/mocha","test/**/BaseUI_spec.js"],"execArgv":[],"cwd":"/home/hurenkam/Workspace/node-red-contrib-mh-hue","time":1670929477202,"ppid":1610410,"coverageFilename":"/home/hurenkam/Workspace/node-red-contrib-mh-hue/.nyc_output/ecb1b16f-015c-458b-96d5-32cb9569c1e8.json","externalId":"","uuid":"ecb1b16f-015c-458b-96d5-32cb9569c1e8","files":[]}
|