node-red-contrib-power-saver 3.0.2 → 3.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.
@@ -6,9 +6,15 @@ sidebar: "auto"
6
6
 
7
7
  List the most significant changes, starting in version 1.0.9.
8
8
 
9
+ ## 3.0.3
10
+
11
+ - Fix bug in lowest price strategy, when period ends at midnight.
12
+ - Fix labels for hours on, so they do not have leading zero.
13
+ - Fix so source should be visible in output 3.
14
+
9
15
  ## 3.0.2
10
16
 
11
- - Bugfix in Lowest Price node
17
+ - Bugfix in Lowest Price node (not successful)
12
18
 
13
19
  ## 3.0.1
14
20
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "node-red-contrib-power-saver",
3
- "version": "3.0.2",
3
+ "version": "3.0.3",
4
4
  "description": "A module for Node-RED that you can use to turn on and off a switch based on power prices",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -37,7 +37,7 @@ function handleStrategyInput(node, msg, doPlanning) {
37
37
  payload: {
38
38
  schedule: plan.schedule,
39
39
  hours: plan.hours,
40
- source: priceData.source,
40
+ source: msg.payload.source,
41
41
  config: effectiveConfig,
42
42
  },
43
43
  };
@@ -15,9 +15,9 @@ function getPriceData(node, msg) {
15
15
  }
16
16
 
17
17
  priceData = [...input.today, ...input.tomorrow];
18
- priceData.source = input.source;
18
+ const source = input.source;
19
19
  node.context().set("lastPriceData", priceData);
20
- return priceData;
20
+ return { priceData, source };
21
21
  }
22
22
 
