node-red-contrib-power-saver 3.0.10 → 3.2.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.
Files changed (100) hide show
  1. package/docs/.vuepress/config.js +5 -1
  2. package/docs/.vuepress/dist/404.html +3 -3
  3. package/docs/.vuepress/dist/assets/img/add-tariff-flow.eb700d4f.png +0 -0
  4. package/docs/.vuepress/dist/assets/img/next-schedule-entity.4406856a.png +0 -0
  5. package/docs/.vuepress/dist/assets/img/next-schedule-flow.413ad62b.png +0 -0
  6. package/docs/.vuepress/dist/assets/img/next-schedule-sensor.eb896bdd.png +0 -0
  7. package/docs/.vuepress/dist/assets/img/node-ps-general-add-tariff.a3cf6f06.png +0 -0
  8. package/docs/.vuepress/dist/assets/js/app.eae70176.js +1 -0
  9. package/docs/.vuepress/dist/assets/js/runtime~app.3384c251.js +1 -0
  10. package/docs/.vuepress/dist/assets/js/v-0607240a.661e1808.js +1 -0
  11. package/docs/.vuepress/dist/assets/js/v-08683c60.a6b9cf5b.js +1 -0
  12. package/docs/.vuepress/dist/assets/js/v-0aca7ba6.b42fad7f.js +1 -0
  13. package/docs/.vuepress/dist/assets/js/v-0b5e3c8c.d62b30f7.js +1 -0
  14. package/docs/.vuepress/dist/assets/js/v-1ad821fa.6e2194d0.js +1 -0
  15. package/docs/.vuepress/dist/assets/js/v-1e2b191e.50b8fa18.js +1 -0
  16. package/docs/.vuepress/dist/assets/js/v-30acb564.f2fcd69f.js +1 -0
  17. package/docs/.vuepress/dist/assets/js/v-4637f9e4.b67738ed.js +1 -0
  18. package/docs/.vuepress/dist/assets/js/v-510ed0d4.528dd6f3.js +1 -0
  19. package/docs/.vuepress/dist/assets/js/v-5954bcb2.182daf70.js +1 -0
  20. package/docs/.vuepress/dist/assets/js/v-5db8da3a.f2de6cb9.js +1 -0
  21. package/docs/.vuepress/dist/assets/js/v-61f728ca.6fdbbb92.js +1 -0
  22. package/docs/.vuepress/dist/assets/js/v-677dfaed.0013f083.js +1 -0
  23. package/docs/.vuepress/dist/assets/js/v-7446a652.d05e2648.js +1 -0
  24. package/docs/.vuepress/dist/assets/js/v-7c87f26e.1127dcf5.js +1 -0
  25. package/docs/.vuepress/dist/assets/js/v-8daa1a0e.dde202c9.js +1 -0
  26. package/docs/.vuepress/dist/assets/js/v-b4a42144.9e5f9728.js +1 -0
  27. package/docs/.vuepress/dist/assets/js/v-e8c55052.8384b053.js +1 -0
  28. package/docs/.vuepress/dist/assets/js/v-fffb8e28.3406fd88.js +1 -0
  29. package/docs/.vuepress/dist/changelog/index.html +3 -3
  30. package/docs/.vuepress/dist/contribute/index.html +3 -3
  31. package/docs/.vuepress/dist/examples/example-next-schedule-entity.html +25 -0
  32. package/docs/.vuepress/dist/examples/example-nordpool-current-state.html +4 -4
  33. package/docs/.vuepress/dist/examples/example-nordpool-events-state.html +4 -4
  34. package/docs/.vuepress/dist/examples/example-tibber-mqtt.html +4 -4
  35. package/docs/.vuepress/dist/examples/index.html +3 -3
  36. package/docs/.vuepress/dist/faq/index.html +15 -0
  37. package/docs/.vuepress/dist/guide/index.html +4 -4
  38. package/docs/.vuepress/dist/index.html +3 -3
  39. package/docs/.vuepress/dist/nodes/index.html +3 -3
  40. package/docs/.vuepress/dist/nodes/old-power-saver-doc.html +4 -4
  41. package/docs/.vuepress/dist/nodes/power-saver.html +3 -3
  42. package/docs/.vuepress/dist/nodes/ps-elvia-add-tariff.html +3 -3
  43. package/docs/.vuepress/dist/nodes/ps-general-add-tariff.html +15 -0
  44. package/docs/.vuepress/dist/nodes/ps-receive-price.html +4 -4
  45. package/docs/.vuepress/dist/nodes/ps-strategy-best-save.html +7 -5
  46. package/docs/.vuepress/dist/nodes/ps-strategy-lowest-price.html +7 -5
  47. package/docs/.vuepress/dist/nodes/strategy-input.html +4 -4
  48. package/docs/README.md +2 -2
  49. package/docs/changelog/README.md +19 -0
  50. package/docs/examples/README.md +4 -0
  51. package/docs/examples/example-next-schedule-entity.md +41 -0
  52. package/docs/faq/README.md +23 -0
  53. package/docs/guide/README.md +4 -5
  54. package/docs/images/add-tariff-flow.png +0 -0
  55. package/docs/images/mysterious-plan.png +0 -0
  56. package/docs/images/next-schedule-entity.png +0 -0
  57. package/docs/images/next-schedule-flow.png +0 -0
  58. package/docs/images/next-schedule-sensor.png +0 -0
  59. package/docs/images/node-ps-general-add-tariff.png +0 -0
  60. package/docs/nodes/README.md +6 -0
  61. package/docs/nodes/ps-elvia-add-tariff.md +1 -1
  62. package/docs/nodes/ps-general-add-tariff.md +51 -0
  63. package/docs/nodes/ps-strategy-best-save.md +6 -2
  64. package/docs/nodes/ps-strategy-lowest-price.md +6 -2
  65. package/package.json +3 -2
  66. package/src/elvia/elvia-add-tariff.js +5 -1
  67. package/src/general-add-tariff-functions.js +46 -0
  68. package/src/general-add-tariff.html +186 -0
  69. package/src/general-add-tariff.js +35 -0
  70. package/src/handle-input.js +14 -5
  71. package/src/power-saver.js +1 -1
  72. package/src/receive-price.js +6 -1
  73. package/src/strategy-lowest-price.js +6 -6
  74. package/test/data/nordpool-3-days-prices.json +293 -0
  75. package/test/data/nordpool-3-days-result.json +444 -0
  76. package/test/data/tibber-result-end-0-24h.json +3 -1
  77. package/test/data/tibber-result-end-0.json +3 -1
  78. package/test/general-add-tariff-functions.test.js +104 -0
  79. package/test/general-add-tariff.test.js +186 -0
  80. package/test/send-config-input.test.js +44 -0
  81. package/test/strategy-lowest-price-3days.test.js +88 -0
  82. package/test/strategy-lowest-price.test.js +5 -0
  83. package/docs/.vuepress/dist/assets/js/app.3cfedce6.js +0 -1
  84. package/docs/.vuepress/dist/assets/js/runtime~app.f1d7fab8.js +0 -1
  85. package/docs/.vuepress/dist/assets/js/v-08683c60.07fe8291.js +0 -1
  86. package/docs/.vuepress/dist/assets/js/v-0aca7ba6.aec5ba75.js +0 -1
  87. package/docs/.vuepress/dist/assets/js/v-0b5e3c8c.163b80fb.js +0 -1
  88. package/docs/.vuepress/dist/assets/js/v-1ad821fa.85407071.js +0 -1
  89. package/docs/.vuepress/dist/assets/js/v-30acb564.73b8e29f.js +0 -1
  90. package/docs/.vuepress/dist/assets/js/v-4637f9e4.60300b77.js +0 -1
  91. package/docs/.vuepress/dist/assets/js/v-510ed0d4.b76b84de.js +0 -1
  92. package/docs/.vuepress/dist/assets/js/v-5954bcb2.9e6d2df1.js +0 -1
  93. package/docs/.vuepress/dist/assets/js/v-5db8da3a.ac192f35.js +0 -1
  94. package/docs/.vuepress/dist/assets/js/v-61f728ca.64fa763c.js +0 -1
  95. package/docs/.vuepress/dist/assets/js/v-677dfaed.b84f09f5.js +0 -1
  96. package/docs/.vuepress/dist/assets/js/v-7c87f26e.91c245da.js +0 -1
  97. package/docs/.vuepress/dist/assets/js/v-8daa1a0e.66c9dbce.js +0 -1
  98. package/docs/.vuepress/dist/assets/js/v-b4a42144.d1856a24.js +0 -1
  99. package/docs/.vuepress/dist/assets/js/v-e8c55052.5f85b6cd.js +0 -1
  100. package/docs/.vuepress/dist/assets/js/v-fffb8e28.9e0579a1.js +0 -1
