node-red-contrib-power-saver 4.1.3 → 4.1.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/CHANGELOG.md +1 -1
- package/docs/.vuepress/client.js +7 -0
- package/docs/.vuepress/clientAppEnhance.js +1 -1
- package/docs/.vuepress/components/AdsenseAdd.vue +1 -1
- package/docs/.vuepress/config.js +31 -30
- package/docs/README.md +6 -0
- package/docs/changelog/README.md +4 -0
- package/docs/examples/example-grid-tariff-capacity-part.md +16 -5
- package/docs/privacy.md +17 -0
- package/examples/example-grid-tariff-capacity-flow.json +2 -2
- package/package.json +19 -18
- package/src/schedule-merger-functions.js +2 -1
- package/src/strategy-heat-capacitor-functions.js +38 -4
- package/src/strategy-heat-capacitor.html +2 -2
- package/src/strategy-heat-capacitor.js +94 -63
- package/test/commands-input-best-save.test.js +15 -15
- package/test/commands-input-lowest-price.test.js +15 -15
- package/test/commands-input-schedule-merger.test.js +11 -11
- package/test/data/heat-capacitor-prices-NaN-test.json +197 -0
- package/test/elvia.test.js +2 -2
- package/test/general-add-tariff-functions.test.js +6 -6
- package/test/general-add-tariff.test.js +7 -7
- package/test/mostSavedStrategy.test.js +17 -17
- package/test/receive-price-functions.test.js +9 -9
- package/test/receive-price.test.js +11 -11
- package/test/schedule-merger-functions.test.js +18 -28
- package/test/schedule-merger.test.js +17 -17
- package/test/send-config-input.test.js +13 -13
- package/test/strategy-best-save-overlap.test.js +2 -2
- package/test/strategy-best-save.test.js +28 -28
- package/test/strategy-fixed-schedule.test.js +5 -5
- package/test/strategy-heat-capacitor-node.test.js +115 -16
- package/test/strategy-heat-capacitor.test.js +8 -6
- package/test/strategy-lowest-price-3days.test.js +4 -4
- package/test/strategy-lowest-price-functions.test.js +13 -13
- package/test/strategy-lowest-price.test.js +34 -34
- package/test/utils.test.js +46 -45
|
@@ -26,77 +26,108 @@ module.exports = function (RED) {
|
|
|
26
26
|
});
|
|
27
27
|
|
|
28
28
|
this.on("input", function (msg) {
|
|
29
|
-
if (validateInput(node, msg))
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
if (msg.payload.config.hasOwnProperty("boostTempHeat"))
|
|
41
|
-
node.boostTempHeat = Number(msg.payload.config.boostTempHeat);
|
|
42
|
-
if (msg.payload.config.hasOwnProperty("boostTempCool"))
|
|
43
|
-
node.boostTempCool = Number(msg.payload.config.boostTempCool);
|
|
44
|
-
if (msg.payload.config.hasOwnProperty("minSavings"))
|
|
45
|
-
node.minSavings = Number(msg.payload.config.minSavings);
|
|
29
|
+
if (!validateInput(node, msg)) return;
|
|
30
|
+
if (!msg.hasOwnProperty("payload")) return;
|
|
31
|
+
|
|
32
|
+
if (msg.payload.hasOwnProperty("commands")) {
|
|
33
|
+
//Commands override input
|
|
34
|
+
if (node.hasOwnProperty("schedule")) {
|
|
35
|
+
//Do not execute if schedule is missing
|
|
36
|
+
if (msg.payload.hasOwnProperty("time")) {
|
|
37
|
+
node.dT = findTemp(msg.payload.time, node.schedule);
|
|
38
|
+
} else {
|
|
39
|
+
node.dT = findTemp(DateTime.now(), node.schedule);
|
|
46
40
|
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
if (node.hasOwnProperty("
|
|
51
|
-
node.
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
41
|
+
node.T = node.setpoint + node.dT;
|
|
42
|
+
if (msg.payload.commands.hasOwnProperty("sendSchedule")) {
|
|
43
|
+
// Send output if schedule exists
|
|
44
|
+
if (node.hasOwnProperty("schedule") && msg.payload.commands.sendSchedule == true) {
|
|
45
|
+
node.send([
|
|
46
|
+
null,
|
|
47
|
+
null,
|
|
48
|
+
{ payload: node.schedule },
|
|
49
|
+
{ payload: { setpoint_now: node.T, schedule: node.schedule.minimalSchedule } },
|
|
50
|
+
]);
|
|
55
51
|
}
|
|
56
52
|
}
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
node.schedule = runBuySellAlgorithm(
|
|
60
|
-
node.priceData,
|
|
61
|
-
node.timeHeat1C,
|
|
62
|
-
node.timeCool1C,
|
|
63
|
-
node.boostTempHeat,
|
|
64
|
-
node.boostTempCool,
|
|
65
|
-
node.maxTempAdjustment,
|
|
66
|
-
node.minSavings
|
|
67
|
-
);
|
|
68
|
-
|
|
69
|
-
if (msg.payload.hasOwnProperty("time")) {
|
|
70
|
-
node.dT = findTemp(msg.payload.time, node.schedule);
|
|
71
|
-
} else {
|
|
72
|
-
node.dT = findTemp(DateTime.now(), node.schedule);
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
node.T = node.setpoint + node.dT;
|
|
76
|
-
|
|
77
|
-
//Add config to statistics
|
|
78
|
-
node.schedule.config = {
|
|
79
|
-
timeHeat1C: node.timeHeat1C,
|
|
80
|
-
timeCool1C: node.timeCool1C,
|
|
81
|
-
setpoint: node.setpoint,
|
|
82
|
-
maxTempAdjustment: node.maxTempAdjustment,
|
|
83
|
-
boostTempHeat: node.boostTempHeat,
|
|
84
|
-
boostTempCool: node.boostTempCool,
|
|
85
|
-
minSavings: node.minSavings,
|
|
86
|
-
};
|
|
87
|
-
|
|
88
|
-
node.schedule.priceData = node.priceData;
|
|
89
|
-
node.schedule.time = DateTime.now().toISO();
|
|
90
|
-
node.schedule.version = version;
|
|
91
|
-
|
|
92
|
-
// Send output
|
|
53
|
+
if (msg.payload.commands.hasOwnProperty("sendOutput") && msg.payload.commands.sendOutput == true) {
|
|
54
|
+
// Send output if schedule exists
|
|
93
55
|
node.send([
|
|
94
56
|
{ payload: node.T, topic: "setpoint", time: node.schedule.time, version: version },
|
|
95
57
|
{ payload: node.dT, topic: "adjustment", time: node.schedule.time, version: version },
|
|
96
|
-
|
|
58
|
+
null,
|
|
59
|
+
null,
|
|
97
60
|
]);
|
|
98
61
|
}
|
|
99
62
|
}
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
// Using msg.payload.config to change specific properties
|
|
66
|
+
if (msg.payload.hasOwnProperty("config")) {
|
|
67
|
+
if (msg.payload.config.hasOwnProperty("timeHeat1C")) node.timeHeat1C = Number(msg.payload.config.timeHeat1C);
|
|
68
|
+
if (msg.payload.config.hasOwnProperty("timeCool1C")) node.timeCool1C = Number(msg.payload.config.timeCool1C);
|
|
69
|
+
if (msg.payload.config.hasOwnProperty("setpoint")) node.setpoint = Number(msg.payload.config.setpoint);
|
|
70
|
+
if (msg.payload.config.hasOwnProperty("maxTempAdjustment"))
|
|
71
|
+
node.maxTempAdjustment = Number(msg.payload.config.maxTempAdjustment);
|
|
72
|
+
if (msg.payload.config.hasOwnProperty("boostTempHeat"))
|
|
73
|
+
node.boostTempHeat = Number(msg.payload.config.boostTempHeat);
|
|
74
|
+
if (msg.payload.config.hasOwnProperty("boostTempCool"))
|
|
75
|
+
node.boostTempCool = Number(msg.payload.config.boostTempCool);
|
|
76
|
+
if (msg.payload.config.hasOwnProperty("minSavings")) node.minSavings = Number(msg.payload.config.minSavings);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
//merge pricedata to escape some midnight issues. Store max 72 hour history
|
|
80
|
+
if (msg.payload.hasOwnProperty("priceData")) {
|
|
81
|
+
if (node.hasOwnProperty("priceData")) {
|
|
82
|
+
node.priceData = mergePriceData(node.priceData, msg.payload.priceData);
|
|
83
|
+
if (node.priceData.length > 72) node.priceData = node.priceData.slice(-72);
|
|
84
|
+
} else {
|
|
85
|
+
node.priceData = msg.payload.priceData;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
if (node.hasOwnProperty("priceData")) {
|
|
90
|
+
node.schedule = runBuySellAlgorithm(
|
|
91
|
+
node.priceData,
|
|
92
|
+
node.timeHeat1C,
|
|
93
|
+
node.timeCool1C,
|
|
94
|
+
node.setpoint,
|
|
95
|
+
node.boostTempHeat,
|
|
96
|
+
node.boostTempCool,
|
|
97
|
+
node.maxTempAdjustment,
|
|
98
|
+
node.minSavings
|
|
99
|
+
);
|
|
100
|
+
|
|
101
|
+
if (msg.payload.hasOwnProperty("time")) {
|
|
102
|
+
node.dT = findTemp(msg.payload.time, node.schedule);
|
|
103
|
+
} else {
|
|
104
|
+
node.dT = findTemp(DateTime.now(), node.schedule);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
node.T = node.setpoint + node.dT;
|
|
108
|
+
|
|
109
|
+
//Add config to statistics
|
|
110
|
+
node.schedule.config = {
|
|
111
|
+
timeHeat1C: node.timeHeat1C,
|
|
112
|
+
timeCool1C: node.timeCool1C,
|
|
113
|
+
setpoint: node.setpoint,
|
|
114
|
+
maxTempAdjustment: node.maxTempAdjustment,
|
|
115
|
+
boostTempHeat: node.boostTempHeat,
|
|
116
|
+
boostTempCool: node.boostTempCool,
|
|
117
|
+
minSavings: node.minSavings,
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
node.schedule.priceData = node.priceData;
|
|
121
|
+
node.schedule.time = DateTime.now().toISO();
|
|
122
|
+
node.schedule.version = version;
|
|
123
|
+
|
|
124
|
+
// Send output
|
|
125
|
+
node.send([
|
|
126
|
+
{ payload: node.T, topic: "setpoint", time: node.schedule.time, version: version },
|
|
127
|
+
{ payload: node.dT, topic: "adjustment", time: node.schedule.time, version: version },
|
|
128
|
+
{ payload: node.schedule },
|
|
129
|
+
{ payload: { setpoint_now: node.T, schedule: node.schedule.minimalSchedule } },
|
|
130
|
+
]);
|
|
100
131
|
}
|
|
101
132
|
});
|
|
102
133
|
}
|
|
@@ -113,7 +144,7 @@ function mergePriceData(priceDataA, priceDataB) {
|
|
|
113
144
|
tempDict[e.start] = e.value;
|
|
114
145
|
});
|
|
115
146
|
|
|
116
|
-
|
|
147
|
+
const keys = Object.keys(tempDict);
|
|
117
148
|
keys.sort();
|
|
118
149
|
|
|
119
150
|
const res = Array(keys.length);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const expect = require("
|
|
1
|
+
const expect = require("chai").expect;
|
|
2
2
|
const cloneDeep = require("lodash.clonedeep");
|
|
3
3
|
const helper = require("node-red-node-test-helper");
|
|
4
4
|
const bestSave = require("../src/strategy-best-save.js");
|
|
@@ -31,11 +31,11 @@ describe("send command as input to best save", () => {
|
|
|
31
31
|
switch (pass) {
|
|
32
32
|
case 1:
|
|
33
33
|
pass++;
|
|
34
|
-
expect(equalPlan(result, msg.payload)).
|
|
34
|
+
expect(equalPlan(result, msg.payload)).to.equal(true);
|
|
35
35
|
n1.receive({ payload: { commands: { sendSchedule: true } } });
|
|
36
36
|
break;
|
|
37
37
|
case 2:
|
|
38
|
-
expect(equalPlan(result, msg.payload)).
|
|
38
|
+
expect(equalPlan(result, msg.payload)).to.equal(true);
|
|
39
39
|
done();
|
|
40
40
|
break;
|
|
41
41
|
}
|
|
@@ -57,22 +57,22 @@ describe("send command as input to best save", () => {
|
|
|
57
57
|
let countOn = 0;
|
|
58
58
|
let countOff = 0;
|
|
59
59
|
n2.on("input", function (msg) {
|
|
60
|
-
expect(equalPlan(result, msg.payload)).
|
|
60
|
+
expect(equalPlan(result, msg.payload)).to.equal(true);
|
|
61
61
|
n1.receive({ payload: { commands: { sendOutput: true }, time: "2021-10-11T11:00:05.000+02:00" } });
|
|
62
62
|
setTimeout(() => {
|
|
63
63
|
console.log("countOn = " + countOn + ", countOff = " + countOff);
|
|
64
|
-
expect(countOn).
|
|
65
|
-
expect(countOff).
|
|
64
|
+
expect(countOn).to.equal(1);
|
|
65
|
+
expect(countOff).to.equal(1);
|
|
66
66
|
done();
|
|
67
67
|
}, 50);
|
|
68
68
|
});
|
|
69
69
|
n3.on("input", function (msg) {
|
|
70
70
|
countOn++;
|
|
71
|
-
expect(msg).
|
|
71
|
+
expect(msg).to.have.deep.property("payload", true);
|
|
72
72
|
});
|
|
73
73
|
n4.on("input", function (msg) {
|
|
74
74
|
countOff++;
|
|
75
|
-
expect(msg).
|
|
75
|
+
expect(msg).to.have.deep.property("payload", false);
|
|
76
76
|
});
|
|
77
77
|
|
|
78
78
|
const payload = cloneDeep(prices);
|
|
@@ -87,7 +87,7 @@ describe("send command as input to best save", () => {
|
|
|
87
87
|
const n1 = helper.getNode("n1");
|
|
88
88
|
const n2 = helper.getNode("n2");
|
|
89
89
|
n2.on("input", function (msg) {
|
|
90
|
-
expect(equalPlan(result, msg.payload)).
|
|
90
|
+
expect(equalPlan(result, msg.payload)).to.equal(true);
|
|
91
91
|
n1.receive({ payload: { commands: { reset: true } } });
|
|
92
92
|
n1.warn.should.be.calledWithExactly("No price data");
|
|
93
93
|
done();
|
|
@@ -112,27 +112,27 @@ describe("send command as input to best save", () => {
|
|
|
112
112
|
switch (pass) {
|
|
113
113
|
case 1:
|
|
114
114
|
pass++;
|
|
115
|
-
expect(equalPlan(result, msg.payload)).
|
|
115
|
+
expect(equalPlan(result, msg.payload)).to.equal(true);
|
|
116
116
|
n1.receive({ payload: { commands: { replan: true }, time: "2021-10-11T00:00:05.000+02:00" } });
|
|
117
117
|
break;
|
|
118
118
|
case 2:
|
|
119
119
|
pass++;
|
|
120
|
-
expect(equalPlan(result, msg.payload)).
|
|
120
|
+
expect(equalPlan(result, msg.payload)).to.equal(true);
|
|
121
121
|
setTimeout(() => {
|
|
122
122
|
console.log("countOn = " + countOn + ", countOff = " + countOff);
|
|
123
|
-
expect(countOn).
|
|
124
|
-
expect(countOff).
|
|
123
|
+
expect(countOn).to.equal(0);
|
|
124
|
+
expect(countOff).to.equal(2);
|
|
125
125
|
done();
|
|
126
126
|
}, 50);
|
|
127
127
|
}
|
|
128
128
|
});
|
|
129
129
|
n3.on("input", function (msg) {
|
|
130
130
|
countOn++;
|
|
131
|
-
expect(msg).
|
|
131
|
+
expect(msg).to.have.deep.property("payload", true);
|
|
132
132
|
});
|
|
133
133
|
n4.on("input", function (msg) {
|
|
134
134
|
countOff++;
|
|
135
|
-
expect(msg).
|
|
135
|
+
expect(msg).to.have.deep.property("payload", false);
|
|
136
136
|
});
|
|
137
137
|
const payload = cloneDeep(prices);
|
|
138
138
|
payload.time = "2021-10-11T00:00:05.000+02:00";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const expect = require("
|
|
1
|
+
const expect = require("chai").expect;
|
|
2
2
|
const cloneDeep = require("lodash.clonedeep");
|
|
3
3
|
const helper = require("node-red-node-test-helper");
|
|
4
4
|
const lowestPrice = require("../src/strategy-lowest-price.js");
|
|
@@ -31,11 +31,11 @@ describe("send command as input to lowest price", () => {
|
|
|
31
31
|
switch (pass) {
|
|
32
32
|
case 1:
|
|
33
33
|
pass++;
|
|
34
|
-
expect(equalSchedule(result.schedule, msg.payload.schedule)).
|
|
34
|
+
expect(equalSchedule(result.schedule, msg.payload.schedule)).to.equal(true);
|
|
35
35
|
n1.receive({ payload: { commands: { sendSchedule: true } } });
|
|
36
36
|
break;
|
|
37
37
|
case 2:
|
|
38
|
-
expect(equalSchedule(result.schedule, msg.payload.schedule)).
|
|
38
|
+
expect(equalSchedule(result.schedule, msg.payload.schedule)).to.equal(true);
|
|
39
39
|
done();
|
|
40
40
|
break;
|
|
41
41
|
}
|
|
@@ -61,12 +61,12 @@ describe("send command as input to lowest price", () => {
|
|
|
61
61
|
switch (pass) {
|
|
62
62
|
case 1:
|
|
63
63
|
pass++;
|
|
64
|
-
expect(equalPlan(result, msg.payload)).
|
|
64
|
+
expect(equalPlan(result, msg.payload)).to.equal(true);
|
|
65
65
|
n1.receive({ payload: { commands: { sendOutput: true }, time: "2021-10-11T11:00:05.000+02:00" } });
|
|
66
66
|
setTimeout(() => {
|
|
67
67
|
console.log("countOn = " + countOn + ", countOff = " + countOff);
|
|
68
|
-
expect(countOn).
|
|
69
|
-
expect(countOff).
|
|
68
|
+
expect(countOn).to.equal(1);
|
|
69
|
+
expect(countOff).to.equal(1);
|
|
70
70
|
done();
|
|
71
71
|
}, 50);
|
|
72
72
|
break;
|
|
@@ -74,11 +74,11 @@ describe("send command as input to lowest price", () => {
|
|
|
74
74
|
});
|
|
75
75
|
n3.on("input", function (msg) {
|
|
76
76
|
countOn++;
|
|
77
|
-
expect(msg).
|
|
77
|
+
expect(msg).to.have.deep.property("payload", true);
|
|
78
78
|
});
|
|
79
79
|
n4.on("input", function (msg) {
|
|
80
80
|
countOff++;
|
|
81
|
-
expect(msg).
|
|
81
|
+
expect(msg).to.have.deep.property("payload", false);
|
|
82
82
|
});
|
|
83
83
|
|
|
84
84
|
const payload = cloneDeep(prices);
|
|
@@ -94,7 +94,7 @@ describe("send command as input to lowest price", () => {
|
|
|
94
94
|
const n1 = helper.getNode("n1");
|
|
95
95
|
const n2 = helper.getNode("n2");
|
|
96
96
|
n2.on("input", function (msg) {
|
|
97
|
-
expect(equalPlan(result, msg.payload)).
|
|
97
|
+
expect(equalPlan(result, msg.payload)).to.equal(true);
|
|
98
98
|
n1.receive({ payload: { commands: { reset: true } } });
|
|
99
99
|
n1.warn.should.be.calledWithExactly("No price data");
|
|
100
100
|
done();
|
|
@@ -119,27 +119,27 @@ describe("send command as input to lowest price", () => {
|
|
|
119
119
|
switch (pass) {
|
|
120
120
|
case 1:
|
|
121
121
|
pass++;
|
|
122
|
-
expect(equalPlan(result, msg.payload)).
|
|
122
|
+
expect(equalPlan(result, msg.payload)).to.equal(true);
|
|
123
123
|
n1.receive({ payload: { commands: { replan: true }, time: "2021-10-11T00:00:05.000+02:00" } });
|
|
124
124
|
break;
|
|
125
125
|
case 2:
|
|
126
126
|
pass++;
|
|
127
|
-
expect(equalPlan(result, msg.payload)).
|
|
127
|
+
expect(equalPlan(result, msg.payload)).to.equal(true);
|
|
128
128
|
setTimeout(() => {
|
|
129
129
|
console.log("countOn = " + countOn + ", countOff = " + countOff);
|
|
130
|
-
expect(countOn).
|
|
131
|
-
expect(countOff).
|
|
130
|
+
expect(countOn).to.equal(0);
|
|
131
|
+
expect(countOff).to.equal(2);
|
|
132
132
|
done();
|
|
133
133
|
}, 50);
|
|
134
134
|
}
|
|
135
135
|
});
|
|
136
136
|
n3.on("input", function (msg) {
|
|
137
137
|
countOn++;
|
|
138
|
-
expect(msg).
|
|
138
|
+
expect(msg).to.have.deep.property("payload", true);
|
|
139
139
|
});
|
|
140
140
|
n4.on("input", function (msg) {
|
|
141
141
|
countOff++;
|
|
142
|
-
expect(msg).
|
|
142
|
+
expect(msg).to.have.deep.property("payload", false);
|
|
143
143
|
});
|
|
144
144
|
const payload = cloneDeep(prices);
|
|
145
145
|
payload.time = "2021-10-11T00:00:05.000+02:00";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const expect = require("
|
|
1
|
+
const expect = require("chai").expect;
|
|
2
2
|
const cloneDeep = require("lodash.clonedeep");
|
|
3
3
|
const helper = require("node-red-node-test-helper");
|
|
4
4
|
const prices = require("./data/converted-prices.json");
|
|
@@ -30,12 +30,12 @@ describe("send command as input to schedule merger", () => {
|
|
|
30
30
|
switch (pass) {
|
|
31
31
|
case 1:
|
|
32
32
|
pass++;
|
|
33
|
-
expect(equalHours(someOn, msg.payload.hours, ["price", "onOff", "start"])).
|
|
33
|
+
expect(equalHours(someOn, msg.payload.hours, ["price", "onOff", "start"])).to.equal(true);
|
|
34
34
|
n1.warn.should.not.be.called;
|
|
35
35
|
n1.receive({ payload: { commands: { sendSchedule: true } } });
|
|
36
36
|
break;
|
|
37
37
|
case 2:
|
|
38
|
-
expect(equalHours(someOn, msg.payload.hours, ["price", "onOff", "start"])).
|
|
38
|
+
expect(equalHours(someOn, msg.payload.hours, ["price", "onOff", "start"])).to.equal(true);
|
|
39
39
|
done();
|
|
40
40
|
break;
|
|
41
41
|
}
|
|
@@ -59,13 +59,13 @@ describe("send command as input to schedule merger", () => {
|
|
|
59
59
|
switch (pass) {
|
|
60
60
|
case 1:
|
|
61
61
|
pass++;
|
|
62
|
-
expect(equalHours(someOn, msg.payload.hours, ["price", "onOff", "start"])).
|
|
62
|
+
expect(equalHours(someOn, msg.payload.hours, ["price", "onOff", "start"])).to.equal(true);
|
|
63
63
|
n1.warn.should.not.be.called;
|
|
64
64
|
n1.receive({ payload: { commands: { sendOutput: true }, time: "2021-06-20T01:05:00.000+02:00" } });
|
|
65
65
|
setTimeout(() => {
|
|
66
66
|
console.log("countOn = " + countOn + ", countOff = " + countOff);
|
|
67
|
-
expect(countOn).
|
|
68
|
-
expect(countOff).
|
|
67
|
+
expect(countOn).to.equal(1);
|
|
68
|
+
expect(countOff).to.equal(1);
|
|
69
69
|
done();
|
|
70
70
|
}, 50);
|
|
71
71
|
break;
|
|
@@ -73,11 +73,11 @@ describe("send command as input to schedule merger", () => {
|
|
|
73
73
|
});
|
|
74
74
|
n3.on("input", function (msg) {
|
|
75
75
|
countOn++;
|
|
76
|
-
expect(msg).
|
|
76
|
+
expect(msg).to.have.deep.property("payload", true);
|
|
77
77
|
});
|
|
78
78
|
n4.on("input", function (msg) {
|
|
79
79
|
countOff++;
|
|
80
|
-
expect(msg).
|
|
80
|
+
expect(msg).to.have.deep.property("payload", false);
|
|
81
81
|
});
|
|
82
82
|
|
|
83
83
|
n1.receive({ payload: makePayload("s1", someOn) });
|
|
@@ -90,7 +90,7 @@ describe("send command as input to schedule merger", () => {
|
|
|
90
90
|
const n1 = helper.getNode("n1");
|
|
91
91
|
const n2 = helper.getNode("n2");
|
|
92
92
|
n2.on("input", function (msg) {
|
|
93
|
-
expect(equalHours(someOn, msg.payload.hours, ["price", "onOff", "start"])).
|
|
93
|
+
expect(equalHours(someOn, msg.payload.hours, ["price", "onOff", "start"])).to.equal(true);
|
|
94
94
|
n1.warn.should.not.be.called;
|
|
95
95
|
n1.receive({ payload: { commands: { reset: true } } });
|
|
96
96
|
n1.warn.should.be.calledWithExactly("No schedule");
|
|
@@ -111,12 +111,12 @@ describe("send command as input to schedule merger", () => {
|
|
|
111
111
|
switch (pass) {
|
|
112
112
|
case 1:
|
|
113
113
|
pass++;
|
|
114
|
-
expect(equalHours(someOn, msg.payload.hours, ["price", "onOff", "start"])).
|
|
114
|
+
expect(equalHours(someOn, msg.payload.hours, ["price", "onOff", "start"])).to.equal(true);
|
|
115
115
|
n1.warn.should.not.be.called;
|
|
116
116
|
n1.receive({ payload: { commands: { replan: true }, time: "2021-06-19T00:00:00.000+02:00" } });
|
|
117
117
|
break;
|
|
118
118
|
case 2:
|
|
119
|
-
expect(equalHours(someOn, msg.payload.hours, ["price", "onOff", "start"])).
|
|
119
|
+
expect(equalHours(someOn, msg.payload.hours, ["price", "onOff", "start"])).to.equal(true);
|
|
120
120
|
done();
|
|
121
121
|
break;
|
|
122
122
|
}
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
{
|
|
2
|
+
"priceData": [
|
|
3
|
+
{
|
|
4
|
+
"value": 2.8995,
|
|
5
|
+
"start": "2022-12-05T00:00:00.000+01:00"
|
|
6
|
+
},
|
|
7
|
+
{
|
|
8
|
+
"value": 2.7094,
|
|
9
|
+
"start": "2022-12-05T01:00:00.000+01:00"
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
"value": 2.557,
|
|
13
|
+
"start": "2022-12-05T02:00:00.000+01:00"
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
"value": 2.5206,
|
|
17
|
+
"start": "2022-12-05T03:00:00.000+01:00"
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
"value": 2.3348,
|
|
21
|
+
"start": "2022-12-05T04:00:00.000+01:00"
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
"value": 3.4332,
|
|
25
|
+
"start": "2022-12-05T05:00:00.000+01:00"
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
"value": 3.6958,
|
|
29
|
+
"start": "2022-12-05T06:00:00.000+01:00"
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
"value": 4.1501,
|
|
33
|
+
"start": "2022-12-05T07:00:00.000+01:00"
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
"value": 4.0352,
|
|
37
|
+
"start": "2022-12-05T08:00:00.000+01:00"
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
"value": 4.1902,
|
|
41
|
+
"start": "2022-12-05T09:00:00.000+01:00"
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
"value": 4.3673,
|
|
45
|
+
"start": "2022-12-05T10:00:00.000+01:00"
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
"value": 4.5833,
|
|
49
|
+
"start": "2022-12-05T11:00:00.000+01:00"
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
"value": 4.5125,
|
|
53
|
+
"start": "2022-12-05T12:00:00.000+01:00"
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
"value": 4.4622,
|
|
57
|
+
"start": "2022-12-05T13:00:00.000+01:00"
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
"value": 4.6789,
|
|
61
|
+
"start": "2022-12-05T14:00:00.000+01:00"
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
"value": 5.6881,
|
|
65
|
+
"start": "2022-12-05T15:00:00.000+01:00"
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
"value": 5.8284,
|
|
69
|
+
"start": "2022-12-05T16:00:00.000+01:00"
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
"value": 6.1628,
|
|
73
|
+
"start": "2022-12-05T17:00:00.000+01:00"
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
"value": 5.8605,
|
|
77
|
+
"start": "2022-12-05T18:00:00.000+01:00"
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
"value": 5.7909,
|
|
81
|
+
"start": "2022-12-05T19:00:00.000+01:00"
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
"value": 5.3179,
|
|
85
|
+
"start": "2022-12-05T20:00:00.000+01:00"
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
"value": 4.23,
|
|
89
|
+
"start": "2022-12-05T21:00:00.000+01:00"
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
"value": 4.0314,
|
|
93
|
+
"start": "2022-12-05T22:00:00.000+01:00"
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
"value": 3.849,
|
|
97
|
+
"start": "2022-12-05T23:00:00.000+01:00"
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
"value": 2.7135,
|
|
101
|
+
"start": "2022-12-06T00:00:00.000+01:00"
|
|
102
|
+
},
|
|
103
|
+
{
|
|
104
|
+
"value": 2.0118,
|
|
105
|
+
"start": "2022-12-06T01:00:00.000+01:00"
|
|
106
|
+
},
|
|
107
|
+
{
|
|
108
|
+
"value": 1.3186,
|
|
109
|
+
"start": "2022-12-06T02:00:00.000+01:00"
|
|
110
|
+
},
|
|
111
|
+
{
|
|
112
|
+
"value": 1.345,
|
|
113
|
+
"start": "2022-12-06T03:00:00.000+01:00"
|
|
114
|
+
},
|
|
115
|
+
{
|
|
116
|
+
"value": 2.0138,
|
|
117
|
+
"start": "2022-12-06T04:00:00.000+01:00"
|
|
118
|
+
},
|
|
119
|
+
{
|
|
120
|
+
"value": 3.861,
|
|
121
|
+
"start": "2022-12-06T05:00:00.000+01:00"
|
|
122
|
+
},
|
|
123
|
+
{
|
|
124
|
+
"value": 4.1762,
|
|
125
|
+
"start": "2022-12-06T06:00:00.000+01:00"
|
|
126
|
+
},
|
|
127
|
+
{
|
|
128
|
+
"value": 6.2559,
|
|
129
|
+
"start": "2022-12-06T07:00:00.000+01:00"
|
|
130
|
+
},
|
|
131
|
+
{
|
|
132
|
+
"value": 6.1595,
|
|
133
|
+
"start": "2022-12-06T08:00:00.000+01:00"
|
|
134
|
+
},
|
|
135
|
+
{
|
|
136
|
+
"value": 6.2161,
|
|
137
|
+
"start": "2022-12-06T09:00:00.000+01:00"
|
|
138
|
+
},
|
|
139
|
+
{
|
|
140
|
+
"value": 6.2744,
|
|
141
|
+
"start": "2022-12-06T10:00:00.000+01:00"
|
|
142
|
+
},
|
|
143
|
+
{
|
|
144
|
+
"value": 6.2384,
|
|
145
|
+
"start": "2022-12-06T11:00:00.000+01:00"
|
|
146
|
+
},
|
|
147
|
+
{
|
|
148
|
+
"value": 6.2849,
|
|
149
|
+
"start": "2022-12-06T12:00:00.000+01:00"
|
|
150
|
+
},
|
|
151
|
+
{
|
|
152
|
+
"value": 6.1778,
|
|
153
|
+
"start": "2022-12-06T13:00:00.000+01:00"
|
|
154
|
+
},
|
|
155
|
+
{
|
|
156
|
+
"value": 6.3486,
|
|
157
|
+
"start": "2022-12-06T14:00:00.000+01:00"
|
|
158
|
+
},
|
|
159
|
+
{
|
|
160
|
+
"value": 6.2832,
|
|
161
|
+
"start": "2022-12-06T15:00:00.000+01:00"
|
|
162
|
+
},
|
|
163
|
+
{
|
|
164
|
+
"value": 6.3878,
|
|
165
|
+
"start": "2022-12-06T16:00:00.000+01:00"
|
|
166
|
+
},
|
|
167
|
+
{
|
|
168
|
+
"value": 6.6309,
|
|
169
|
+
"start": "2022-12-06T17:00:00.000+01:00"
|
|
170
|
+
},
|
|
171
|
+
{
|
|
172
|
+
"value": 6.2844,
|
|
173
|
+
"start": "2022-12-06T18:00:00.000+01:00"
|
|
174
|
+
},
|
|
175
|
+
{
|
|
176
|
+
"value": 5.799,
|
|
177
|
+
"start": "2022-12-06T19:00:00.000+01:00"
|
|
178
|
+
},
|
|
179
|
+
{
|
|
180
|
+
"value": 5.128,
|
|
181
|
+
"start": "2022-12-06T20:00:00.000+01:00"
|
|
182
|
+
},
|
|
183
|
+
{
|
|
184
|
+
"value": 4.4484,
|
|
185
|
+
"start": "2022-12-06T21:00:00.000+01:00"
|
|
186
|
+
},
|
|
187
|
+
{
|
|
188
|
+
"value": 4.1897,
|
|
189
|
+
"start": "2022-12-06T22:00:00.000+01:00"
|
|
190
|
+
},
|
|
191
|
+
{
|
|
192
|
+
"value": 3.7427,
|
|
193
|
+
"start": "2022-12-06T23:00:00.000+01:00"
|
|
194
|
+
}
|
|
195
|
+
],
|
|
196
|
+
"source": "Tibber"
|
|
197
|
+
}
|
package/test/elvia.test.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
const helper = require("node-red-node-test-helper");
|
|
2
2
|
const elviaAddTariff = require("../src/elvia/elvia-add-tariff.js");
|
|
3
3
|
const elviaConfig = require("../src/elvia/elvia-config.js");
|
|
4
|
-
const expect = require("
|
|
4
|
+
const expect = require("chai").expect;
|
|
5
5
|
|
|
6
6
|
helper.init(require.resolve("node-red"));
|
|
7
7
|
|
|
@@ -33,7 +33,7 @@ describe("ps-elvia-add-tariff node", function () {
|
|
|
33
33
|
];
|
|
34
34
|
helper.load([elviaAddTariff, elviaConfig], flow, function () {
|
|
35
35
|
const n1 = helper.getNode("n1");
|
|
36
|
-
expect(n1).
|
|
36
|
+
expect(n1).to.have.property("name", "test name");
|
|
37
37
|
done();
|
|
38
38
|
});
|
|
39
39
|
});
|