23
23
  function validateMsg(node, msg) {
@@ -6,14 +6,14 @@ module.exports = function (RED) {
6
6
  const node = this;
7
7
 
8
8
  node.on("input", function (msg) {
9
- const priceData = getPriceData(node, msg);
9
+ const { priceData, source } = getPriceData(node, msg);
10
10
  if (!priceData) {
11
11
  // Set status failed
12
12
  return;
13
13
  }
14
14
 
15
15
  // Send output
16
- node.send({ payload: { priceData } });
16
+ node.send({ payload: { priceData, source } });
17
17
  });
18
18
  }
19
19
 
@@ -108,7 +108,7 @@
108
108
  {
109
109
  value: "hourson",
110
110
  options: (() => {
111
- const res = hours.map((h) => ({ value: h, label: h }));
111
+ const res = hours.map((h) => ({ value: "" + parseInt(h), label: "" + parseInt(h) }));
112
112
  res.push({ value: "24", label: "24" });
113
113
  return res;
114
114
  })(),
@@ -41,14 +41,14 @@ function doPlanning(node, _, priceData, _, dateDayBefore, _) {
41
41
  const periodStatus = [];
42
42
  const startIndexes = [];
43
43
  const endIndexes = [];
44
- let currentStatus = from < to ? "Outside" : "StartMissing";
44
+ let currentStatus = from < (to === 0 && to !== from ? 24 : to) ? "Outside" : "StartMissing";
45
45
  let hour;
46
46
  priceData.forEach((pd, i) => {
47
47
  hour = DateTime.fromISO(pd.start).hour;
48
48
  if (hour === to && to === from && currentStatus === "Inside") {
49
49
  endIndexes.push(i - 1);
50
50
  }
51
- if (hour === to && to !== from) {
51
+ if (hour === to && to !== from && i > 0) {
52
52
  currentStatus = "Outside";
53
53
  endIndexes.push(i - 1);
54
54
  }
@@ -1,4 +1,5 @@
1
1
  {
2
+ "source": "Tibber",
2
3
  "priceData": [
3
4
  {
4
5
  "value": 0.2494,
@@ -0,0 +1,197 @@
1
+ {
2
+ "source": "Tibber",
3
+ "priceData": [
4
+ {
5
+ "value": 0.4675,
6
+ "start": "2021-12-14T00:00:00.000+01:00"
7
+ },
8
+ {
9
+ "value": 0.4488,
10
+ "start": "2021-12-14T01:00:00.000+01:00"
11
+ },
12
+ {
13
+ "value": 0.4344,
14
+ "start": "2021-12-14T02:00:00.000+01:00"
15
+ },
16
+ {
17
+ "value": 0.4124,
18
+ "start": "2021-12-14T03:00:00.000+01:00"
19
+ },
20
+ {
21
+ "value": 0.413,
22
+ "start": "2021-12-14T04:00:00.000+01:00"
23
+ },
24
+ {
25
+ "value": 0.4232,
26
+ "start": "2021-12-14T05:00:00.000+01:00"
27
+ },
28
+ {
29
+ "value": 0.4,
30
+ "start": "2021-12-14T06:00:00.000+01:00"
31
+ },
32
+ {
33
+ "value": 0.4067,
34
+ "start": "2021-12-14T07:00:00.000+01:00"
35
+ },
36
+ {
37
+ "value": 0.504,
38
+ "start": "2021-12-14T08:00:00.000+01:00"
39
+ },
40
+ {
41
+ "value": 0.5341,
42
+ "start": "2021-12-14T09:00:00.000+01:00"
43
+ },
44
+ {
45
+ "value": 0.5179,
46
+ "start": "2021-12-14T10:00:00.000+01:00"
47
+ },
48
+ {
49
+ "value": 0.5375,
50
+ "start": "2021-12-14T11:00:00.000+01:00"
51
+ },
52
+ {
53
+ "value": 0.535,
54
+ "start": "2021-12-14T12:00:00.000+01:00"
55
+ },
56
+ {
57
+ "value": 0.5403,
58
+ "start": "2021-12-14T13:00:00.000+01:00"
59
+ },
60
+ {
61
+ "value": 0.5291,
62
+ "start": "2021-12-14T14:00:00.000+01:00"
63
+ },
64
+ {
65
+ "value": 0.5175,
66
+ "start": "2021-12-14T15:00:00.000+01:00"
67
+ },
68
+ {
69
+ "value": 0.4914,
70
+ "start": "2021-12-14T16:00:00.000+01:00"
71
+ },
72
+ {
73
+ "value": 0.4698,
74
+ "start": "2021-12-14T17:00:00.000+01:00"
75
+ },
76
+ {
77
+ "value": 0.4609,
78
+ "start": "2021-12-14T18:00:00.000+01:00"
79
+ },
80
+ {
81
+ "value": 0.4408,
82
+ "start": "2021-12-14T19:00:00.000+01:00"
83
+ },
84
+ {
85
+ "value": 0.4263,
86
+ "start": "2021-12-14T20:00:00.000+01:00"
87
+ },
88
+ {
89
+ "value": 0.3946,
90
+ "start": "2021-12-14T21:00:00.000+01:00"
91
+ },
92
+ {
93
+ "value": 0.3852,
94
+ "start": "2021-12-14T22:00:00.000+01:00"
95
+ },
96
+ {
97
+ "value": 0.373,
98
+ "start": "2021-12-14T23:00:00.000+01:00"
99
+ },
100
+ {
101
+ "value": 0.4675,
102
+ "start": "2021-12-15T00:00:00.000+01:00"
103
+ },
104
+ {
105
+ "value": 0.4488,
106
+ "start": "2021-12-15T01:00:00.000+01:00"
107
+ },
108
+ {
109
+ "value": 0.4344,
110
+ "start": "2021-12-15T02:00:00.000+01:00"
111
+ },
112
+ {
113
+ "value": 0.4124,
114
+ "start": "2021-12-15T03:00:00.000+01:00"
115
+ },
116
+ {
117
+ "value": 0.413,
118
+ "start": "2021-12-15T04:00:00.000+01:00"
119
+ },
120
+ {
121
+ "value": 0.4232,
122
+ "start": "2021-12-15T05:00:00.000+01:00"
123
+ },
124
+ {
125
+ "value": 0.4,
126
+ "start": "2021-12-15T06:00:00.000+01:00"
127
+ },
128
+ {
129
+ "value": 0.4067,
130
+ "start": "2021-12-15T07:00:00.000+01:00"
131
+ },
132
+ {
133
+ "value": 0.504,
134
+ "start": "2021-12-15T08:00:00.000+01:00"
135
+ },
136
+ {
137
+ "value": 0.5341,
138
+ "start": "2021-12-15T09:00:00.000+01:00"
139
+ },
140
+ {
141
+ "value": 0.5179,
142
+ "start": "2021-12-15T10:00:00.000+01:00"
143
+ },
144
+ {
145
+ "value": 0.5375,
146
+ "start": "2021-12-15T11:00:00.000+01:00"
147
+ },
148
+ {
149
+ "value": 0.535,
150
+ "start": "2021-12-15T12:00:00.000+01:00"
151
+ },
152
+ {
153
+ "value": 0.5403,
154
+ "start": "2021-12-15T13:00:00.000+01:00"
155
+ },
156
+ {
157
+ "value": 0.5291,
158
+ "start": "2021-12-15T14:00:00.000+01:00"
159
+ },
160
+ {
161
+ "value": 0.5175,
162
+ "start": "2021-12-15T15:00:00.000+01:00"
163
+ },
164
+ {
165
+ "value": 0.4914,
166
+ "start": "2021-12-15T16:00:00.000+01:00"
167
+ },
168
+ {
169
+ "value": 0.4698,
170
+ "start": "2021-12-15T17:00:00.000+01:00"
171
+ },
172
+ {
173
+ "value": 0.4609,
174
+ "start": "2021-12-15T18:00:00.000+01:00"
175
+ },
176
+ {
177
+ "value": 0.4408,
178
+ "start": "2021-12-15T19:00:00.000+01:00"
179
+ },
180
+ {
181
+ "value": 0.4263,
182
+ "start": "2021-12-15T20:00:00.000+01:00"
183
+ },
184
+ {
185
+ "value": 0.3946,
186
+ "start": "2021-12-15T21:00:00.000+01:00"
187
+ },
188
+ {
189
+ "value": 0.3852,
190
+ "start": "2021-12-15T22:00:00.000+01:00"
191
+ },
192
+ {
193
+ "value": 0.373,
194
+ "start": "2021-12-15T23:00:00.000+01:00"
195
+ }
196
+ ]
197
+ }
@@ -0,0 +1,101 @@
1
+ {
2
+ "source": "Tibber",
3
+ "priceData": [
4
+ {
5
+ "value": 0.4675,
6
+ "start": "2021-12-14T00:00:00.000+01:00"
7
+ },
8
+ {
9
+ "value": 0.4488,
10
+ "start": "2021-12-14T01:00:00.000+01:00"
11
+ },
12
+ {
13
+ "value": 0.4344,
14
+ "start": "2021-12-14T02:00:00.000+01:00"
15
+ },
16
+ {
17
+ "value": 0.4124,
18
+ "start": "2021-12-14T03:00:00.000+01:00"
19
+ },
20
+ {
21
+ "value": 0.413,
22
+ "start": "2021-12-14T04:00:00.000+01:00"
23
+ },
24
+ {
25
+ "value": 0.4232,
26
+ "start": "2021-12-14T05:00:00.000+01:00"
27
+ },
28
+ {
29
+ "value": 0.4,
30
+ "start": "2021-12-14T06:00:00.000+01:00"
31
+ },
32
+ {
33
+ "value": 0.4067,
34
+ "start": "2021-12-14T07:00:00.000+01:00"
35
+ },
36
+ {
37
+ "value": 0.504,
38
+ "start": "2021-12-14T08:00:00.000+01:00"
39
+ },
40
+ {
41
+ "value": 0.5341,
42
+ "start": "2021-12-14T09:00:00.000+01:00"
43
+ },
44
+ {
45
+ "value": 0.5179,
46
+ "start": "2021-12-14T10:00:00.000+01:00"
47
+ },
48
+ {
49
+ "value": 0.5375,
50
+ "start": "2021-12-14T11:00:00.000+01:00"
51
+ },
52
+ {
53
+ "value": 0.535,
54
+ "start": "2021-12-14T12:00:00.000+01:00"
55
+ },
56
+ {
57
+ "value": 0.5403,
58
+ "start": "2021-12-14T13:00:00.000+01:00"
59
+ },
60
+ {
61
+ "value": 0.5291,
62
+ "start": "2021-12-14T14:00:00.000+01:00"
63
+ },
64
+ {
65
+ "value": 0.5175,
66
+ "start": "2021-12-14T15:00:00.000+01:00"
67
+ },
68
+ {
69
+ "value": 0.4914,
70
+ "start": "2021-12-14T16:00:00.000+01:00"
71
+ },
72
+ {
73
+ "value": 0.4698,
74
+ "start": "2021-12-14T17:00:00.000+01:00"
75
+ },
76
+ {
77
+ "value": 0.4609,
78
+ "start": "2021-12-14T18:00:00.000+01:00"
79
+ },
80
+ {
81
+ "value": 0.4408,
82
+ "start": "2021-12-14T19:00:00.000+01:00"
83
+ },
84
+ {
85
+ "value": 0.4263,
86
+ "start": "2021-12-14T20:00:00.000+01:00"
87
+ },
88
+ {
89
+ "value": 0.3946,
90
+ "start": "2021-12-14T21:00:00.000+01:00"
91
+ },
92
+ {
93
+ "value": 0.3852,
94
+ "start": "2021-12-14T22:00:00.000+01:00"
95
+ },
96
+ {
97
+ "value": 0.373,
98
+ "start": "2021-12-14T23:00:00.000+01:00"
99
+ }
100
+ ]
101
+ }
@@ -0,0 +1,320 @@
1
+ {
2
+ "schedule": [
3
+ {
4
+ "time": "2021-12-14T00:00:00.000+01:00",
5
+ "value": false
6
+ },
7
+ {
8
+ "time": "2021-12-14T21:00:00.000+01:00",
9
+ "value": true
10
+ },
11
+ {
12
+ "time": "2021-12-15T00:00:00.000+01:00",
13
+ "value": false
14
+ },
15
+ {
16
+ "time": "2021-12-15T21:00:00.000+01:00",
17
+ "value": true
18
+ }
19
+ ],
20
+ "hours": [
21
+ {
22
+ "price": 0.4675,
23
+ "onOff": false,
24
+ "start": "2021-12-14T00:00:00.000+01:00",
25
+ "saving": null
26
+ },
27
+ {
28
+ "price": 0.4488,
29
+ "onOff": false,
30
+ "start": "2021-12-14T01:00:00.000+01:00",
31
+ "saving": null
32
+ },
33
+ {
34
+ "price": 0.4344,
35
+ "onOff": false,
36
+ "start": "2021-12-14T02:00:00.000+01:00",
37
+ "saving": null
38
+ },
39
+ {
40
+ "price": 0.4124,
41
+ "onOff": false,
42
+ "start": "2021-12-14T03:00:00.000+01:00",
43
+ "saving": null
44
+ },
45
+ {
46
+ "price": 0.413,
47
+ "onOff": false,
48
+ "start": "2021-12-14T04:00:00.000+01:00",
49
+ "saving": null
50
+ },
51
+ {
52
+ "price": 0.4232,
53
+ "onOff": false,
54
+ "start": "2021-12-14T05:00:00.000+01:00",
55
+ "saving": null
56
+ },
57
+ {
58
+ "price": 0.4,
59
+ "onOff": false,
60
+ "start": "2021-12-14T06:00:00.000+01:00",
61
+ "saving": null
62
+ },
63
+ {
64
+ "price": 0.4067,
65
+ "onOff": false,
66
+ "start": "2021-12-14T07:00:00.000+01:00",
67
+ "saving": null
68
+ },
69
+ {
70
+ "price": 0.504,
71
+ "onOff": false,
72
+ "start": "2021-12-14T08:00:00.000+01:00",
73
+ "saving": null
74
+ },
75
+ {
76
+ "price": 0.5341,
77
+ "onOff": false,
78
+ "start": "2021-12-14T09:00:00.000+01:00",
79
+ "saving": null
80
+ },
81
+ {
82
+ "price": 0.5179,
83
+ "onOff": false,
84
+ "start": "2021-12-14T10:00:00.000+01:00",
85
+ "saving": null
86
+ },
87
+ {
88
+ "price": 0.5375,
89
+ "onOff": false,
90
+ "start": "2021-12-14T11:00:00.000+01:00",
91
+ "saving": null
92
+ },
93
+ {
94
+ "price": 0.535,
95
+ "onOff": false,
96
+ "start": "2021-12-14T12:00:00.000+01:00",
97
+ "saving": null
98
+ },
99
+ {
100
+ "price": 0.5403,
101
+ "onOff": false,
102
+ "start": "2021-12-14T13:00:00.000+01:00",
103
+ "saving": null
104
+ },
105
+ {
106
+ "price": 0.5291,
107
+ "onOff": false,
108
+ "start": "2021-12-14T14:00:00.000+01:00",
109
+ "saving": null
110
+ },
111
+ {
112
+ "price": 0.5175,
113
+ "onOff": false,
114
+ "start": "2021-12-14T15:00:00.000+01:00",
115
+ "saving": null
116
+ },
117
+ {
118
+ "price": 0.4914,
119
+ "onOff": false,
120
+ "start": "2021-12-14T16:00:00.000+01:00",
121
+ "saving": null
122
+ },
123
+ {
124
+ "price": 0.4698,
125
+ "onOff": false,
126
+ "start": "2021-12-14T17:00:00.000+01:00",
127
+ "saving": null
128
+ },
129
+ {
130
+ "price": 0.4609,
131
+ "onOff": false,
132
+ "start": "2021-12-14T18:00:00.000+01:00",
133
+ "saving": null
134
+ },
135
+ {
136
+ "price": 0.4408,
137
+ "onOff": false,
138
+ "start": "2021-12-14T19:00:00.000+01:00",
139
+ "saving": null
140
+ },
141
+ {
142
+ "price": 0.4263,
143
+ "onOff": false,
144
+ "start": "2021-12-14T20:00:00.000+01:00",
145
+ "saving": null
146
+ },
147
+ {
148
+ "price": 0.3946,
149
+ "onOff": true,
150
+ "start": "2021-12-14T21:00:00.000+01:00",
151
+ "saving": null
152
+ },
153
+ {
154
+ "price": 0.3852,
155
+ "onOff": true,
156
+ "start": "2021-12-14T22:00:00.000+01:00",
157
+ "saving": null
158
+ },
159
+ {
160
+ "price": 0.373,
161
+ "onOff": true,
162
+ "start": "2021-12-14T23:00:00.000+01:00",
163
+ "saving": null
164
+ },
165
+ {
166
+ "price": 0.4675,
167
+ "onOff": false,
168
+ "start": "2021-12-15T00:00:00.000+01:00",
169
+ "saving": null
170
+ },
171
+ {
172
+ "price": 0.4488,
173
+ "onOff": false,
174
+ "start": "2021-12-15T01:00:00.000+01:00",
175
+ "saving": null
176
+ },
177
+ {
178
+ "price": 0.4344,
179
+ "onOff": false,
180
+ "start": "2021-12-15T02:00:00.000+01:00",
181
+ "saving": null
182
+ },
183
+ {
184
+ "price": 0.4124,
185
+ "onOff": false,
186
+ "start": "2021-12-15T03:00:00.000+01:00",
187
+ "saving": null
188
+ },
189
+ {
190
+ "price": 0.413,
191
+ "onOff": false,
192
+ "start": "2021-12-15T04:00:00.000+01:00",
193
+ "saving": null
194
+ },
195
+ {
196
+ "price": 0.4232,
197
+ "onOff": false,
198
+ "start": "2021-12-15T05:00:00.000+01:00",
199
+ "saving": null
200
+ },
201
+ {
202
+ "price": 0.4,
203
+ "onOff": false,
204
+ "start": "2021-12-15T06:00:00.000+01:00",
205
+ "saving": null
206
+ },
207
+ {
208
+ "price": 0.4067,
209
+ "onOff": false,
210
+ "start": "2021-12-15T07:00:00.000+01:00",
211
+ "saving": null
212
+ },
213
+ {
214
+ "price": 0.504,
215
+ "onOff": false,
216
+ "start": "2021-12-15T08:00:00.000+01:00",
217
+ "saving": null
218
+ },
219
+ {
220
+ "price": 0.5341,
221
+ "onOff": false,
222
+ "start": "2021-12-15T09:00:00.000+01:00",
223
+ "saving": null
224
+ },
225
+ {
226
+ "price": 0.5179,
227
+ "onOff": false,
228
+ "start": "2021-12-15T10:00:00.000+01:00",
229
+ "saving": null
230
+ },
231
+ {
232
+ "price": 0.5375,
233
+ "onOff": false,
234
+ "start": "2021-12-15T11:00:00.000+01:00",
235
+ "saving": null
236
+ },
237
+ {
238
+ "price": 0.535,
239
+ "onOff": false,
240
+ "start": "2021-12-15T12:00:00.000+01:00",
241
+ "saving": null
242
+ },
243
+ {
244
+ "price": 0.5403,
245
+ "onOff": false,
246
+ "start": "2021-12-15T13:00:00.000+01:00",
247
+ "saving": null
248
+ },
249
+ {
250
+ "price": 0.5291,
251
+ "onOff": false,
252
+ "start": "2021-12-15T14:00:00.000+01:00",
253
+ "saving": null
254
+ },
255
+ {
256
+ "price": 0.5175,
257
+ "onOff": false,
258
+ "start": "2021-12-15T15:00:00.000+01:00",
259
+ "saving": null
260
+ },
261
+ {
262
+ "price": 0.4914,
263
+ "onOff": false,
264
+ "start": "2021-12-15T16:00:00.000+01:00",
265
+ "saving": null
266
+ },
267
+ {
268
+ "price": 0.4698,
269
+ "onOff": false,
270
+ "start": "2021-12-15T17:00:00.000+01:00",
271
+ "saving": null
272
+ },
273
+ {
274
+ "price": 0.4609,
275
+ "onOff": false,
276
+ "start": "2021-12-15T18:00:00.000+01:00",
277
+ "saving": null
278
+ },
279
+ {
280
+ "price": 0.4408,
281
+ "onOff": false,
282
+ "start": "2021-12-15T19:00:00.000+01:00",
283
+ "saving": null
284
+ },
285
+ {
286
+ "price": 0.4263,
287
+ "onOff": false,
288
+ "start": "2021-12-15T20:00:00.000+01:00",
289
+ "saving": null
290
+ },
291
+ {
292
+ "price": 0.3946,
293
+ "onOff": true,
294
+ "start": "2021-12-15T21:00:00.000+01:00",
295
+ "saving": null
296
+ },
297
+ {
298
+ "price": 0.3852,
299
+ "onOff": true,
300
+ "start": "2021-12-15T22:00:00.000+01:00",
301
+ "saving": null
302
+ },
303
+ {
304
+ "price": 0.373,
305
+ "onOff": true,
306
+ "start": "2021-12-15T23:00:00.000+01:00",
307
+ "saving": null
308
+ }
309
+ ],
310
+ "source": "Tibber",
311
+ "config": {
312
+ "fromTime": "16",
313
+ "toTime": "00",
314
+ "hoursOn": 3,
315
+ "doNotSplit": false,
316
+ "sendCurrentValueWhenRescheduling": true,
317
+ "outputIfNoSchedule": false,
318
+ "outputOutsidePeriod": false
319
+ }
320
+ }
@@ -0,0 +1,168 @@
1
+ {
2
+ "schedule": [
3
+ {
4
+ "time": "2021-12-14T00:00:00.000+01:00",
5
+ "value": false
6
+ },
7
+ {
8
+ "time": "2021-12-14T21:00:00.000+01:00",
9
+ "value": true
10
+ }
11
+ ],
12
+ "hours": [
13
+ {
14
+ "price": 0.4675,
15
+ "onOff": false,
16
+ "start": "2021-12-14T00:00:00.000+01:00",
17
+ "saving": null
18
+ },
19
+ {
20
+ "price": 0.4488,
21
+ "onOff": false,
22
+ "start": "2021-12-14T01:00:00.000+01:00",
23
+ "saving": null
24
+ },
25
+ {
26
+ "price": 0.4344,
27
+ "onOff": false,
28
+ "start": "2021-12-14T02:00:00.000+01:00",
29
+ "saving": null
30
+ },
31
+ {
32
+ "price": 0.4124,
33
+ "onOff": false,
34
+ "start": "2021-12-14T03:00:00.000+01:00",
35
+ "saving": null
36
+ },
37
+ {
38
+ "price": 0.413,
39
+ "onOff": false,
40
+ "start": "2021-12-14T04:00:00.000+01:00",
41
+ "saving": null
42
+ },
43
+ {
44
+ "price": 0.4232,
45
+ "onOff": false,
46
+ "start": "2021-12-14T05:00:00.000+01:00",
47
+ "saving": null
48
+ },
49
+ {
50
+ "price": 0.4,
51
+ "onOff": false,
52
+ "start": "2021-12-14T06:00:00.000+01:00",
53
+ "saving": null
54
+ },
55
+ {
56
+ "price": 0.4067,
57
+ "onOff": false,
58
+ "start": "2021-12-14T07:00:00.000+01:00",
59
+ "saving": null
60
+ },
61
+ {
62
+ "price": 0.504,
63
+ "onOff": false,
64
+ "start": "2021-12-14T08:00:00.000+01:00",
65
+ "saving": null
66
+ },
67
+ {
68
+ "price": 0.5341,
69
+ "onOff": false,
70
+ "start": "2021-12-14T09:00:00.000+01:00",
71
+ "saving": null
72
+ },
73
+ {
74
+ "price": 0.5179,
75
+ "onOff": false,
76
+ "start": "2021-12-14T10:00:00.000+01:00",
77
+ "saving": null
78
+ },
79
+ {
80
+ "price": 0.5375,
81
+ "onOff": false,
82
+ "start": "2021-12-14T11:00:00.000+01:00",
83
+ "saving": null
84
+ },
85
+ {
86
+ "price": 0.535,
87
+ "onOff": false,
88
+ "start": "2021-12-14T12:00:00.000+01:00",
89
+ "saving": null
90
+ },
91
+ {
92
+ "price": 0.5403,
93
+ "onOff": false,
94
+ "start": "2021-12-14T13:00:00.000+01:00",
95
+ "saving": null
96
+ },
97
+ {
98
+ "price": 0.5291,
99
+ "onOff": false,
100
+ "start": "2021-12-14T14:00:00.000+01:00",
101
+ "saving": null
102
+ },
103
+ {
104
+ "price": 0.5175,
105
+ "onOff": false,
106
+ "start": "2021-12-14T15:00:00.000+01:00",
107
+ "saving": null
108
+ },
109
+ {
110
+ "price": 0.4914,
111
+ "onOff": false,
112
+ "start": "2021-12-14T16:00:00.000+01:00",
113
+ "saving": null
114
+ },
115
+ {
116
+ "price": 0.4698,
117
+ "onOff": false,
118
+ "start": "2021-12-14T17:00:00.000+01:00",
119
+ "saving": null
120
+ },
121
+ {
122
+ "price": 0.4609,
123
+ "onOff": false,
124
+ "start": "2021-12-14T18:00:00.000+01:00",
125
+ "saving": null
126
+ },
127
+ {
128
+ "price": 0.4408,
129
+ "onOff": false,
130
+ "start": "2021-12-14T19:00:00.000+01:00",
131
+ "saving": null
132
+ },
133
+ {
134
+ "price": 0.4263,
135
+ "onOff": false,
136
+ "start": "2021-12-14T20:00:00.000+01:00",
137
+ "saving": null
138
+ },
139
+ {
140
+ "price": 0.3946,
141
+ "onOff": true,
142
+ "start": "2021-12-14T21:00:00.000+01:00",
143
+ "saving": null
144
+ },
145
+ {
146
+ "price": 0.3852,
147
+ "onOff": true,
148
+ "start": "2021-12-14T22:00:00.000+01:00",
149
+ "saving": null
150
+ },
151
+ {
152
+ "price": 0.373,
153
+ "onOff": true,
154
+ "start": "2021-12-14T23:00:00.000+01:00",
155
+ "saving": null
156
+ }
157
+ ],
158
+ "source": "Tibber",
159
+ "config": {
160
+ "fromTime": "16",
161
+ "toTime": "00",
162
+ "hoursOn": 3,
163
+ "doNotSplit": false,
164
+ "sendCurrentValueWhenRescheduling": true,
165
+ "outputIfNoSchedule": false,
166
+ "outputOutsidePeriod": false
167
+ }
168
+ }
@@ -27,7 +27,7 @@ describe("receive-price node", function () {
27
27
  it("should convert tibber prices", function (done) {
28
28
  const tibberPrices = require("./data/tibber-prices.json");
29
29
  const convertedPrices = require("./data/converted-prices.json");
30
- convertedPrices.priceData.source = "Tibber";
30
+ convertedPrices.source = "Tibber";
31
31
  const flow = [
32
32
  {
33
33
  id: "n1",
@@ -51,7 +51,7 @@ describe("receive-price node", function () {
51
51
  it("should convert tibber single home prices", function (done) {
52
52
  const tibberPrices = require("./data/tibber-prices-single-home.json");
53
53
  const convertedPrices = require("./data/converted-prices.json");
54
- convertedPrices.priceData.source = "Tibber";
54
+ convertedPrices.source = "Tibber";
55
55
  const flow = [
56
56
  {
57
57
  id: "n1",
@@ -75,7 +75,7 @@ describe("receive-price node", function () {
75
75
  it("should convert nordpool event prices", function (done) {
76
76
  const nordpoolPrices = require("./data/nordpool-event-prices.json");
77
77
  const convertedPrices = require("./data/converted-prices.json");
78
- convertedPrices.priceData.source = "Nordpool";
78
+ convertedPrices.source = "Nordpool";
79
79
  const flow = [
80
80
  {
81
81
  id: "n1",
@@ -99,7 +99,7 @@ describe("receive-price node", function () {
99
99
  it("should convert nordpool current state prices", function (done) {
100
100
  const nordpoolPrices = require("./data/nordpool-current-state-prices.json");
101
101
  const convertedPrices = require("./data/converted-prices.json");
102
- convertedPrices.priceData.source = "Nordpool";
102
+ convertedPrices.source = "Nordpool";
103
103
  const flow = [
104
104
  {
105
105
  id: "n1",
@@ -438,6 +438,72 @@ describe("ps-strategy-lowest-price node", function () {
438
438
  n1.receive({ payload: makePayload(prices, time) });
439
439
  });
440
440
  });
441
+ it("handles period end on hour 0 - 12 hours", function (done) {
442
+ const input = require("./data/tibber-data-end-0.json");
443
+ const result = require("./data/tibber-result-end-0.json");
444
+ const flow = [
445
+ {
446
+ id: "n1",
447
+ type: "ps-strategy-lowest-price",
448
+ name: "test name",
449
+ fromTime: "16",
450
+ toTime: "00",
451
+ hoursOn: 3,
452
+ doNotSplit: false,
453
+ sendCurrentValueWhenRescheduling: true,
454
+ outputIfNoSchedule: false,
455
+ outputOutsidePeriod: false,
456
+ wires: [["n3"], ["n4"], ["n2"]],
457
+ },
458
+ { id: "n2", type: "helper" },
459
+ { id: "n3", type: "helper" },
460
+ { id: "n4", type: "helper" },
461
+ ];
462
+ helper.load(lowestPrice, flow, function () {
463
+ const n1 = helper.getNode("n1");
464
+ const n2 = helper.getNode("n2");
465
+ n2.on("input", function (msg) {
466
+ expect(msg).toHaveProperty("payload", result);
467
+ n1.warn.should.not.be.called;
468
+ done();
469
+ });
470
+ const time = DateTime.fromISO(prices.priceData[10].start);
471
+ n1.receive({ payload: makePayload(input, time) });
472
+ });
473
+ });
474
+ it("handles period end on hour 0 - 24 hours", function (done) {
475
+ const input = require("./data/tibber-data-end-0-24h.json");
476
+ const result = require("./data/tibber-result-end-0-24h.json");
477
+ const flow = [
478
+ {
479
+ id: "n1",
480
+ type: "ps-strategy-lowest-price",
481
+ name: "test name",
482
+ fromTime: "16",
483
+ toTime: "00",
484
+ hoursOn: 3,
485
+ doNotSplit: false,
486
+ sendCurrentValueWhenRescheduling: true,
487
+ outputIfNoSchedule: false,
488
+ outputOutsidePeriod: false,
489
+ wires: [["n3"], ["n4"], ["n2"]],
490
+ },
491
+ { id: "n2", type: "helper" },
492
+ { id: "n3", type: "helper" },
493
+ { id: "n4", type: "helper" },
494
+ ];
495
+ helper.load(lowestPrice, flow, function () {
496
+ const n1 = helper.getNode("n1");
497
+ const n2 = helper.getNode("n2");
498
+ n2.on("input", function (msg) {
499
+ expect(msg).toHaveProperty("payload", result);
500
+ n1.warn.should.not.be.called;
501
+ done();
502
+ });
503
+ const time = DateTime.fromISO(prices.priceData[10].start);
504
+ n1.receive({ payload: makePayload(input, time) });
505
+ });
506
+ });
441
507
  });
442
508
 
443
509
  function makeFlow(hoursOn) {