node-red-contrib-power-saver 3.2.2 → 3.3.2

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 (105) hide show
  1. package/CHANGELOG.md +1 -1
  2. package/README.md +1 -1
  3. package/docs/.vuepress/clientAppEnhance.js +5 -0
  4. package/docs/.vuepress/components/BestSaveVerificator.vue +306 -0
  5. package/docs/.vuepress/components/DonateButtons.vue +87 -0
  6. package/docs/.vuepress/config.js +29 -5
  7. package/docs/.vuepress/dist/.nojekyll +0 -0
  8. package/docs/.vuepress/dist/404.html +5 -5
  9. package/docs/.vuepress/dist/assets/css/563.styles.99f4a8aa.css +1 -0
  10. package/docs/.vuepress/dist/assets/css/835.styles.c5afb22b.css +1 -0
  11. package/docs/.vuepress/dist/assets/css/{styles.e835bef6.css → styles.031dcf27.css} +2 -1
  12. package/docs/.vuepress/dist/assets/img/best-save-config.79a2f39a.png +0 -0
  13. package/docs/.vuepress/dist/assets/img/copy-payload-best-save.b9192985.png +0 -0
  14. package/docs/.vuepress/dist/assets/js/262.cf2c57d2.js +1 -0
  15. package/docs/.vuepress/dist/assets/js/{293.5e967839.js → 293.08ea5200.js} +0 -0
  16. package/docs/.vuepress/dist/assets/js/331.15ee3c51.js +1 -0
  17. package/docs/.vuepress/dist/assets/js/{491.c183eba3.js → 491.17a98f38.js} +0 -0
  18. package/docs/.vuepress/dist/assets/js/619.8ba1b1f6.js +2 -0
  19. package/docs/.vuepress/dist/assets/js/{812.79dad458.js.LICENSE.txt → 619.8ba1b1f6.js.LICENSE.txt} +0 -0
  20. package/docs/.vuepress/dist/assets/js/811.6a3392d5.js +1 -0
  21. package/docs/.vuepress/dist/assets/js/app.b705176c.js +1 -0
  22. package/docs/.vuepress/dist/assets/js/runtime~app.47f4f812.js +1 -0
  23. package/docs/.vuepress/dist/assets/js/{v-0607240a.661e1808.js → v-0607240a.a57c2199.js} +0 -0
  24. package/docs/.vuepress/dist/assets/js/{v-08683c60.a6b9cf5b.js → v-08683c60.ccafdcab.js} +0 -0
  25. package/docs/.vuepress/dist/assets/js/{v-0aca7ba6.b42fad7f.js → v-0aca7ba6.25903946.js} +0 -0
  26. package/docs/.vuepress/dist/assets/js/v-0b5e3c8c.a6a015b4.js +1 -0
  27. package/docs/.vuepress/dist/assets/js/{v-1ad821fa.6e2194d0.js → v-1ad821fa.5978386f.js} +0 -0
  28. package/docs/.vuepress/dist/assets/js/{v-1e2b191e.98cc227b.js → v-1e2b191e.88dc5555.js} +0 -0
  29. package/docs/.vuepress/dist/assets/js/v-29504124.4aca27d5.js +1 -0
  30. package/docs/.vuepress/dist/assets/js/{v-30acb564.f2fcd69f.js → v-30acb564.529a3c16.js} +0 -0
  31. package/docs/.vuepress/dist/assets/js/v-4637f9e4.703b1d96.js +1 -0
  32. package/docs/.vuepress/dist/assets/js/v-510ed0d4.7b142a81.js +1 -0
  33. package/docs/.vuepress/dist/assets/js/{v-5954bcb2.182daf70.js → v-5954bcb2.937005d0.js} +0 -0
  34. package/docs/.vuepress/dist/assets/js/{v-5db8da3a.f2de6cb9.js → v-5db8da3a.3de3588d.js} +1 -1
  35. package/docs/.vuepress/dist/assets/js/{v-61f728ca.6fdbbb92.js → v-61f728ca.21d432fe.js} +1 -1
  36. package/docs/.vuepress/dist/assets/js/{v-677dfaed.0013f083.js → v-677dfaed.44a653b9.js} +0 -0
  37. package/docs/.vuepress/dist/assets/js/v-7446a652.74b21d0b.js +1 -0
  38. package/docs/.vuepress/dist/assets/js/v-7c87f26e.ee5be992.js +1 -0
  39. package/docs/.vuepress/dist/assets/js/{v-8daa1a0e.dde202c9.js → v-8daa1a0e.c63afc2b.js} +1 -1
  40. package/docs/.vuepress/dist/assets/js/{v-b4a42144.9e5f9728.js → v-b4a42144.733e4e7c.js} +0 -0
  41. package/docs/.vuepress/dist/assets/js/{v-e8c55052.8384b053.js → v-e8c55052.ab0a79ec.js} +0 -0
  42. package/docs/.vuepress/dist/assets/js/v-fffb8e28.525be02a.js +1 -0
  43. package/docs/.vuepress/dist/changelog/index.html +5 -5
  44. package/docs/.vuepress/dist/contribute/index.html +5 -5
  45. package/docs/.vuepress/dist/examples/example-next-schedule-entity.html +6 -6
  46. package/docs/.vuepress/dist/examples/example-nordpool-current-state.html +6 -7
  47. package/docs/.vuepress/dist/examples/example-nordpool-events-state.html +6 -6
  48. package/docs/.vuepress/dist/examples/example-tibber-mqtt.html +6 -7
  49. package/docs/.vuepress/dist/examples/index.html +5 -5
  50. package/docs/.vuepress/dist/faq/best-save-viewer.html +15 -0
  51. package/docs/.vuepress/dist/faq/index.html +5 -5
  52. package/docs/.vuepress/dist/guide/index.html +6 -6
  53. package/docs/.vuepress/dist/index.html +5 -5
  54. package/docs/.vuepress/dist/nodes/index.html +5 -5
  55. package/docs/.vuepress/dist/nodes/old-power-saver-doc.html +7 -7
  56. package/docs/.vuepress/dist/nodes/power-saver.html +5 -5
  57. package/docs/.vuepress/dist/nodes/ps-elvia-add-tariff.html +5 -5
  58. package/docs/.vuepress/dist/nodes/ps-general-add-tariff.html +5 -5
  59. package/docs/.vuepress/dist/nodes/ps-receive-price.html +8 -8
  60. package/docs/.vuepress/dist/nodes/ps-strategy-best-save.html +22 -8
  61. package/docs/.vuepress/dist/nodes/ps-strategy-lowest-price.html +17 -7
  62. package/docs/.vuepress/dist/nodes/strategy-input.html +5 -5
  63. package/docs/README.md +4 -1
  64. package/docs/changelog/README.md +23 -0
  65. package/docs/contribute/README.md +3 -3
  66. package/docs/examples/example-nordpool-current-state.md +0 -1
  67. package/docs/examples/example-tibber-mqtt.md +0 -1
  68. package/docs/faq/README.md +28 -1
  69. package/docs/faq/best-save-viewer.md +61 -0
  70. package/docs/images/best-save-config.png +0 -0
  71. package/docs/images/copy-payload-best-save.png +0 -0
  72. package/docs/nodes/ps-strategy-best-save.md +95 -8
  73. package/docs/nodes/ps-strategy-lowest-price.md +57 -0
  74. package/package.json +7 -3
  75. package/src/general-add-tariff-functions.js +0 -1
  76. package/src/general-add-tariff.js +2 -4
  77. package/src/handle-input.js +31 -9
  78. package/src/strategy-best-save.html +0 -21
  79. package/src/strategy-best-save.js +8 -11
  80. package/test/commands-input.test.js +47 -0
  81. package/test/data/best-save-result.json +1 -2
  82. package/test/data/current-undefined-prices.json +197 -0
  83. package/test/data/current-undefined-result.json +208 -0
  84. package/test/data/lowest-price-result-missing-end.json +2 -1
  85. package/test/data/reconfigResult.js +56 -294
  86. package/test/data/reconfigResult_old2.js +75 -0
  87. package/test/data/tibber-result-end-0-24h.json +1 -0
  88. package/test/data/tibber-result-end-0.json +1 -0
  89. package/test/send-config-input.test.js +3 -37
  90. package/test/strategy-best-save-test-utils.js +2 -1
  91. package/test/strategy-best-save.test.js +14 -8
  92. package/test/test-utils.js +1 -7
  93. package/test/utils.test.js +0 -33
  94. package/docs/.vuepress/dist/assets/img/best-save-config.93fa3c21.png +0 -0
  95. package/docs/.vuepress/dist/assets/js/812.79dad458.js +0 -2
  96. package/docs/.vuepress/dist/assets/js/app.46f7644a.js +0 -1
  97. package/docs/.vuepress/dist/assets/js/runtime~app.714a526c.js +0 -1
  98. package/docs/.vuepress/dist/assets/js/v-0b5e3c8c.3b37457f.js +0 -1
  99. package/docs/.vuepress/dist/assets/js/v-4637f9e4.b320f5e8.js +0 -1
  100. package/docs/.vuepress/dist/assets/js/v-510ed0d4.9d35e3e3.js +0 -1
  101. package/docs/.vuepress/dist/assets/js/v-7446a652.d05e2648.js +0 -1
  102. package/docs/.vuepress/dist/assets/js/v-7c87f26e.1127dcf5.js +0 -1
  103. package/docs/.vuepress/dist/assets/js/v-fffb8e28.3406fd88.js +0 -1
  104. package/test/data/adjustedResult.js +0 -302
  105. package/test/data/adjustedResult_old.js +0 -154
