smart-nodes 0.5.1 → 0.6.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.
- package/CHANGELOG.md +11 -1
- package/SmartNodesContext.json +1 -0
- package/__tests__/compare.test.js +57 -0
- package/__tests__/counter.test.js +54 -0
- package/__tests__/forwarder.test.js +54 -0
- package/__tests__/heating-curve.test.js +54 -0
- package/__tests__/hysteresis.test.js +54 -0
- package/__tests__/light.test.js +49 -0
- package/__tests__/logic.test.js +61 -0
- package/__tests__/long-press.test.js +54 -0
- package/__tests__/mixing-valve.test.js +54 -0
- package/__tests__/mode-selector.test.js +54 -0
- package/__tests__/multi-press.test.js +54 -0
- package/__tests__/scene.test.js +54 -0
- package/__tests__/scheduler.test.js +54 -0
- package/__tests__/shutter-complex.test.js +54 -0
- package/__tests__/shutter.test.js +54 -0
- package/__tests__/statistics.test.js +54 -0
- package/__tests__/test-helper.js +40 -0
- package/__tests__/text-exec.test.js +54 -0
- package/forwarder/forwarder.js +16 -13
- package/heating-curve/heating-curve.html +5 -5
- package/jest.config.js +5 -0
- package/light/light.js +7 -1
- package/mixing-valve/locales/de-DE/mixing-valve.html +6 -0
- package/mixing-valve/locales/de-DE/mixing-valve.json +2 -0
- package/mixing-valve/locales/en-US/mixing-valve.html +6 -0
- package/mixing-valve/locales/en-US/mixing-valve.json +2 -0
- package/mixing-valve/mixing-valve.html +20 -2
- package/mixing-valve/mixing-valve.js +120 -29
- package/package.json +8 -4
- package/persistence.js +38 -8
- package/smart_helper.js +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -213,4 +213,14 @@
|
|
|
213
213
|
|
|
214
214
|
## Version 0.5.1:
|
|
215
215
|
|
|
216
|
-
- To be more compatible, topic "set" is also possible instead of "set_state". Same for "set_inverted" instead of "set_state_inverted".
|
|
216
|
+
- To be more compatible, topic "set" is also possible instead of "set_state". Same for "set_inverted" instead of "set_state_inverted".
|
|
217
|
+
|
|
218
|
+
## Version 0.5.2:
|
|
219
|
+
|
|
220
|
+
- Added alarm mode to mixing-valve.
|
|
221
|
+
|
|
222
|
+
## Version 0.6.0:
|
|
223
|
+
|
|
224
|
+
- Reduced amount of messages sent by light node when it is in alarm mode.
|
|
225
|
+
- Fixed forwarder node causing an error when no topic was sent.
|
|
226
|
+
- Added Jest example for all nodes to be able to debug nodes in vscode.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"idn1":{"temperature_outside":10,"last_flow_temperature":null}}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
const th = require("./test-helper");
|
|
2
|
+
const helper = th.helper;
|
|
3
|
+
const nodeModule = require("../compare/compare.js");
|
|
4
|
+
|
|
5
|
+
const nodeType = "smart_compare";
|
|
6
|
+
|
|
7
|
+
th.init();
|
|
8
|
+
|
|
9
|
+
test("compare", (done) =>
|
|
10
|
+
{
|
|
11
|
+
const flow = [
|
|
12
|
+
{
|
|
13
|
+
id: "n1",
|
|
14
|
+
type: nodeType,
|
|
15
|
+
name: "test-compare",
|
|
16
|
+
comparator: "SMALLER",
|
|
17
|
+
value1: 5,
|
|
18
|
+
value2: 9,
|
|
19
|
+
wires: [["n2"]]
|
|
20
|
+
},
|
|
21
|
+
{ id: "n2", type: "helper" }
|
|
22
|
+
];
|
|
23
|
+
|
|
24
|
+
helper.load(nodeModule, flow, () =>
|
|
25
|
+
{
|
|
26
|
+
try
|
|
27
|
+
{
|
|
28
|
+
const n1 = helper.getNode("n1");
|
|
29
|
+
const n2 = helper.getNode("n2");
|
|
30
|
+
|
|
31
|
+
if (!n1) return done(new Error("Node n1 wurde nicht erstellt"));
|
|
32
|
+
if (!n2) return done(new Error("Helper-Node n2 fehlt"));
|
|
33
|
+
|
|
34
|
+
n2.on("input", (msg) =>
|
|
35
|
+
{
|
|
36
|
+
try
|
|
37
|
+
{
|
|
38
|
+
console.log("Received:", msg);
|
|
39
|
+
expect(msg).toBeDefined();
|
|
40
|
+
}
|
|
41
|
+
catch (err)
|
|
42
|
+
{
|
|
43
|
+
done(err);
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
n1.receive({ topic: "1", payload: 7 });
|
|
48
|
+
n1.receive({ topic: "1", payload: 17 });
|
|
49
|
+
|
|
50
|
+
setImmediate(() => { done(); });
|
|
51
|
+
}
|
|
52
|
+
catch (err)
|
|
53
|
+
{
|
|
54
|
+
done(err);
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
});
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
const th = require("./test-helper");
|
|
2
|
+
const helper = th.helper;
|
|
3
|
+
const nodeModule = require("../counter/counter.js");
|
|
4
|
+
|
|
5
|
+
const nodeType = "smart_counter";
|
|
6
|
+
|
|
7
|
+
th.init();
|
|
8
|
+
|
|
9
|
+
test("counter", (done) =>
|
|
10
|
+
{
|
|
11
|
+
const flow = [
|
|
12
|
+
{
|
|
13
|
+
id: "n1",
|
|
14
|
+
type: nodeType,
|
|
15
|
+
name: "test-counter",
|
|
16
|
+
wires: [["n2"]]
|
|
17
|
+
},
|
|
18
|
+
{ id: "n2", type: "helper" }
|
|
19
|
+
];
|
|
20
|
+
|
|
21
|
+
helper.load(nodeModule, flow, () =>
|
|
22
|
+
{
|
|
23
|
+
try
|
|
24
|
+
{
|
|
25
|
+
const n1 = helper.getNode("n1");
|
|
26
|
+
const n2 = helper.getNode("n2");
|
|
27
|
+
|
|
28
|
+
if (!n1) return done(new Error("Node n1 wurde nicht erstellt"));
|
|
29
|
+
if (!n2) return done(new Error("Helper-Node n2 fehlt"));
|
|
30
|
+
|
|
31
|
+
n2.on("input", (msg) =>
|
|
32
|
+
{
|
|
33
|
+
try
|
|
34
|
+
{
|
|
35
|
+
console.log("Received:", msg);
|
|
36
|
+
expect(msg).toBeDefined();
|
|
37
|
+
}
|
|
38
|
+
catch (err)
|
|
39
|
+
{
|
|
40
|
+
done(err);
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
n1.receive({ topic: "1", payload: 7 });
|
|
45
|
+
n1.receive({ topic: "1", payload: 17 });
|
|
46
|
+
|
|
47
|
+
setImmediate(() => { done(); });
|
|
48
|
+
}
|
|
49
|
+
catch (err)
|
|
50
|
+
{
|
|
51
|
+
done(err);
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
});
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
const th = require("./test-helper");
|
|
2
|
+
const helper = th.helper;
|
|
3
|
+
const nodeModule = require("../forwarder/forwarder.js");
|
|
4
|
+
|
|
5
|
+
const nodeType = "smart_forwarder";
|
|
6
|
+
|
|
7
|
+
th.init();
|
|
8
|
+
|
|
9
|
+
test("forwarder", (done) =>
|
|
10
|
+
{
|
|
11
|
+
const flow = [
|
|
12
|
+
{
|
|
13
|
+
id: "n1",
|
|
14
|
+
type: nodeType,
|
|
15
|
+
name: "test-forwarder",
|
|
16
|
+
wires: [["n2"]]
|
|
17
|
+
},
|
|
18
|
+
{ id: "n2", type: "helper" }
|
|
19
|
+
];
|
|
20
|
+
|
|
21
|
+
helper.load(nodeModule, flow, () =>
|
|
22
|
+
{
|
|
23
|
+
try
|
|
24
|
+
{
|
|
25
|
+
const n1 = helper.getNode("n1");
|
|
26
|
+
const n2 = helper.getNode("n2");
|
|
27
|
+
|
|
28
|
+
if (!n1) return done(new Error("Node n1 wurde nicht erstellt"));
|
|
29
|
+
if (!n2) return done(new Error("Helper-Node n2 fehlt"));
|
|
30
|
+
|
|
31
|
+
n2.on("input", (msg) =>
|
|
32
|
+
{
|
|
33
|
+
try
|
|
34
|
+
{
|
|
35
|
+
console.log("Received:", msg);
|
|
36
|
+
expect(msg).toBeDefined();
|
|
37
|
+
}
|
|
38
|
+
catch (err)
|
|
39
|
+
{
|
|
40
|
+
done(err);
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
n1.receive({ topic: "1", payload: 7 });
|
|
45
|
+
n1.receive({ topic: "1", payload: 17 });
|
|
46
|
+
|
|
47
|
+
setImmediate(() => { done(); });
|
|
48
|
+
}
|
|
49
|
+
catch (err)
|
|
50
|
+
{
|
|
51
|
+
done(err);
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
});
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
const th = require("./test-helper");
|
|
2
|
+
const helper = th.helper;
|
|
3
|
+
const nodeModule = require("../heating-curve/heating-curve.js");
|
|
4
|
+
|
|
5
|
+
const nodeType = "smart_heating-curve";
|
|
6
|
+
|
|
7
|
+
th.init();
|
|
8
|
+
|
|
9
|
+
test("heating-curve", (done) =>
|
|
10
|
+
{
|
|
11
|
+
const flow = [
|
|
12
|
+
{
|
|
13
|
+
id: "n1",
|
|
14
|
+
type: nodeType,
|
|
15
|
+
name: "test-heating-curve",
|
|
16
|
+
wires: [["n2"]]
|
|
17
|
+
},
|
|
18
|
+
{ id: "n2", type: "helper" }
|
|
19
|
+
];
|
|
20
|
+
|
|
21
|
+
helper.load(nodeModule, flow, () =>
|
|
22
|
+
{
|
|
23
|
+
try
|
|
24
|
+
{
|
|
25
|
+
const n1 = helper.getNode("n1");
|
|
26
|
+
const n2 = helper.getNode("n2");
|
|
27
|
+
|
|
28
|
+
if (!n1) return done(new Error("Node n1 wurde nicht erstellt"));
|
|
29
|
+
if (!n2) return done(new Error("Helper-Node n2 fehlt"));
|
|
30
|
+
|
|
31
|
+
n2.on("input", (msg) =>
|
|
32
|
+
{
|
|
33
|
+
try
|
|
34
|
+
{
|
|
35
|
+
console.log("Received:", msg);
|
|
36
|
+
expect(msg).toBeDefined();
|
|
37
|
+
}
|
|
38
|
+
catch (err)
|
|
39
|
+
{
|
|
40
|
+
done(err);
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
n1.receive({ topic: "1", payload: 7 });
|
|
45
|
+
n1.receive({ topic: "1", payload: 17 });
|
|
46
|
+
|
|
47
|
+
setImmediate(() => { done(); });
|
|
48
|
+
}
|
|
49
|
+
catch (err)
|
|
50
|
+
{
|
|
51
|
+
done(err);
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
});
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
const th = require("./test-helper");
|
|
2
|
+
const helper = th.helper;
|
|
3
|
+
const nodeModule = require("../hysteresis/hysteresis.js");
|
|
4
|
+
|
|
5
|
+
const nodeType = "smart_hysteresis";
|
|
6
|
+
|
|
7
|
+
th.init();
|
|
8
|
+
|
|
9
|
+
test("hysteresis", (done) =>
|
|
10
|
+
{
|
|
11
|
+
const flow = [
|
|
12
|
+
{
|
|
13
|
+
id: "n1",
|
|
14
|
+
type: nodeType,
|
|
15
|
+
name: "test-hysteresis",
|
|
16
|
+
wires: [["n2"]]
|
|
17
|
+
},
|
|
18
|
+
{ id: "n2", type: "helper" }
|
|
19
|
+
];
|
|
20
|
+
|
|
21
|
+
helper.load(nodeModule, flow, () =>
|
|
22
|
+
{
|
|
23
|
+
try
|
|
24
|
+
{
|
|
25
|
+
const n1 = helper.getNode("n1");
|
|
26
|
+
const n2 = helper.getNode("n2");
|
|
27
|
+
|
|
28
|
+
if (!n1) return done(new Error("Node n1 wurde nicht erstellt"));
|
|
29
|
+
if (!n2) return done(new Error("Helper-Node n2 fehlt"));
|
|
30
|
+
|
|
31
|
+
n2.on("input", (msg) =>
|
|
32
|
+
{
|
|
33
|
+
try
|
|
34
|
+
{
|
|
35
|
+
console.log("Received:", msg);
|
|
36
|
+
expect(msg).toBeDefined();
|
|
37
|
+
}
|
|
38
|
+
catch (err)
|
|
39
|
+
{
|
|
40
|
+
done(err);
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
n1.receive({ topic: "1", payload: 7 });
|
|
45
|
+
n1.receive({ topic: "1", payload: 17 });
|
|
46
|
+
|
|
47
|
+
setImmediate(() => { done(); });
|
|
48
|
+
}
|
|
49
|
+
catch (err)
|
|
50
|
+
{
|
|
51
|
+
done(err);
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
});
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
const th = require("./test-helper");
|
|
2
|
+
const helper = th.helper;
|
|
3
|
+
const nodeModule = require("../light/light.js");
|
|
4
|
+
|
|
5
|
+
const nodeType = "smart_light-control";
|
|
6
|
+
|
|
7
|
+
th.init();
|
|
8
|
+
|
|
9
|
+
test("light node", (done) =>
|
|
10
|
+
{
|
|
11
|
+
const flow = [
|
|
12
|
+
{ id: "n1", type: nodeType, name: "test-light", wires: [["n2"]] },
|
|
13
|
+
{ id: "n2", type: "helper" }
|
|
14
|
+
];
|
|
15
|
+
|
|
16
|
+
helper.load(nodeModule, flow, () =>
|
|
17
|
+
{
|
|
18
|
+
try
|
|
19
|
+
{
|
|
20
|
+
const n1 = helper.getNode("n1");
|
|
21
|
+
const n2 = helper.getNode("n2");
|
|
22
|
+
|
|
23
|
+
if (!n1) return done(new Error("Node n1 wurde nicht erstellt"));
|
|
24
|
+
if (!n2) return done(new Error("Helper-Node n2 fehlt"));
|
|
25
|
+
|
|
26
|
+
n2.on("input", (msg) =>
|
|
27
|
+
{
|
|
28
|
+
try
|
|
29
|
+
{
|
|
30
|
+
console.log("Received:", msg);
|
|
31
|
+
expect(msg).toBeDefined();
|
|
32
|
+
}
|
|
33
|
+
catch (err)
|
|
34
|
+
{
|
|
35
|
+
done(err);
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
n1.receive({ topic: "toggle" });
|
|
40
|
+
n1.receive({ topic: "toggle" });
|
|
41
|
+
|
|
42
|
+
setImmediate(() => { done(); });
|
|
43
|
+
}
|
|
44
|
+
catch (err)
|
|
45
|
+
{
|
|
46
|
+
done(err);
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
});
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
const th = require("./test-helper");
|
|
2
|
+
const helper = th.helper;
|
|
3
|
+
const nodeModule = require("../logic/logic.js");
|
|
4
|
+
|
|
5
|
+
const nodeType = "smart_logic";
|
|
6
|
+
|
|
7
|
+
th.init();
|
|
8
|
+
|
|
9
|
+
test("logic", (done) =>
|
|
10
|
+
{
|
|
11
|
+
const flow = [
|
|
12
|
+
{
|
|
13
|
+
id: "n1",
|
|
14
|
+
type: nodeType,
|
|
15
|
+
name: "test-logic",
|
|
16
|
+
out_true: "{}",
|
|
17
|
+
out_true_type: "json",
|
|
18
|
+
out_false: "{}",
|
|
19
|
+
out_false_type: "json",
|
|
20
|
+
inverts: "",
|
|
21
|
+
send_only_change: true,
|
|
22
|
+
outputs: 1,
|
|
23
|
+
wires: [["n2"]]
|
|
24
|
+
},
|
|
25
|
+
{ id: "n2", type: "helper" }
|
|
26
|
+
];
|
|
27
|
+
|
|
28
|
+
helper.load(nodeModule, flow, () =>
|
|
29
|
+
{
|
|
30
|
+
try
|
|
31
|
+
{
|
|
32
|
+
const n1 = helper.getNode("n1");
|
|
33
|
+
const n2 = helper.getNode("n2");
|
|
34
|
+
|
|
35
|
+
if (!n1) return done(new Error("Node n1 wurde nicht erstellt"));
|
|
36
|
+
if (!n2) return done(new Error("Helper-Node n2 fehlt"));
|
|
37
|
+
|
|
38
|
+
n2.on("input", (msg) =>
|
|
39
|
+
{
|
|
40
|
+
try
|
|
41
|
+
{
|
|
42
|
+
console.log("Received:", msg);
|
|
43
|
+
expect(msg).toBeDefined();
|
|
44
|
+
}
|
|
45
|
+
catch (err)
|
|
46
|
+
{
|
|
47
|
+
done(err);
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
n1.receive({ topic: "1", payload: 7 });
|
|
52
|
+
n1.receive({ topic: "1", payload: 17 });
|
|
53
|
+
|
|
54
|
+
setImmediate(() => { done(); });
|
|
55
|
+
}
|
|
56
|
+
catch (err)
|
|
57
|
+
{
|
|
58
|
+
done(err);
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
});
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
const th = require("./test-helper");
|
|
2
|
+
const helper = th.helper;
|
|
3
|
+
const nodeModule = require("../long-press/long-press.js");
|
|
4
|
+
|
|
5
|
+
const nodeType = "smart_long-press-control";
|
|
6
|
+
|
|
7
|
+
th.init();
|
|
8
|
+
|
|
9
|
+
test("long-press", (done) =>
|
|
10
|
+
{
|
|
11
|
+
const flow = [
|
|
12
|
+
{
|
|
13
|
+
id: "n1",
|
|
14
|
+
type: nodeType,
|
|
15
|
+
name: "test-long-press",
|
|
16
|
+
wires: [["n2"]]
|
|
17
|
+
},
|
|
18
|
+
{ id: "n2", type: "helper" }
|
|
19
|
+
];
|
|
20
|
+
|
|
21
|
+
helper.load(nodeModule, flow, () =>
|
|
22
|
+
{
|
|
23
|
+
try
|
|
24
|
+
{
|
|
25
|
+
const n1 = helper.getNode("n1");
|
|
26
|
+
const n2 = helper.getNode("n2");
|
|
27
|
+
|
|
28
|
+
if (!n1) return done(new Error("Node n1 wurde nicht erstellt"));
|
|
29
|
+
if (!n2) return done(new Error("Helper-Node n2 fehlt"));
|
|
30
|
+
|
|
31
|
+
n2.on("input", (msg) =>
|
|
32
|
+
{
|
|
33
|
+
try
|
|
34
|
+
{
|
|
35
|
+
console.log("Received:", msg);
|
|
36
|
+
expect(msg).toBeDefined();
|
|
37
|
+
}
|
|
38
|
+
catch (err)
|
|
39
|
+
{
|
|
40
|
+
done(err);
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
n1.receive({ topic: "1", payload: 7 });
|
|
45
|
+
n1.receive({ topic: "1", payload: 17 });
|
|
46
|
+
|
|
47
|
+
setImmediate(() => { done(); });
|
|
48
|
+
}
|
|
49
|
+
catch (err)
|
|
50
|
+
{
|
|
51
|
+
done(err);
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
});
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
const th = require("./test-helper");
|
|
2
|
+
const helper = th.helper;
|
|
3
|
+
const nodeModule = require("../mixing-valve/mixing-valve.js");
|
|
4
|
+
|
|
5
|
+
const nodeType = "smart_mixing-valve";
|
|
6
|
+
|
|
7
|
+
th.init();
|
|
8
|
+
|
|
9
|
+
test("mixing-valve", (done) =>
|
|
10
|
+
{
|
|
11
|
+
const flow = [
|
|
12
|
+
{
|
|
13
|
+
id: "n1",
|
|
14
|
+
type: nodeType,
|
|
15
|
+
name: "test-mixing-valve",
|
|
16
|
+
wires: [["n2"]]
|
|
17
|
+
},
|
|
18
|
+
{ id: "n2", type: "helper" }
|
|
19
|
+
];
|
|
20
|
+
|
|
21
|
+
helper.load(nodeModule, flow, () =>
|
|
22
|
+
{
|
|
23
|
+
try
|
|
24
|
+
{
|
|
25
|
+
const n1 = helper.getNode("n1");
|
|
26
|
+
const n2 = helper.getNode("n2");
|
|
27
|
+
|
|
28
|
+
if (!n1) return done(new Error("Node n1 wurde nicht erstellt"));
|
|
29
|
+
if (!n2) return done(new Error("Helper-Node n2 fehlt"));
|
|
30
|
+
|
|
31
|
+
n2.on("input", (msg) =>
|
|
32
|
+
{
|
|
33
|
+
try
|
|
34
|
+
{
|
|
35
|
+
console.log("Received:", msg);
|
|
36
|
+
expect(msg).toBeDefined();
|
|
37
|
+
}
|
|
38
|
+
catch (err)
|
|
39
|
+
{
|
|
40
|
+
done(err);
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
n1.receive({ topic: "1", payload: 7 });
|
|
45
|
+
n1.receive({ topic: "1", payload: 17 });
|
|
46
|
+
|
|
47
|
+
setImmediate(() => { done(); });
|
|
48
|
+
}
|
|
49
|
+
catch (err)
|
|
50
|
+
{
|
|
51
|
+
done(err);
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
});
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
const th = require("./test-helper");
|
|
2
|
+
const helper = th.helper;
|
|
3
|
+
const nodeModule = require("../mode-selector/mode-selector.js");
|
|
4
|
+
|
|
5
|
+
const nodeType = "smart_mode-selector";
|
|
6
|
+
|
|
7
|
+
th.init();
|
|
8
|
+
|
|
9
|
+
test("mode-selector", (done) =>
|
|
10
|
+
{
|
|
11
|
+
const flow = [
|
|
12
|
+
{
|
|
13
|
+
id: "n1",
|
|
14
|
+
type: nodeType,
|
|
15
|
+
name: "test-mode-selector",
|
|
16
|
+
wires: [["n2"]]
|
|
17
|
+
},
|
|
18
|
+
{ id: "n2", type: "helper" }
|
|
19
|
+
];
|
|
20
|
+
|
|
21
|
+
helper.load(nodeModule, flow, () =>
|
|
22
|
+
{
|
|
23
|
+
try
|
|
24
|
+
{
|
|
25
|
+
const n1 = helper.getNode("n1");
|
|
26
|
+
const n2 = helper.getNode("n2");
|
|
27
|
+
|
|
28
|
+
if (!n1) return done(new Error("Node n1 wurde nicht erstellt"));
|
|
29
|
+
if (!n2) return done(new Error("Helper-Node n2 fehlt"));
|
|
30
|
+
|
|
31
|
+
n2.on("input", (msg) =>
|
|
32
|
+
{
|
|
33
|
+
try
|
|
34
|
+
{
|
|
35
|
+
console.log("Received:", msg);
|
|
36
|
+
expect(msg).toBeDefined();
|
|
37
|
+
}
|
|
38
|
+
catch (err)
|
|
39
|
+
{
|
|
40
|
+
done(err);
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
n1.receive({ topic: "1", payload: 7 });
|
|
45
|
+
n1.receive({ topic: "1", payload: 17 });
|
|
46
|
+
|
|
47
|
+
setImmediate(() => { done(); });
|
|
48
|
+
}
|
|
49
|
+
catch (err)
|
|
50
|
+
{
|
|
51
|
+
done(err);
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
});
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
const th = require("./test-helper");
|
|
2
|
+
const helper = th.helper;
|
|
3
|
+
const nodeModule = require("../multi-press/multi-press.js");
|
|
4
|
+
|
|
5
|
+
const nodeType = "smart_multi-press";
|
|
6
|
+
|
|
7
|
+
th.init();
|
|
8
|
+
|
|
9
|
+
test("multi-press", (done) =>
|
|
10
|
+
{
|
|
11
|
+
const flow = [
|
|
12
|
+
{
|
|
13
|
+
id: "n1",
|
|
14
|
+
type: nodeType,
|
|
15
|
+
name: "test-multi-press",
|
|
16
|
+
wires: [["n2"]]
|
|
17
|
+
},
|
|
18
|
+
{ id: "n2", type: "helper" }
|
|
19
|
+
];
|
|
20
|
+
|
|
21
|
+
helper.load(nodeModule, flow, () =>
|
|
22
|
+
{
|
|
23
|
+
try
|
|
24
|
+
{
|
|
25
|
+
const n1 = helper.getNode("n1");
|
|
26
|
+
const n2 = helper.getNode("n2");
|
|
27
|
+
|
|
28
|
+
if (!n1) return done(new Error("Node n1 wurde nicht erstellt"));
|
|
29
|
+
if (!n2) return done(new Error("Helper-Node n2 fehlt"));
|
|
30
|
+
|
|
31
|
+
n2.on("input", (msg) =>
|
|
32
|
+
{
|
|
33
|
+
try
|
|
34
|
+
{
|
|
35
|
+
console.log("Received:", msg);
|
|
36
|
+
expect(msg).toBeDefined();
|
|
37
|
+
}
|
|
38
|
+
catch (err)
|
|
39
|
+
{
|
|
40
|
+
done(err);
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
n1.receive({ topic: "1", payload: 7 });
|
|
45
|
+
n1.receive({ topic: "1", payload: 17 });
|
|
46
|
+
|
|
47
|
+
setImmediate(() => { done(); });
|
|
48
|
+
}
|
|
49
|
+
catch (err)
|
|
50
|
+
{
|
|
51
|
+
done(err);
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
});
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
const th = require("./test-helper");
|
|
2
|
+
const helper = th.helper;
|
|
3
|
+
const nodeModule = require("../scene/scene.js");
|
|
4
|
+
|
|
5
|
+
const nodeType = "smart_scene-control";
|
|
6
|
+
|
|
7
|
+
th.init();
|
|
8
|
+
|
|
9
|
+
test("scene", (done) =>
|
|
10
|
+
{
|
|
11
|
+
const flow = [
|
|
12
|
+
{
|
|
13
|
+
id: "n1",
|
|
14
|
+
type: nodeType,
|
|
15
|
+
name: "test-scene",
|
|
16
|
+
wires: [["n2"]]
|
|
17
|
+
},
|
|
18
|
+
{ id: "n2", type: "helper" }
|
|
19
|
+
];
|
|
20
|
+
|
|
21
|
+
helper.load(nodeModule, flow, () =>
|
|
22
|
+
{
|
|
23
|
+
try
|
|
24
|
+
{
|
|
25
|
+
const n1 = helper.getNode("n1");
|
|
26
|
+
const n2 = helper.getNode("n2");
|
|
27
|
+
|
|
28
|
+
if (!n1) return done(new Error("Node n1 wurde nicht erstellt"));
|
|
29
|
+
if (!n2) return done(new Error("Helper-Node n2 fehlt"));
|
|
30
|
+
|
|
31
|
+
n2.on("input", (msg) =>
|
|
32
|
+
{
|
|
33
|
+
try
|
|
34
|
+
{
|
|
35
|
+
console.log("Received:", msg);
|
|
36
|
+
expect(msg).toBeDefined();
|
|
37
|
+
}
|
|
38
|
+
catch (err)
|
|
39
|
+
{
|
|
40
|
+
done(err);
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
n1.receive({ topic: "1", payload: 7 });
|
|
45
|
+
n1.receive({ topic: "1", payload: 17 });
|
|
46
|
+
|
|
47
|
+
setImmediate(() => { done(); });
|
|
48
|
+
}
|
|
49
|
+
catch (err)
|
|
50
|
+
{
|
|
51
|
+
done(err);
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
});
|