@@ -0,0 +1,444 @@
1
+ {
2
+ "schedule": [
3
+ {
4
+ "time": "2022-01-03T00:00:00+01:00",
5
+ "value": false
6
+ },
7
+ {
8
+ "time": "2022-01-04T04:00:00+01:00",
9
+ "value": true
10
+ },
11
+ {
12
+ "time": "2022-01-04T05:00:00+01:00",
13
+ "value": false
14
+ },
15
+ {
16
+ "time": "2022-01-05T03:00:00+01:00",
17
+ "value": true
18
+ },
19
+ {
20
+ "time": "2022-01-05T04:00:00+01:00",
21
+ "value": false
22
+ }
23
+ ],
24
+ "hours": [
25
+ {
26
+ "price": 1.563,
27
+ "onOff": false,
28
+ "start": "2022-01-03T00:00:00+01:00",
29
+ "saving": null
30
+ },
31
+ {
32
+ "price": 1.543,
33
+ "onOff": false,
34
+ "start": "2022-01-03T01:00:00+01:00",
35
+ "saving": null
36
+ },
37
+ {
38
+ "price": 1.535,
39
+ "onOff": false,
40
+ "start": "2022-01-03T02:00:00+01:00",
41
+ "saving": null
42
+ },
43
+ {
44
+ "price": 1.52,
45
+ "onOff": false,
46
+ "start": "2022-01-03T03:00:00+01:00",
47
+ "saving": null
48
+ },
49
+ {
50
+ "price": 1.528,
51
+ "onOff": false,
52
+ "start": "2022-01-03T04:00:00+01:00",
53
+ "saving": null
54
+ },
55
+ {
56
+ "price": 1.545,
57
+ "onOff": false,
58
+ "start": "2022-01-03T05:00:00+01:00",
59
+ "saving": null
60
+ },
61
+ {
62
+ "price": 1.509,
63
+ "onOff": false,
64
+ "start": "2022-01-03T06:00:00+01:00",
65
+ "saving": null
66
+ },
67
+ {
68
+ "price": 1.513,
69
+ "onOff": false,
70
+ "start": "2022-01-03T07:00:00+01:00",
71
+ "saving": null
72
+ },
73
+ {
74
+ "price": 1.583,
75
+ "onOff": false,
76
+ "start": "2022-01-03T08:00:00+01:00",
77
+ "saving": null
78
+ },
79
+ {
80
+ "price": 1.658,
81
+ "onOff": false,
82
+ "start": "2022-01-03T09:00:00+01:00",
83
+ "saving": null
84
+ },
85
+ {
86
+ "price": 1.538,
87
+ "onOff": false,
88
+ "start": "2022-01-03T10:00:00+01:00",
89
+ "saving": null
90
+ },
91
+ {
92
+ "price": 1.54,
93
+ "onOff": false,
94
+ "start": "2022-01-03T11:00:00+01:00",
95
+ "saving": null
96
+ },
97
+ {
98
+ "price": 1.55,
99
+ "onOff": false,
100
+ "start": "2022-01-03T12:00:00+01:00",
101
+ "saving": null
102
+ },
103
+ {
104
+ "price": 1.584,
105
+ "onOff": false,
106
+ "start": "2022-01-03T13:00:00+01:00",
107
+ "saving": null
108
+ },
109
+ {
110
+ "price": 1.673,
111
+ "onOff": false,
112
+ "start": "2022-01-03T14:00:00+01:00",
113
+ "saving": null
114
+ },
115
+ {
116
+ "price": 1.722,
117
+ "onOff": false,
118
+ "start": "2022-01-03T15:00:00+01:00",
119
+ "saving": null
120
+ },
121
+ {
122
+ "price": 1.719,
123
+ "onOff": false,
124
+ "start": "2022-01-03T16:00:00+01:00",
125
+ "saving": null
126
+ },
127
+ {
128
+ "price": 1.798,
129
+ "onOff": false,
130
+ "start": "2022-01-03T17:00:00+01:00",
131
+ "saving": null
132
+ },
133
+ {
134
+ "price": 1.815,
135
+ "onOff": false,
136
+ "start": "2022-01-03T18:00:00+01:00",
137
+ "saving": null
138
+ },
139
+ {
140
+ "price": 1.786,
141
+ "onOff": false,
142
+ "start": "2022-01-03T19:00:00+01:00",
143
+ "saving": null
144
+ },
145
+ {
146
+ "price": 1.779,
147
+ "onOff": false,
148
+ "start": "2022-01-03T20:00:00+01:00",
149
+ "saving": null
150
+ },
151
+ {
152
+ "price": 1.746,
153
+ "onOff": false,
154
+ "start": "2022-01-03T21:00:00+01:00",
155
+ "saving": null
156
+ },
157
+ {
158
+ "price": 1.636,
159
+ "onOff": false,
160
+ "start": "2022-01-03T22:00:00+01:00",
161
+ "saving": null
162
+ },
163
+ {
164
+ "price": 1.421,
165
+ "onOff": false,
166
+ "start": "2022-01-03T23:00:00+01:00",
167
+ "saving": null
168
+ },
169
+ {
170
+ "price": 1.648,
171
+ "onOff": false,
172
+ "start": "2022-01-04T00:00:00+01:00",
173
+ "saving": null
174
+ },
175
+ {
176
+ "price": 1.65,
177
+ "onOff": false,
178
+ "start": "2022-01-04T01:00:00+01:00",
179
+ "saving": null
180
+ },
181
+ {
182
+ "price": 1.608,
183
+ "onOff": false,
184
+ "start": "2022-01-04T02:00:00+01:00",
185
+ "saving": null
186
+ },
187
+ {
188
+ "price": 1.445,
189
+ "onOff": false,
190
+ "start": "2022-01-04T03:00:00+01:00",
191
+ "saving": null
192
+ },
193
+ {
194
+ "price": 1.418,
195
+ "onOff": true,
196
+ "start": "2022-01-04T04:00:00+01:00",
197
+ "saving": null
198
+ },
199
+ {
200
+ "price": 1.664,
201
+ "onOff": false,
202
+ "start": "2022-01-04T05:00:00+01:00",
203
+ "saving": null
204
+ },
205
+ {
206
+ "price": 1.794,
207
+ "onOff": false,
208
+ "start": "2022-01-04T06:00:00+01:00",
209
+ "saving": null
210
+ },
211
+ {
212
+ "price": 1.938,
213
+ "onOff": false,
214
+ "start": "2022-01-04T07:00:00+01:00",
215
+ "saving": null
216
+ },
217
+ {
218
+ "price": 2.1,
219
+ "onOff": false,
220
+ "start": "2022-01-04T08:00:00+01:00",
221
+ "saving": null
222
+ },
223
+ {
224
+ "price": 2.085,
225
+ "onOff": false,
226
+ "start": "2022-01-04T09:00:00+01:00",
227
+ "saving": null
228
+ },
229
+ {
230
+ "price": 2.093,
231
+ "onOff": false,
232
+ "start": "2022-01-04T10:00:00+01:00",
233
+ "saving": null
234
+ },
235
+ {
236
+ "price": 2.059,
237
+ "onOff": false,
238
+ "start": "2022-01-04T11:00:00+01:00",
239
+ "saving": null
240
+ },
241
+ {
242
+ "price": 2.001,
243
+ "onOff": false,
244
+ "start": "2022-01-04T12:00:00+01:00",
245
+ "saving": null
246
+ },
247
+ {
248
+ "price": 1.948,
249
+ "onOff": false,
250
+ "start": "2022-01-04T13:00:00+01:00",
251
+ "saving": null
252
+ },
253
+ {
254
+ "price": 1.941,
255
+ "onOff": false,
256
+ "start": "2022-01-04T14:00:00+01:00",
257
+ "saving": null
258
+ },
259
+ {
260
+ "price": 1.982,
261
+ "onOff": false,
262
+ "start": "2022-01-04T15:00:00+01:00",
263
+ "saving": null
264
+ },
265
+ {
266
+ "price": 2.018,
267
+ "onOff": false,
268
+ "start": "2022-01-04T16:00:00+01:00",
269
+ "saving": null
270
+ },
271
+ {
272
+ "price": 2.099,
273
+ "onOff": false,
274
+ "start": "2022-01-04T17:00:00+01:00",
275
+ "saving": null
276
+ },
277
+ {
278
+ "price": 2.057,
279
+ "onOff": false,
280
+ "start": "2022-01-04T18:00:00+01:00",
281
+ "saving": null
282
+ },
283
+ {
284
+ "price": 1.925,
285
+ "onOff": false,
286
+ "start": "2022-01-04T19:00:00+01:00",
287
+ "saving": null
288
+ },
289
+ {
290
+ "price": 1.837,
291
+ "onOff": false,
292
+ "start": "2022-01-04T20:00:00+01:00",
293
+ "saving": null
294
+ },
295
+ {
296
+ "price": 1.771,
297
+ "onOff": false,
298
+ "start": "2022-01-04T21:00:00+01:00",
299
+ "saving": null
300
+ },
301
+ {
302
+ "price": 1.717,
303
+ "onOff": false,
304
+ "start": "2022-01-04T22:00:00+01:00",
305
+ "saving": null
306
+ },
307
+ {
308
+ "price": 1.429,
309
+ "onOff": false,
310
+ "start": "2022-01-04T23:00:00+01:00",
311
+ "saving": null
312
+ },
313
+ {
314
+ "price": 1.666,
315
+ "start": "2022-01-05T00:00:00+01:00",
316
+ "saving": null
317
+ },
318
+ {
319
+ "price": 1.544,
320
+ "start": "2022-01-05T01:00:00+01:00",
321
+ "saving": null
322
+ },
323
+ {
324
+ "price": 1.397,
325
+ "start": "2022-01-05T02:00:00+01:00",
326
+ "saving": null
327
+ },
328
+ {
329
+ "price": 1.294,
330
+ "start": "2022-01-05T03:00:00+01:00",
331
+ "saving": null
332
+ },
333
+ {
334
+ "price": 1.325,
335
+ "start": "2022-01-05T04:00:00+01:00",
336
+ "saving": null
337
+ },
338
+ {
339
+ "price": 1.523,
340
+ "start": "2022-01-05T05:00:00+01:00",
341
+ "saving": null
342
+ },
343
+ {
344
+ "price": 1.731,
345
+ "start": "2022-01-05T06:00:00+01:00",
346
+ "saving": null
347
+ },
348
+ {
349
+ "price": 1.737,
350
+ "start": "2022-01-05T07:00:00+01:00",
351
+ "saving": null
352
+ },
353
+ {
354
+ "price": 1.737,
355
+ "start": "2022-01-05T08:00:00+01:00",
356
+ "saving": null
357
+ },
358
+ {
359
+ "price": 1.742,
360
+ "start": "2022-01-05T09:00:00+01:00",
361
+ "saving": null
362
+ },
363
+ {
364
+ "price": 1.741,
365
+ "start": "2022-01-05T10:00:00+01:00",
366
+ "saving": null
367
+ },
368
+ {
369
+ "price": 1.728,
370
+ "start": "2022-01-05T11:00:00+01:00",
371
+ "saving": null
372
+ },
373
+ {
374
+ "price": 1.714,
375
+ "start": "2022-01-05T12:00:00+01:00",
376
+ "saving": null
377
+ },
378
+ {
379
+ "price": 1.713,
380
+ "start": "2022-01-05T13:00:00+01:00",
381
+ "saving": null
382
+ },
383
+ {
384
+ "price": 1.71,
385
+ "start": "2022-01-05T14:00:00+01:00",
386
+ "saving": null
387
+ },
388
+ {
389
+ "price": 1.715,
390
+ "start": "2022-01-05T15:00:00+01:00",
391
+ "saving": null
392
+ },
393
+ {
394
+ "price": 1.773,
395
+ "start": "2022-01-05T16:00:00+01:00",
396
+ "saving": null
397
+ },
398
+ {
399
+ "price": 1.853,
400
+ "start": "2022-01-05T17:00:00+01:00",
401
+ "saving": null
402
+ },
403
+ {
404
+ "price": 1.799,
405
+ "start": "2022-01-05T18:00:00+01:00",
406
+ "saving": null
407
+ },
408
+ {
409
+ "price": 1.753,
410
+ "start": "2022-01-05T19:00:00+01:00",
411
+ "saving": null
412
+ },
413
+ {
414
+ "price": 1.723,
415
+ "start": "2022-01-05T20:00:00+01:00",
416
+ "saving": null
417
+ },
418
+ {
419
+ "price": 1.74,
420
+ "start": "2022-01-05T21:00:00+01:00",
421
+ "saving": null
422
+ },
423
+ {
424
+ "price": 1.714,
425
+ "start": "2022-01-05T22:00:00+01:00",
426
+ "saving": null
427
+ },
428
+ {
429
+ "price": 1.696,
430
+ "start": "2022-01-05T23:00:00+01:00",
431
+ "saving": null
432
+ }
433
+ ],
434
+ "source": "Nordpool",
435
+ "config": {
436
+ "fromTime": 19,
437
+ "toTime": 7,
438
+ "hoursOn": 1,
439
+ "doNotSplit": false,
440
+ "sendCurrentValueWhenRescheduling": true,
441
+ "outputIfNoSchedule": false,
442
+ "outputOutsidePeriod": false
443
+ }
444
+ }
@@ -316,5 +316,7 @@
316
316
  "sendCurrentValueWhenRescheduling": true,