@@ -1,5 +1,7 @@
1
1
  module.exports = {
2
2
  schedule: [
3
+ { time: "2021-06-20T01:50:00.000+02:00", value: false },
4
+ { time: "2021-06-20T01:50:00.020+02:00", value: true },
3
5
  { time: "2021-06-20T01:50:00.080+02:00", value: false },
4
6
  { time: "2021-06-20T01:50:00.110+02:00", value: true },
5
7
  { time: "2021-06-20T01:50:00.180+02:00", value: false },
@@ -8,308 +10,68 @@ module.exports = {
8
10
  { time: "2021-06-20T01:50:00.250+02:00", value: true },
9
11
  { time: "2021-06-20T01:50:00.330+02:00", value: false },
10
12
  { time: "2021-06-20T01:50:00.360+02:00", value: true },
11
- { time: "2021-06-20T01:50:00.400+02:00", value: false },
12
- { time: "2021-06-20T01:50:00.430+02:00", value: true },
13
- { time: "2021-06-20T01:50:00.460+02:00", value: false },
14
- { time: "2021-06-20T01:50:00.470+02:00", value: true },
13
+ { time: "2021-06-20T01:50:00.410+02:00", value: false },
14
+ { time: "2021-06-20T01:50:00.440+02:00", value: true },
15
15
  ],
16
16
  hours: [
17
- {
18
- price: 0.2494,
19
- onOff: false,
20
- start: "2021-06-20T01:50:00.000+02:00",
21
- saving: 0.0395,
22
- },
23
- {
24
- price: 0.2209,
25
- onOff: false,
26
- start: "2021-06-20T01:50:00.010+02:00",
27
- saving: 0.011,
28
- },
29
- {
30
- price: 0.2099,
31
- onOff: true,
32
- start: "2021-06-20T01:50:00.020+02:00",
33
- saving: null,
34
- },
35
- {
36
- price: 0.219,
37
- onOff: true,
38
- start: "2021-06-20T01:50:00.030+02:00",
39
- saving: null,
40
- },
41
- {
42
- price: 0.2614,
43
- onOff: true,
44
- start: "2021-06-20T01:50:00.040+02:00",
45
- saving: null,
46
- },
47
- {
48
- price: 0.4426,
49
- onOff: true,
50
- start: "2021-06-20T01:50:00.050+02:00",
51
- saving: null,
52
- },
53
- {
54
- price: 0.5433,
55
- onOff: true,
56
- start: "2021-06-20T01:50:00.060+02:00",
57
- saving: null,
58
- },
59
- {
60
- price: 0.5667,
61
- onOff: true,
62
- start: "2021-06-20T01:50:00.070+02:00",
63
- saving: null,
64
- },
65
- {
66
- price: 0.5847,
67
- onOff: false,
68
- start: "2021-06-20T01:50:00.080+02:00",
69
- saving: 0.0723,
70
- },
71
- {
72
- price: 0.5762,
73
- onOff: false,
74
- start: "2021-06-20T01:50:00.090+02:00",
75
- saving: 0.0638,
76
- },
77
- {
78
- price: 0.5391,
79
- onOff: false,
80
- start: "2021-06-20T01:50:00.100+02:00",
81
- saving: 0.0267,
82
- },
83
- {
84
- price: 0.5124,
85
- onOff: true,
86
- start: "2021-06-20T01:50:00.110+02:00",
87
- saving: null,
88
- },
89
- {
90
- price: 0.504,
91
- onOff: true,
92
- start: "2021-06-20T01:50:00.120+02:00",
93
- saving: null,
94
- },
95
- {
96
- price: 0.5057,
97
- onOff: true,
98
- start: "2021-06-20T01:50:00.130+02:00",
99
- saving: null,
100
- },
101
- {
102
- price: 0.5066,
103
- onOff: true,
104
- start: "2021-06-20T01:50:00.140+02:00",
105
- saving: null,
106
- },
107
- {
108
- price: 0.5136,
109
- onOff: true,
110
- start: "2021-06-20T01:50:00.150+02:00",
111
- saving: null,
112
- },
113
- {
114
- price: 0.5143,
115
- onOff: true,
116
- start: "2021-06-20T01:50:00.160+02:00",
117
- saving: null,
118
- },
119
- {
120
- price: 0.5306,
121
- onOff: true,
122
- start: "2021-06-20T01:50:00.170+02:00",
123
- saving: null,
124
- },
125
- {
126
- price: 0.5534,
127
- onOff: false,
128
- start: "2021-06-20T01:50:00.180+02:00",
129
- saving: 0.0043,
130
- },
131
- {
132
- price: 0.5511,
133
- onOff: false,
134
- start: "2021-06-20T01:50:00.190+02:00",
135
- saving: 0.002,
136
- },
137
- {
138
- price: 0.5491,
139
- onOff: true,
140
- start: "2021-06-20T01:50:00.200+02:00",
141
- saving: null,
142
- },
143
- {
144
- price: 0.5485,
145
- onOff: true,
146
- start: "2021-06-20T01:50:00.210+02:00",
147
- saving: null,
148
- },
149
- {
150
- price: 0.5481,
151
- onOff: false,
152
- start: "2021-06-20T01:50:00.220+02:00",
153
- saving: 0.1285,
154
- },
155
- {
156
- price: 0.5218,
157
- onOff: false,
158
- start: "2021-06-20T01:50:00.230+02:00",
159
- saving: 0.1022,
160
- },
161
- {
162
- price: 0.4533,
163
- onOff: false,
164
- start: "2021-06-20T01:50:00.240+02:00",
165
- saving: 0.0337,
166
- },
167
- {
168
- price: 0.4196,
169
- onOff: true,
170
- start: "2021-06-20T01:50:00.250+02:00",
171
- saving: null,
172
- },
173
- {
174
- price: 0.4037,
175
- onOff: true,
176
- start: "2021-06-20T01:50:00.260+02:00",
177
- saving: null,
178
- },
179
- {
180
- price: 0.3829,
181
- onOff: true,
182
- start: "2021-06-20T01:50:00.270+02:00",
183
- saving: null,
184
- },
185
- {
186
- price: 0.4555,
187
- onOff: true,
188
- start: "2021-06-20T01:50:00.280+02:00",
189
- saving: null,
190
- },
191
- {
192
- price: 0.4721,
193
- onOff: true,
194
- start: "2021-06-20T01:50:00.290+02:00",
195
- saving: null,
196
- },
197
- {
198
- price: 0.4903,
199
- onOff: true,
200
- start: "2021-06-20T01:50:00.300+02:00",
201
- saving: null,
202
- },
203
- {
204
- price: 0.5028,
205
- onOff: true,
206
- start: "2021-06-20T01:50:00.310+02:00",
207
- saving: null,
208
- },
209
- {
210
- price: 0.5163,
211
- onOff: true,
212
- start: "2021-06-20T01:50:00.320+02:00",
213
- saving: null,
214
- },
215
- {
216
- price: 0.5264,
217
- onOff: false,
218
- start: "2021-06-20T01:50:00.330+02:00",
219
- saving: 0.0193,
220
- },
221
- {
222
- price: 0.5346,
223
- onOff: false,
224
- start: "2021-06-20T01:50:00.340+02:00",
225
- saving: 0.0275,
226
- },
227
- {
228
- price: 0.5224,
229
- onOff: false,
230
- start: "2021-06-20T01:50:00.350+02:00",
231
- saving: 0.0153,
232
- },
233
- {
234
- price: 0.5071,
235
- onOff: true,
236
- start: "2021-06-20T01:50:00.360+02:00",
237
- saving: null,
238
- },
239
- {
240
- price: 0.5045,
241
- onOff: true,
242
- start: "2021-06-20T01:50:00.370+02:00",
243
- saving: null,
244
- },
245
- {
246
- price: 0.5024,
247
- onOff: true,
248
- start: "2021-06-20T01:50:00.380+02:00",
249
- saving: null,
250
- },
251
- {
252
- price: 0.5038,
253
- onOff: true,
254
- start: "2021-06-20T01:50:00.390+02:00",
255
- saving: null,
256
- },
257
- {
258
- price: 0.5118,
259
- onOff: false,
260
- start: "2021-06-20T01:50:00.400+02:00",
261
- saving: 0.0063,
262
- },
263
- {
264
- price: 0.5111,
265
- onOff: false,
266
- start: "2021-06-20T01:50:00.410+02:00",
267
- saving: 0.0056,
268
- },
269
- {
270
- price: 0.5108,
271
- onOff: false,
272
- start: "2021-06-20T01:50:00.420+02:00",
273
- saving: 0.0053,
274
- },
275
- {
276
- price: 0.5055,
277
- onOff: true,
278
- start: "2021-06-20T01:50:00.430+02:00",
279
- saving: null,
280
- },
281
- {
282
- price: 0.5042,
283
- onOff: true,
284
- start: "2021-06-20T01:50:00.440+02:00",
285
- saving: null,
286
- },
287
- {
288
- price: 0.5259,
289
- onOff: true,
290
- start: "2021-06-20T01:50:00.450+02:00",
291
- saving: null,
292
- },
293
- {
294
- price: 0.5282,
295
- onOff: false,
296
- start: "2021-06-20T01:50:00.460+02:00",
297
- saving: 0.003,
298
- },
299
- {
300
- price: 0.5252,
301
- onOff: true,
302
- start: "2021-06-20T01:50:00.470+02:00",
303
- saving: null,
304
- },
17
+ { price: 0.2494, onOff: false, start: "2021-06-20T01:50:00.000+02:00", saving: 0.0395 },
18
+ { price: 0.2209, onOff: false, start: "2021-06-20T01:50:00.010+02:00", saving: 0.011 },
19
+ { price: 0.2099, onOff: true, start: "2021-06-20T01:50:00.020+02:00", saving: null },
20
+ { price: 0.219, onOff: true, start: "2021-06-20T01:50:00.030+02:00", saving: null },
21
+ { price: 0.2614, onOff: true, start: "2021-06-20T01:50:00.040+02:00", saving: null },
22
+ { price: 0.4426, onOff: true, start: "2021-06-20T01:50:00.050+02:00", saving: null },
23
+ { price: 0.5433, onOff: true, start: "2021-06-20T01:50:00.060+02:00", saving: null },
24
+ { price: 0.5667, onOff: true, start: "2021-06-20T01:50:00.070+02:00", saving: null },
25
+ { price: 0.5847, onOff: false, start: "2021-06-20T01:50:00.080+02:00", saving: 0.0723 },
26
+ { price: 0.5762, onOff: false, start: "2021-06-20T01:50:00.090+02:00", saving: 0.0638 },
27
+ { price: 0.5391, onOff: false, start: "2021-06-20T01:50:00.100+02:00", saving: 0.0267 },
28
+ { price: 0.5124, onOff: true, start: "2021-06-20T01:50:00.110+02:00", saving: null },
29
+ { price: 0.504, onOff: true, start: "2021-06-20T01:50:00.120+02:00", saving: null },
30
+ { price: 0.5057, onOff: true, start: "2021-06-20T01:50:00.130+02:00", saving: null },
31
+ { price: 0.5066, onOff: true, start: "2021-06-20T01:50:00.140+02:00", saving: null },
32
+ { price: 0.5136, onOff: true, start: "2021-06-20T01:50:00.150+02:00", saving: null },
33
+ { price: 0.5143, onOff: true, start: "2021-06-20T01:50:00.160+02:00", saving: null },
34
+ { price: 0.5306, onOff: true, start: "2021-06-20T01:50:00.170+02:00", saving: null },
35
+ { price: 0.5534, onOff: false, start: "2021-06-20T01:50:00.180+02:00", saving: 0.0043 },
36
+ { price: 0.5511, onOff: false, start: "2021-06-20T01:50:00.190+02:00", saving: 0.002 },
37
+ { price: 0.5491, onOff: true, start: "2021-06-20T01:50:00.200+02:00", saving: null },
38
+ { price: 0.5485, onOff: true, start: "2021-06-20T01:50:00.210+02:00", saving: null },
39
+ { price: 0.5481, onOff: false, start: "2021-06-20T01:50:00.220+02:00", saving: 0.1285 },
40
+ { price: 0.5218, onOff: false, start: "2021-06-20T01:50:00.230+02:00", saving: 0.1022 },
41
+ { price: 0.4533, onOff: false, start: "2021-06-20T01:50:00.240+02:00", saving: 0.0337 },
42
+ { price: 0.4196, onOff: true, start: "2021-06-20T01:50:00.250+02:00", saving: null },
43
+ { price: 0.4037, onOff: true, start: "2021-06-20T01:50:00.260+02:00", saving: null },
44
+ { price: 0.3829, onOff: true, start: "2021-06-20T01:50:00.270+02:00", saving: null },
45
+ { price: 0.4555, onOff: true, start: "2021-06-20T01:50:00.280+02:00", saving: null },
46
+ { price: 0.4721, onOff: true, start: "2021-06-20T01:50:00.290+02:00", saving: null },
47
+ { price: 0.4903, onOff: true, start: "2021-06-20T01:50:00.300+02:00", saving: null },
48
+ { price: 0.5028, onOff: true, start: "2021-06-20T01:50:00.310+02:00", saving: null },
49
+ { price: 0.5163, onOff: true, start: "2021-06-20T01:50:00.320+02:00", saving: null },
50
+ { price: 0.5264, onOff: false, start: "2021-06-20T01:50:00.330+02:00", saving: 0.0193 },
51
+ { price: 0.5346, onOff: false, start: "2021-06-20T01:50:00.340+02:00", saving: 0.0275 },
52
+ { price: 0.5224, onOff: false, start: "2021-06-20T01:50:00.350+02:00", saving: 0.0153 },
53
+ { price: 0.5071, onOff: true, start: "2021-06-20T01:50:00.360+02:00", saving: null },
54
+ { price: 0.5045, onOff: true, start: "2021-06-20T01:50:00.370+02:00", saving: null },
55
+ { price: 0.5024, onOff: true, start: "2021-06-20T01:50:00.380+02:00", saving: null },
56
+ { price: 0.5038, onOff: true, start: "2021-06-20T01:50:00.390+02:00", saving: null },
57
+ { price: 0.5118, onOff: true, start: "2021-06-20T01:50:00.400+02:00", saving: null },
58
+ { price: 0.5111, onOff: false, start: "2021-06-20T01:50:00.410+02:00", saving: 0.0069 },
59
+ { price: 0.5108, onOff: false, start: "2021-06-20T01:50:00.420+02:00", saving: 0.0066 },
60
+ { price: 0.5055, onOff: false, start: "2021-06-20T01:50:00.430+02:00", saving: 0.0013 },
61
+ { price: 0.5042, onOff: true, start: "2021-06-20T01:50:00.440+02:00", saving: null },
62
+ { price: 0.5259, onOff: true, start: "2021-06-20T01:50:00.450+02:00", saving: null },
63
+ { price: 0.5282, onOff: true, start: "2021-06-20T01:50:00.460+02:00", saving: null },
64
+ { price: 0.5252, onOff: true, start: "2021-06-20T01:50:00.470+02:00", saving: null },
305
65
  ],
306
66
  source: undefined,
307
67
  config: {
308
68
  maxHoursToSaveInSequence: 3,
309
- minHoursOnAfterMaxSequenceSaved: 2,
69
+ minHoursOnAfterMaxSequenceSaved: 5,
310
70
  minSaving: 0.001,
311
71
  sendCurrentValueWhenRescheduling: undefined,
312
72
  outputIfNoSchedule: false,
313
- scheduleOnlyFromCurrentTime: true,
314
73
  },
74
+ time: "2021-06-20T01:50:00.045+02:00",
75
+ version: "3.2.3",
76
+ current: true,
315
77
  };
@@ -0,0 +1,75 @@
1
+ module.exports = {
2
+ schedule: [
3
+ { time: "2021-06-20T01:50:00.080+02:00", value: false },
4
+ { time: "2021-06-20T01:50:00.110+02:00", value: true },
5
+ { time: "2021-06-20T01:50:00.180+02:00", value: false },
6
+ { time: "2021-06-20T01:50:00.200+02:00", value: true },
7
+ { time: "2021-06-20T01:50:00.220+02:00", value: false },
8
+ { time: "2021-06-20T01:50:00.250+02:00", value: true },
9
+ { time: "2021-06-20T01:50:00.330+02:00", value: false },
10
+ { time: "2021-06-20T01:50:00.360+02:00", value: true },
11
+ { time: "2021-06-20T01:50:00.400+02:00", value: false },
12
+ { time: "2021-06-20T01:50:00.430+02:00", value: true },
13
+ { time: "2021-06-20T01:50:00.460+02:00", value: false },
14
+ { time: "2021-06-20T01:50:00.470+02:00", value: true },
15
+ ],
16
+ hours: [
17
+ { price: 0.2494, onOff: false, start: "2021-06-20T01:50:00.000+02:00", saving: 0.0395 },
18
+ { price: 0.2209, onOff: false, start: "2021-06-20T01:50:00.010+02:00", saving: 0.011 },
19
+ { price: 0.2099, onOff: true, start: "2021-06-20T01:50:00.020+02:00", saving: null },
20
+ { price: 0.219, onOff: true, start: "2021-06-20T01:50:00.030+02:00", saving: null },
21
+ { price: 0.2614, onOff: true, start: "2021-06-20T01:50:00.040+02:00", saving: null },
22
+ { price: 0.4426, onOff: true, start: "2021-06-20T01:50:00.050+02:00", saving: null },
23
+ { price: 0.5433, onOff: true, start: "2021-06-20T01:50:00.060+02:00", saving: null },
24
+ { price: 0.5667, onOff: true, start: "2021-06-20T01:50:00.070+02:00", saving: null },
25
+ { price: 0.5847, onOff: false, start: "2021-06-20T01:50:00.080+02:00", saving: 0.0723 },
26
+ { price: 0.5762, onOff: false, start: "2021-06-20T01:50:00.090+02:00", saving: 0.0638 },
27
+ { price: 0.5391, onOff: false, start: "2021-06-20T01:50:00.100+02:00", saving: 0.0267 },
28
+ { price: 0.5124, onOff: true, start: "2021-06-20T01:50:00.110+02:00", saving: null },
29
+ { price: 0.504, onOff: true, start: "2021-06-20T01:50:00.120+02:00", saving: null },
30
+ { price: 0.5057, onOff: true, start: "2021-06-20T01:50:00.130+02:00", saving: null },
31
+ { price: 0.5066, onOff: true, start: "2021-06-20T01:50:00.140+02:00", saving: null },
32
+ { price: 0.5136, onOff: true, start: "2021-06-20T01:50:00.150+02:00", saving: null },
33
+ { price: 0.5143, onOff: true, start: "2021-06-20T01:50:00.160+02:00", saving: null },
34
+ { price: 0.5306, onOff: true, start: "2021-06-20T01:50:00.170+02:00", saving: null },
35
+ { price: 0.5534, onOff: false, start: "2021-06-20T01:50:00.180+02:00", saving: 0.0043 },
36
+ { price: 0.5511, onOff: false, start: "2021-06-20T01:50:00.190+02:00", saving: 0.002 },
37
+ { price: 0.5491, onOff: true, start: "2021-06-20T01:50:00.200+02:00", saving: null },
38
+ { price: 0.5485, onOff: true, start: "2021-06-20T01:50:00.210+02:00", saving: null },
39
+ { price: 0.5481, onOff: false, start: "2021-06-20T01:50:00.220+02:00", saving: 0.1285 },
40
+ { price: 0.5218, onOff: false, start: "2021-06-20T01:50:00.230+02:00", saving: 0.1022 },
41
+ { price: 0.4533, onOff: false, start: "2021-06-20T01:50:00.240+02:00", saving: 0.0337 },
42
+ { price: 0.4196, onOff: true, start: "2021-06-20T01:50:00.250+02:00", saving: null },
43
+ { price: 0.4037, onOff: true, start: "2021-06-20T01:50:00.260+02:00", saving: null },
44
+ { price: 0.3829, onOff: true, start: "2021-06-20T01:50:00.270+02:00", saving: null },
45
+ { price: 0.4555, onOff: true, start: "2021-06-20T01:50:00.280+02:00", saving: null },
46
+ { price: 0.4721, onOff: true, start: "2021-06-20T01:50:00.290+02:00", saving: null },
47
+ { price: 0.4903, onOff: true, start: "2021-06-20T01:50:00.300+02:00", saving: null },
48
+ { price: 0.5028, onOff: true, start: "2021-06-20T01:50:00.310+02:00", saving: null },
49
+ { price: 0.5163, onOff: true, start: "2021-06-20T01:50:00.320+02:00", saving: null },
50
+ { price: 0.5264, onOff: false, start: "2021-06-20T01:50:00.330+02:00", saving: 0.0193 },
51
+ { price: 0.5346, onOff: false, start: "2021-06-20T01:50:00.340+02:00", saving: 0.0275 },
52
+ { price: 0.5224, onOff: false, start: "2021-06-20T01:50:00.350+02:00", saving: 0.0153 },
53
+ { price: 0.5071, onOff: true, start: "2021-06-20T01:50:00.360+02:00", saving: null },
54
+ { price: 0.5045, onOff: true, start: "2021-06-20T01:50:00.370+02:00", saving: null },
55
+ { price: 0.5024, onOff: true, start: "2021-06-20T01:50:00.380+02:00", saving: null },
56
+ { price: 0.5038, onOff: true, start: "2021-06-20T01:50:00.390+02:00", saving: null },
57
+ { price: 0.5118, onOff: false, start: "2021-06-20T01:50:00.400+02:00", saving: 0.0063 },
58
+ { price: 0.5111, onOff: false, start: "2021-06-20T01:50:00.410+02:00", saving: 0.0056 },
59
+ { price: 0.5108, onOff: false, start: "2021-06-20T01:50:00.420+02:00", saving: 0.0053 },
60
+ { price: 0.5055, onOff: true, start: "2021-06-20T01:50:00.430+02:00", saving: null },
61
+ { price: 0.5042, onOff: true, start: "2021-06-20T01:50:00.440+02:00", saving: null },
62
+ { price: 0.5259, onOff: true, start: "2021-06-20T01:50:00.450+02:00", saving: null },
63
+ { price: 0.5282, onOff: false, start: "2021-06-20T01:50:00.460+02:00", saving: 0.003 },
64
+ { price: 0.5252, onOff: true, start: "2021-06-20T01:50:00.470+02:00", saving: null },
65
+ ],
66
+ source: undefined,
67
+ config: {
68
+ maxHoursToSaveInSequence: 3,
69
+ minHoursOnAfterMaxSequenceSaved: 2,
70
+ minSaving: 0.001,
71
+ sendCurrentValueWhenRescheduling: undefined,
72
+ outputIfNoSchedule: false,
73
+ scheduleOnlyFromCurrentTime: true,
74
+ },
75
+ };
@@ -317,6 +317,7 @@
317
317
  "outputIfNoSchedule": false,
318
318
  "outputOutsidePeriod": false
319
319
  },