317
317
  "outputIfNoSchedule": false,
318
318
  "outputOutsidePeriod": false
319
- }
319
+ },
320
+ "time": "2021-10-11T10:00:00.000+02:00",
321
+ "version": "1.2.3"
320
322
  }
@@ -164,5 +164,7 @@
164
164
  "sendCurrentValueWhenRescheduling": true,
165
165
  "outputIfNoSchedule": false,
166
166
  "outputOutsidePeriod": false
167
- }
167
+ },
168
+ "time": "2021-10-11T10:00:00.000+02:00",
169
+ "version": "1.2.3"
168
170
  }
@@ -0,0 +1,104 @@
1
+ const expect = require("expect");
2
+ const { DateTime } = require("luxon");
3
+ const { addTariffToPrices, buildAllHours } = require("../src/general-add-tariff-functions");
4
+
5
+ describe("general-add-tariff-functions", () => {
6
+ it("can build all hours 6-22", () => {
7
+ const periods = [
8
+ { start: "06", value: 10 },
9
+ { start: "22", value: 11 },
10
+ ];
11
+ const result = [];
12
+ fillResult(result, 0, 5, 11);
13
+ fillResult(result, 6, 21, 10);
14
+ fillResult(result, 22, 23, 11);
15
+
16
+ expect(buildAllHours(console, periods)).toEqual(result);
17
+ });
18
+ it("can build all hours 0-22", () => {
19
+ const periods = [
20
+ { start: "00", value: 10 },
21
+ { start: "22", value: 11 },
22
+ ];
23
+ const result = [];
24
+ fillResult(result, 0, 21, 10);
25
+ fillResult(result, 22, 23, 11);
26
+
27
+ expect(buildAllHours(console, periods)).toEqual(result);
28
+ });
29
+ it("can build all hours 22-23", () => {
30
+ const periods = [
31
+ { start: "00", value: 10 },
32
+ { start: "23", value: 11 },
33
+ ];
34
+ const result = [];
35
+ fillResult(result, 0, 22, 10);
36
+ fillResult(result, 23, 23, 11);
37
+
38
+ expect(buildAllHours(console, periods)).toEqual(result);
39
+ });
40
+ it("can add tariff to prices", () => {
41
+ const config = {
42
+ validFrom: "2021-12-01",
43
+ validTo: "2021-12-10",
44
+ periods: [
45
+ { start: "06", value: 10 },
46
+ { start: "22", value: 11 },
47
+ ],
48
+ };
49
+ const values = [];
50
+ fillResult(values, 0, 5, 21);
51
+ fillResult(values, 6, 21, 20);
52
+ fillResult(values, 22, 23, 21);
53
+ const prices = values.map((_, i) => {
54
+ const start = DateTime.fromISO(config.validFrom).plus({ hours: i }).toISO();
55
+ return {
56
+ start,
57
+ value: 10,
58
+ };
59
+ });
60
+ const result = values.map((v, i) => {
61
+ const start = DateTime.fromISO(config.validFrom).plus({ hours: i }).toISO();
62
+ return {
63
+ start,
64
+ value: v,
65
+ };
66
+ });
67
+ addTariffToPrices(console, config, prices);
68
+ expect(prices).toEqual(result);
69
+ });
70
+ it("pass through when out of period", () => {
71
+ const config = {
72
+ validFrom: "2021-12-01",
73
+ validTo: "2021-12-10",
74
+ periods: [
75
+ { start: "06", value: 10 },
76
+ { start: "22", value: 11 },
77
+ ],
78
+ };
79
+ const values = [];
80
+ fillResult(values, 0, 23, 10);
81
+ const prices = values.map((_, i) => {
82
+ const start = DateTime.fromISO(config.validFrom).plus({ days: 20, hours: i }).toISO();
83
+ return {
84
+ start,
85
+ value: 10,
86
+ };
87
+ });
88
+ const result = values.map((v, i) => {
89
+ const start = DateTime.fromISO(config.validFrom).plus({ days: 20, hours: i }).toISO();
90
+ return {
91
+ start,
92
+ value: v,
93
+ };
94
+ });
95
+ addTariffToPrices(console, config, prices);
96
+ expect(prices).toEqual(result);
97
+ });
98
+ });
99
+
100
+ function fillResult(arr, from, to, value) {
101
+ for (let start = from; start <= to; start++) {
102
+ arr[start] = value;
103
+ }
104
+ }