320
+ "sentOnCommand": false,
320
321
  "time": "2021-10-11T10:00:00.000+02:00",
321
322
  "version": "1.2.3"
322
323
  }
@@ -165,6 +165,7 @@
165
165
  "outputIfNoSchedule": false,
166
166
  "outputOutsidePeriod": false
167
167
  },
168
+ "sentOnCommand": false,
168
169
  "time": "2021-10-11T10:00:00.000+02:00",
169
170
  "version": "1.2.3"
170
171
  }
@@ -5,7 +5,6 @@ const { DateTime } = require("luxon");
5
5
  const prices = require("./data/converted-prices.json");
6
6
  const result = require("./data/best-save-result.json");
7
7
  const reconfigResult = require("./data/reconfigResult");
8
- const adjustedResult = require("./data/adjustedResult");
9
8
  const { testPlan, equalPlan } = require("./test-utils");
10
9
  const { makeFlow, makePayload } = require("./strategy-best-save-test-utils");
11
10
  const cloneDeep = require("lodash.clonedeep");
@@ -50,9 +49,8 @@ describe("send config as input", () => {
50
49
  n1.receive({ payload: makePayload(prices, testPlan.time) });
51
50
  });
52
51
  });
53
- it("should schedule only from selected time", function (done) {
52
+ it("should use another minHoursOnAfterMaxSequenceSaved", function (done) {
54
53
  const flow = makeFlow(3, 2);
55
- flow[0].scheduleOnlyFromCurrentTime = false;
56
54
  const changeTime = DateTime.fromISO("2021-06-20T01:50:00.045+02:00");
57
55
  let pass = 1;
58
56
  helper.load(bestSave, flow, function () {
@@ -65,14 +63,14 @@ describe("send config as input", () => {
65
63
  expect(equalPlan(result, msg.payload)).toBeTruthy();
66
64
  n1.receive({
67
65
  payload: {
68
- config: { scheduleOnlyFromCurrentTime: true },
66
+ config: { minHoursOnAfterMaxSequenceSaved: 5 },
69
67
  time: changeTime,
70
68
  },
71
69
  });
72
70
  break;
73
71
  case 2:
74
72
  pass++;
75
- reconfigResult.config.scheduleOnlyFromCurrentTime = true;
73
+ reconfigResult.config.minHoursOnAfterMaxSequenceSaved = 5;
76
74
  expect(equalPlan(reconfigResult, msg.payload)).toBeTruthy();
77
75
  const payload = makePayload(prices, testPlan.time);
78
76
  payload.time = changeTime;
@@ -87,38 +85,6 @@ describe("send config as input", () => {
87
85
  n1.receive({ payload: makePayload(prices, testPlan.time) });
88
86
  });
89
87
  });
90
- it("should correct savings for passed hours", function (done) {
91
- const flow = makeFlow(3, 2);
92
- const changeTime = DateTime.fromISO("2021-06-20T01:50:00.045+02:00");
93
- let pass = 1;
94
- helper.load(bestSave, flow, function () {
95
- const n1 = helper.getNode("n1");
96
- const n2 = helper.getNode("n2");
97
- n2.on("input", function (msg) {
98
- switch (pass) {
99
- case 1:
100
- pass++;
101
- expect(equalPlan(result, msg.payload)).toBeTruthy();
102
- n1.receive({
103
- payload: {
104
- config: {
105
- maxHoursToSaveInSequence: 5,
106
- minSaving: 0.25,
107
- scheduleOnlyFromCurrentTime: true,
108
- },
109
- time: changeTime,
110
- },
111
- });
112
- break;
113
- case 2:
114
- pass++;
115
- expect(equalPlan(adjustedResult, msg.payload)).toBeTruthy();
116
- done();
117
- }
118
- });
119
- n1.receive({ payload: makePayload(prices, testPlan.time) });
120
- });
121
- });
122
88
  it("should accept config and price-data together", function (done) {
123
89
  const flow = makeFlow(3, 2);
124
90
  let pass = 1;
@@ -1,7 +1,7 @@
1
1
  const cloneDeep = require("lodash.clonedeep");
2
2
  const { DateTime } = require("luxon");
3
3
 
4
- function makeFlow(maxHoursToSaveInSequence, minHoursOnAfterMaxSequenceSaved) {
4
+ function makeFlow(maxHoursToSaveInSequence, minHoursOnAfterMaxSequenceSaved, sendCurrentValueWhenRescheduling = false) {
5
5
  return [
6
6
  {
7
7
  id: "n1",
@@ -9,6 +9,7 @@ function makeFlow(maxHoursToSaveInSequence, minHoursOnAfterMaxSequenceSaved) {
9
9
  name: "test name",
10
10
  maxHoursToSaveInSequence,
11
11
  minHoursOnAfterMaxSequenceSaved,
12
+ sendCurrentValueWhenRescheduling,
12
13
  minSaving: 0.001,
13
14
  wires: [["n3"], ["n4"], ["n2"]],
14
15
  },
@@ -5,8 +5,9 @@ const helper = require("node-red-node-test-helper");
5
5
  const bestSave = require("../src/strategy-best-save.js");
6
6
  const prices = require("./data/converted-prices.json");
7
7
  const result = require("./data/best-save-result.json");
8
- const { testPlan: plan } = require("./test-utils");
8
+ const { testPlan: plan, equalPlan } = require("./test-utils");
9
9
  const { makeFlow } = require("./strategy-best-save-test-utils");
10
+ const { version } = require("../package.json");
10
11
 
11
12
  helper.init(require.resolve("node-red"));
12
13
 
@@ -61,6 +62,11 @@ describe("ps-strategy-best-save node", function () {
61
62
  });
62
63
  it("should send new schedule on output 3", function (done) {
63
64
  const flow = makeFlow(3, 2);
65
+ const expected = cloneDeep(result);
66
+ expected.version = version;
67
+ expected.time = plan.time;
68
+ expected.source = "Tibber";
69
+ expected.current = false;
64
70
  helper.load(bestSave, flow, function () {
65
71
  const n1 = helper.getNode("n1");
66
72
  const n2 = helper.getNode("n2");
@@ -69,22 +75,22 @@ describe("ps-strategy-best-save node", function () {
69
75
  let countOn = 0;
70
76
  let countOff = 0;
71
77
  n2.on("input", function (msg) {
72
- expect(msg).toHaveProperty("payload", result);
78
+ expect(equalPlan(expected, msg.payload)).toBeTruthy();
73
79
  n1.warn.should.not.be.called;
80
+ setTimeout(() => {
81
+ console.log("countOn = " + countOn + ", countOff = " + countOff);
82
+ expect(countOn).toEqual(7);
83
+ expect(countOff).toEqual(7);
84
+ done();
85
+ }, 900);
74
86
  });
75
87
  n3.on("input", function (msg) {
76
88
  countOn++;
77
89
  expect(msg).toHaveProperty("payload", true);
78
- if (countOn === 7 && countOff === 7) {
79
- done();
80
- }
81
90
  });
82
91
  n4.on("input", function (msg) {
83
92
  countOff++;
84
93
  expect(msg).toHaveProperty("payload", false);
85
- if (countOn === 7 && countOff === 7) {
86
- done();
87
- }
88
94
  });
89
95
  n1.receive({ payload: makePayload(prices, plan.time) });
90
96
  });
@@ -81,13 +81,7 @@ function equalPlan(expected, actual) {
81
81
  });
82
82
  });
83
83
 
84
- [
85
- "maxHoursToSaveInSequence",
86
- "minHoursOnAfterMaxSequenceSaved",
87
- "minSaving",
88
- "outputIfNoSchedule",
89
- "scheduleOnlyFromCurrentTime",
90
- ].forEach((key) => {
84
+ ["maxHoursToSaveInSequence", "minHoursOnAfterMaxSequenceSaved", "minSaving", "outputIfNoSchedule"].forEach((key) => {
91
85
  if (expected.config[key] != actual.config[key]) {
92
86
  console.log(
93
87
  "Different config values for " + key + ": Expected " + expected.config[key] + ", got " + actual.config[key]
@@ -196,37 +196,4 @@ describe("utils", () => {
196
196
  };
197
197
  expect(extractPlanForDate(plan, "2021-06-20T01:50:00.000+02:00")).toEqual(part1);
198
198
  });
199
-
200
- it("can get the correct startAt index", () => {
201
- const config = { scheduleOnlyFromCurrentTime: true };
202
- const time = DateTime.fromISO("2021-06-20T01:50:00.012+02:00");
203
- const priceData = [
204
- {
205
- start: "2021-06-20T01:50:00.000+02:00",
206
- },
207
- {
208
- start: "2021-06-20T01:50:00.010+02:00",
209
- },
210
- {
211
- start: "2021-06-21T01:50:00.180+02:00",
212
- },
213
- {
214
- start: "2021-06-21T01:50:00.190+02:00",
215
- },
216
- ];
217
- expect(
218
- // Start on 0
219
- getStartAtIndex({ scheduleOnlyFromCurrentTime: false }, priceData, time)
220
- ).toEqual(0);
221
- expect(getStartAtIndex(config, priceData, time)).toEqual(2);
222
- expect(
223
- // Start exactly on time
224
- getStartAtIndex(config, priceData, DateTime.fromISO("2021-06-20T01:50:00.010+02:00"))
225
- ).toEqual(1);
226
- expect(getStartAtIndex(config, priceData, DateTime.fromISO("2021-06-20T01:50:00.011+02:00"))).toEqual(2);
227
- expect(
228
- // Start later than all data
229
- getStartAtIndex(config, priceData, DateTime.fromISO("2021-06-21T01:50:00.200+02:00"))
230
- ).toEqual(4);
231
- });
232
199
  });