node-red-contrib-power-saver 3.0.7 → 3.0.8

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 (29) hide show
  1. package/docs/.vuepress/config.js +1 -1
  2. package/docs/.vuepress/dist/404.html +4 -4
  3. package/docs/.vuepress/dist/assets/js/{app.342dc054.js → app.8ccc81e3.js} +1 -1
  4. package/docs/.vuepress/dist/assets/js/runtime~app.7653fe7e.js +1 -0
  5. package/docs/.vuepress/dist/assets/js/v-510ed0d4.e5215a83.js +1 -0
  6. package/docs/.vuepress/dist/changelog/index.html +4 -4
  7. package/docs/.vuepress/dist/contribute/index.html +3 -3
  8. package/docs/.vuepress/dist/examples/example-nordpool-current-state.html +3 -3
  9. package/docs/.vuepress/dist/examples/example-nordpool-events-state.html +3 -3
  10. package/docs/.vuepress/dist/examples/example-tibber-mqtt.html +3 -3
  11. package/docs/.vuepress/dist/examples/index.html +3 -3
  12. package/docs/.vuepress/dist/guide/index.html +3 -3
  13. package/docs/.vuepress/dist/index.html +3 -3
  14. package/docs/.vuepress/dist/nodes/index.html +3 -3
  15. package/docs/.vuepress/dist/nodes/old-power-saver-doc.html +3 -3
  16. package/docs/.vuepress/dist/nodes/power-saver.html +3 -3
  17. package/docs/.vuepress/dist/nodes/ps-elvia-add-tariff.html +3 -3
  18. package/docs/.vuepress/dist/nodes/ps-receive-price.html +3 -3
  19. package/docs/.vuepress/dist/nodes/ps-strategy-best-save.html +3 -3
  20. package/docs/.vuepress/dist/nodes/ps-strategy-lowest-price.html +3 -3
  21. package/docs/.vuepress/dist/nodes/strategy-input.html +3 -3
  22. package/docs/changelog/README.md +5 -0
  23. package/package.json +1 -1
  24. package/src/strategy-lowest-price.js +2 -1
  25. package/test/data/lowest-price-input-missing-end.json +197 -0
  26. package/test/data/lowest-price-result-missing-end.json +319 -0
  27. package/test/strategy-lowest-price.test.js +33 -0
  28. package/docs/.vuepress/dist/assets/js/runtime~app.0d53f24f.js +0 -1
  29. package/docs/.vuepress/dist/assets/js/v-510ed0d4.129ef915.js +0 -1
@@ -0,0 +1,319 @@
1
+ {
2
+ "payload": {
3
+ "schedule": [
4
+ {
5
+ "time": "2021-12-15T00:00:00+01:00",
6
+ "value": false
7
+ },
8
+ {
9
+ "time": "2021-12-15T22:00:00+01:00",
10
+ "value": true
11
+ },
12
+ {
13
+ "time": "2021-12-16T01:00:00+01:00",
14
+ "value": false
15
+ }
16
+ ],
17
+ "hours": [
18
+ {
19
+ "price": 1.588,
20
+ "onOff": false,
21
+ "start": "2021-12-15T00:00:00+01:00",
22
+ "saving": null
23
+ },
24
+ {
25
+ "price": 1.521,
26
+ "onOff": false,
27
+ "start": "2021-12-15T01:00:00+01:00",
28
+ "saving": null
29
+ },
30
+ {
31
+ "price": 1.492,
32
+ "onOff": false,
33
+ "start": "2021-12-15T02:00:00+01:00",
34
+ "saving": null
35
+ },
36
+ {
37
+ "price": 1.487,
38
+ "onOff": false,
39
+ "start": "2021-12-15T03:00:00+01:00",
40
+ "saving": null
41
+ },
42
+ {
43
+ "price": 1.497,
44
+ "onOff": false,
45
+ "start": "2021-12-15T04:00:00+01:00",
46
+ "saving": null
47
+ },
48
+ {
49
+ "price": 1.514,
50
+ "onOff": false,
51
+ "start": "2021-12-15T05:00:00+01:00",
52
+ "saving": null
53
+ },
54
+ {
55
+ "price": 1.583,
56
+ "onOff": false,
57
+ "start": "2021-12-15T06:00:00+01:00",
58
+ "saving": null
59
+ },
60
+ {
61
+ "price": 1.667,
62
+ "onOff": false,
63
+ "start": "2021-12-15T07:00:00+01:00",
64
+ "saving": null
65
+ },
66
+ {
67
+ "price": 1.729,
68
+ "onOff": false,
69
+ "start": "2021-12-15T08:00:00+01:00",
70
+ "saving": null
71
+ },
72
+ {
73
+ "price": 1.724,
74
+ "onOff": false,
75
+ "start": "2021-12-15T09:00:00+01:00",
76
+ "saving": null
77
+ },
78
+ {
79
+ "price": 1.707,
80
+ "onOff": false,
81
+ "start": "2021-12-15T10:00:00+01:00",
82
+ "saving": null
83
+ },
84
+ {
85
+ "price": 1.703,
86
+ "onOff": false,
87
+ "start": "2021-12-15T11:00:00+01:00",
88
+ "saving": null
89
+ },
90
+ {
91
+ "price": 1.692,
92
+ "onOff": false,
93
+ "start": "2021-12-15T12:00:00+01:00",
94
+ "saving": null
95
+ },
96
+ {
97
+ "price": 1.692,
98
+ "onOff": false,
99
+ "start": "2021-12-15T13:00:00+01:00",
100
+ "saving": null
101
+ },
102
+ {
103
+ "price": 1.692,
104
+ "onOff": false,
105
+ "start": "2021-12-15T14:00:00+01:00",
106
+ "saving": null
107
+ },
108
+ {
109
+ "price": 1.717,
110
+ "onOff": false,
111
+ "start": "2021-12-15T15:00:00+01:00",
112
+ "saving": null
113
+ },
114
+ {
115
+ "price": 1.72,
116
+ "onOff": false,
117
+ "start": "2021-12-15T16:00:00+01:00",
118
+ "saving": null
119
+ },
120
+ {
121
+ "price": 1.718,
122
+ "onOff": false,
123
+ "start": "2021-12-15T17:00:00+01:00",
124
+ "saving": null
125
+ },
126
+ {
127
+ "price": 1.679,
128
+ "onOff": false,
129
+ "start": "2021-12-15T18:00:00+01:00",
130
+ "saving": null
131
+ },
132
+ {
133
+ "price": 1.661,
134
+ "onOff": false,
135
+ "start": "2021-12-15T19:00:00+01:00",
136
+ "saving": null
137
+ },
138
+ {
139
+ "price": 1.629,
140
+ "onOff": false,
141
+ "start": "2021-12-15T20:00:00+01:00",
142
+ "saving": null
143
+ },
144
+ {
145
+ "price": 1.652,
146
+ "onOff": false,
147
+ "start": "2021-12-15T21:00:00+01:00",
148
+ "saving": null
149
+ },
150
+ {
151
+ "price": 1.612,
152
+ "onOff": true,
153
+ "start": "2021-12-15T22:00:00+01:00",
154
+ "saving": null
155
+ },
156
+ {
157
+ "price": 1.587,
158
+ "onOff": true,
159
+ "start": "2021-12-15T23:00:00+01:00",
160
+ "saving": null
161
+ },
162
+ {
163
+ "price": 1.682,
164
+ "onOff": true,
165
+ "start": "2021-12-16T00:00:00+01:00",
166
+ "saving": null
167
+ },
168
+ {
169
+ "price": 1.676,
170
+ "onOff": false,
171
+ "start": "2021-12-16T01:00:00+01:00",
172
+ "saving": null
173
+ },
174
+ {
175
+ "price": 1.669,
176
+ "onOff": false,
177
+ "start": "2021-12-16T02:00:00+01:00",
178
+ "saving": null
179
+ },
180
+ {
181
+ "price": 1.673,
182
+ "onOff": false,
183
+ "start": "2021-12-16T03:00:00+01:00",
184
+ "saving": null
185
+ },
186
+ {
187
+ "price": 1.692,
188
+ "onOff": false,
189
+ "start": "2021-12-16T04:00:00+01:00",
190
+ "saving": null
191
+ },
192
+ {
193
+ "price": 1.768,
194
+ "onOff": false,
195
+ "start": "2021-12-16T05:00:00+01:00",
196
+ "saving": null
197
+ },
198
+ {
199
+ "price": 1.888,
200
+ "onOff": false,
201
+ "start": "2021-12-16T06:00:00+01:00",
202
+ "saving": null
203
+ },
204
+ {
205
+ "price": 1.971,
206
+ "onOff": false,
207
+ "start": "2021-12-16T07:00:00+01:00",
208
+ "saving": null
209
+ },
210
+ {
211
+ "price": 2.098,
212
+ "onOff": false,
213
+ "start": "2021-12-16T08:00:00+01:00",
214
+ "saving": null
215
+ },
216
+ {
217
+ "price": 2.076,
218
+ "onOff": false,
219
+ "start": "2021-12-16T09:00:00+01:00",
220
+ "saving": null
221
+ },
222
+ {
223
+ "price": 2.073,
224
+ "onOff": false,
225
+ "start": "2021-12-16T10:00:00+01:00",
226
+ "saving": null
227
+ },
228
+ {
229
+ "price": 2.039,
230
+ "onOff": false,
231
+ "start": "2021-12-16T11:00:00+01:00",
232
+ "saving": null
233
+ },
234
+ {
235
+ "price": 2.003,
236
+ "onOff": false,
237
+ "start": "2021-12-16T12:00:00+01:00",
238
+ "saving": null
239
+ },
240
+ {
241
+ "price": 1.968,
242
+ "onOff": false,
243
+ "start": "2021-12-16T13:00:00+01:00",
244
+ "saving": null
245
+ },
246
+ {
247
+ "price": 1.971,
248
+ "onOff": false,
249
+ "start": "2021-12-16T14:00:00+01:00",
250
+ "saving": null
251
+ },
252
+ {
253
+ "price": 2.029,
254
+ "onOff": false,
255
+ "start": "2021-12-16T15:00:00+01:00",
256
+ "saving": null
257
+ },
258
+ {
259
+ "price": 2.138,
260
+ "onOff": false,
261
+ "start": "2021-12-16T16:00:00+01:00",
262
+ "saving": null
263
+ },
264
+ {
265
+ "price": 2.258,
266
+ "onOff": false,
267
+ "start": "2021-12-16T17:00:00+01:00",
268
+ "saving": null
269
+ },
270
+ {
271
+ "price": 2.248,
272
+ "onOff": false,
273
+ "start": "2021-12-16T18:00:00+01:00",
274
+ "saving": null
275
+ },
276
+ {
277
+ "price": 2.076,
278
+ "onOff": false,
279
+ "start": "2021-12-16T19:00:00+01:00",
280
+ "saving": null
281
+ },
282
+ {
283
+ "price": 2.009,
284
+ "onOff": false,
285
+ "start": "2021-12-16T20:00:00+01:00",
286
+ "saving": null
287
+ },
288
+ {
289
+ "price": 2.051,
290
+ "onOff": false,
291
+ "start": "2021-12-16T21:00:00+01:00",
292
+ "saving": null
293
+ },
294
+ {
295
+ "price": 1.926,
296
+ "onOff": false,
297
+ "start": "2021-12-16T22:00:00+01:00",
298
+ "saving": null
299
+ },
300
+ {
301
+ "price": 1.863,
302
+ "onOff": false,
303
+ "start": "2021-12-16T23:00:00+01:00",
304
+ "saving": null
305
+ }
306
+ ],
307
+ "source": "Nordpool",
308
+ "config": {
309
+ "fromTime": "22",
310
+ "toTime": "08",
311
+ "hoursOn": 3,
312
+ "doNotSplit": true,
313
+ "sendCurrentValueWhenRescheduling": true,
314
+ "outputIfNoSchedule": false,
315
+ "outputOutsidePeriod": false
316
+ }
317
+ },
318
+ "_msgid": "892aabf20811e69f"
319
+ }
@@ -504,6 +504,39 @@ describe("ps-strategy-lowest-price node", function () {
504
504
  n1.receive({ payload: makePayload(input, time) });
505
505
  });
506
506
  });
507
+ it("fix bug", function (done) {
508
+ const input = require("./data/lowest-price-input-missing-end.json");
509
+ const result = require("./data/lowest-price-result-missing-end.json");
510
+ const flow = [
511
+ {
512
+ id: "n1",
513
+ type: "ps-strategy-lowest-price",
514
+ name: "test name",
515
+ fromTime: "22",
516
+ toTime: "08",
517
+ hoursOn: 3,
518
+ doNotSplit: true,
519
+ sendCurrentValueWhenRescheduling: true,
520
+ outputIfNoSchedule: false,
521
+ outputOutsidePeriod: false,
522
+ wires: [["n3"], ["n4"], ["n2"]],
523
+ },
524
+ { id: "n2", type: "helper" },
525
+ { id: "n3", type: "helper" },
526
+ { id: "n4", type: "helper" },
527
+ ];
528
+ helper.load(lowestPrice, flow, function () {
529
+ const n1 = helper.getNode("n1");
530
+ const n2 = helper.getNode("n2");
531
+ n2.on("input", function (msg) {
532
+ expect(msg).toHaveProperty("payload", result.payload);
533
+ n1.warn.should.not.be.called;
534
+ done();
535
+ });
536
+ const time = DateTime.fromISO(prices.priceData[10].start);
537
+ n1.receive({ payload: makePayload(input, time) });
538
+ });
539
+ });
507
540
  });
508
541
 
509
542
  function makeFlow(hoursOn) {
@@ -1 +0,0 @@
1
- (()=>{"use strict";var e,r,t,a={},o={};function n(e){var r=o[e];if(void 0!==r)return r.exports;var t=o[e]={exports:{}};return a[e].call(t.exports,t,t.exports,n),t.exports}n.m=a,e=[],n.O=(r,t,a,o)=>{if(!t){var d=1/0;for(v=0;v<e.length;v++){for(var[t,a,o]=e[v],i=!0,c=0;c<t.length;c++)(!1&o||d>=o)&&Object.keys(n.O).every((e=>n.O[e](t[c])))?t.splice(c--,1):(i=!1,o<d&&(d=o));if(i){e.splice(v--,1);var s=a();void 0!==s&&(r=s)}}return r}o=o||0;for(var v=e.length;v>0&&e[v-1][2]>o;v--)e[v]=e[v-1];e[v]=[t,a,o]},n.d=(e,r)=>{for(var t in r)n.o(r,t)&&!n.o(e,t)&&Object.defineProperty(e,t,{enumerable:!0,get:r[t]})},n.f={},n.e=e=>Promise.all(Object.keys(n.f).reduce(((r,t)=>(n.f[t](e,r),r)),[])),n.u=e=>"assets/js/"+({22:"v-1ad821fa",27:"v-0aca7ba6",88:"v-3706649a",283:"v-61f728ca",317:"v-5954bcb2",332:"v-08683c60",363:"v-0b5e3c8c",407:"v-b4a42144",418:"v-4637f9e4",495:"v-510ed0d4",509:"v-8daa1a0e",625:"v-5db8da3a",651:"v-e8c55052",745:"v-677dfaed",807:"v-fffb8e28",889:"v-7c87f26e",901:"v-30acb564"}[e]||e)+"."+{22:"85407071",27:"aec5ba75",88:"d7f73384",283:"802ab15e",293:"5e967839",317:"be07962c",332:"07fe8291",363:"d008d8bc",407:"6e0c5aa0",418:"22ab9413",491:"c183eba3",495:"129ef915",509:"db8b59c6",625:"ac192f35",651:"5f85b6cd",745:"9bbbd037",807:"e815e852",889:"457a1a60",901:"73b8e29f"}[e]+".js",n.miniCssF=e=>{},n.o=(e,r)=>Object.prototype.hasOwnProperty.call(e,r),r={},t="node-red-contrib-power-saver:",n.l=(e,a,o,d)=>{if(r[e])r[e].push(a);else{var i,c;if(void 0!==o)for(var s=document.getElementsByTagName("script"),v=0;v<s.length;v++){var l=s[v];if(l.getAttribute("src")==e||l.getAttribute("data-webpack")==t+o){i=l;break}}i||(c=!0,(i=document.createElement("script")).charset="utf-8",i.timeout=120,n.nc&&i.setAttribute("nonce",n.nc),i.setAttribute("data-webpack",t+o),i.src=e),r[e]=[a];var b=(t,a)=>{i.onerror=i.onload=null,clearTimeout(f);var o=r[e];if(delete r[e],i.parentNode&&i.parentNode.removeChild(i),o&&o.forEach((e=>e(a))),t)return t(a)},f=setTimeout(b.bind(null,void 0,{type:"timeout",target:i}),12e4);i.onerror=b.bind(null,i.onerror),i.onload=b.bind(null,i.onload),c&&document.head.appendChild(i)}},n.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.p="/node-red-contrib-power-saver/",(()=>{var e={523:0,460:0};n.f.j=(r,t)=>{var a=n.o(e,r)?e[r]:void 0;if(0!==a)if(a)t.push(a[2]);else if(/^(460|523)$/.test(r))e[r]=0;else{var o=new Promise(((t,o)=>a=e[r]=[t,o]));t.push(a[2]=o);var d=n.p+n.u(r),i=new Error;n.l(d,(t=>{if(n.o(e,r)&&(0!==(a=e[r])&&(e[r]=void 0),a)){var o=t&&("load"===t.type?"missing":t.type),d=t&&t.target&&t.target.src;i.message="Loading chunk "+r+" failed.\n("+o+": "+d+")",i.name="ChunkLoadError",i.type=o,i.request=d,a[1](i)}}),"chunk-"+r,r)}},n.O.j=r=>0===e[r];var r=(r,t)=>{var a,o,[d,i,c]=t,s=0;if(d.some((r=>0!==e[r]))){for(a in i)n.o(i,a)&&(n.m[a]=i[a]);if(c)var v=c(n)}for(r&&r(t);s<d.length;s++)o=d[s],n.o(e,o)&&e[o]&&e[o][0](),e[d[s]]=0;return n.O(v)},t=self.webpackChunknode_red_contrib_power_saver=self.webpackChunknode_red_contrib_power_saver||[];t.forEach(r.bind(null,0)),t.push=r.bind(null,t.push.bind(t))})()})();
@@ -1 +0,0 @@
1
- "use strict";(self.webpackChunknode_red_contrib_power_saver=self.webpackChunknode_red_contrib_power_saver||[]).push([[495],{3707:(e,i,l)=>{l.r(i),l.d(i,{data:()=>a});const a={key:"v-510ed0d4",path:"/changelog/",title:"Change Log",lang:"en-US",frontmatter:{sidebar:"auto"},excerpt:"",headers:[{level:2,title:"3.0.4",slug:"_3-0-4",children:[]},{level:2,title:"3.0.3",slug:"_3-0-3",children:[]},{level:2,title:"3.0.2",slug:"_3-0-2",children:[]},{level:2,title:"3.0.1",slug:"_3-0-1",children:[]},{level:2,title:"3.0.0",slug:"_3-0-0",children:[]},{level:2,title:"2.1.0",slug:"_2-1-0",children:[]},{level:2,title:"2.0.5",slug:"_2-0-5",children:[]},{level:2,title:"2.0.4",slug:"_2-0-4",children:[]},{level:2,title:"2.0.3",slug:"_2-0-3",children:[]},{level:2,title:"2.0.2",slug:"_2-0-2",children:[]},{level:2,title:"2.0.1",slug:"_2-0-1",children:[]},{level:2,title:"2.0.0",slug:"_2-0-0",children:[]},{level:2,title:"1.0.9",slug:"_1-0-9",children:[]}],filePathRelative:"changelog/README.md",git:{updatedTime:1639494003e3,contributors:[{name:"Otto Paulsen",email:"ottpau@gmail.com",commits:4},{name:"Otto Paulsen",email:"otto.paulsen@itema.no",commits:1}]}}},3619:(e,i,l)=>{l.r(i),l.d(i,{default:()=>d});const a=(0,l(6252).uE)('<h1 id="change-log" tabindex="-1"><a class="header-anchor" href="#change-log" aria-hidden="true">#</a> Change Log</h1><p>List the most significant changes, starting in version 1.0.9.</p><h2 id="_3-0-4" tabindex="-1"><a class="header-anchor" href="#_3-0-4" aria-hidden="true">#</a> 3.0.4</h2><ul><li>Remove <code>null</code>-values from Nordpool data for <code>tomorrow</code>.</li></ul><h2 id="_3-0-3" tabindex="-1"><a class="header-anchor" href="#_3-0-3" aria-hidden="true">#</a> 3.0.3</h2><ul><li>Fix bug in lowest price strategy, when period ends at midnight.</li><li>Fix labels for hours on, so they do not have leading zero.</li><li>Fix so source should be visible in output 3.</li></ul><h2 id="_3-0-2" tabindex="-1"><a class="header-anchor" href="#_3-0-2" aria-hidden="true">#</a> 3.0.2</h2><ul><li>Bugfix in Lowest Price node (not successful)</li></ul><h2 id="_3-0-1" tabindex="-1"><a class="header-anchor" href="#_3-0-1" aria-hidden="true">#</a> 3.0.1</h2><ul><li>Fix so elvia subscripion key is stored as credential</li><li>Fix bug on config for strategy nodes. Config was not saved properly.</li><li>Remove double output bug, and better handling when hoursOn &gt; period</li></ul><h2 id="_3-0-0" tabindex="-1"><a class="header-anchor" href="#_3-0-0" aria-hidden="true">#</a> 3.0.0</h2><ul><li>Deprecating old Power Saver node, adding multiple new nodes.</li><li>New node <code>ps-strategy-best-save</code> is replacing old node <code>Power Saver</code> together with the new <code>ps-receive-price</code> node.</li><li>Add new strategy node: <code>ps-strategy-lowest-price</code>.</li><li>Add new node: <code>ps-receive-price</code>.</li><li>Add gridd tariff for Elvia customers, using the <code>ps-elvia-add-tariff</code> node.</li><li>New documentation.</li><li>Change node category to Power Saver.</li></ul><h2 id="_2-1-0" tabindex="-1"><a class="header-anchor" href="#_2-1-0" aria-hidden="true">#</a> 2.1.0</h2><ul><li>Accept config as input, making it possible to dynamically change config</li><li>Fix dropdown for config value for selecting output when there is no schedule</li><li>Improve config screen and documentation</li></ul><h2 id="_2-0-5" tabindex="-1"><a class="header-anchor" href="#_2-0-5" aria-hidden="true">#</a> 2.0.5</h2><ul><li>Update links to examples</li></ul><h2 id="_2-0-4" tabindex="-1"><a class="header-anchor" href="#_2-0-4" aria-hidden="true">#</a> 2.0.4</h2><ul><li>Update doc and add examples</li></ul><h2 id="_2-0-3" tabindex="-1"><a class="header-anchor" href="#_2-0-3" aria-hidden="true">#</a> 2.0.3</h2><ul><li>Bugfix</li></ul><h2 id="_2-0-2" tabindex="-1"><a class="header-anchor" href="#_2-0-2" aria-hidden="true">#</a> 2.0.2</h2><ul><li>Fix so Nordpool data can be read directly from the current state node</li></ul><h2 id="_2-0-1" tabindex="-1"><a class="header-anchor" href="#_2-0-1" aria-hidden="true">#</a> 2.0.1</h2><ul><li>Fix bug that caused no schedule</li><li>Add config to output</li></ul><h2 id="_2-0-0" tabindex="-1"><a class="header-anchor" href="#_2-0-0" aria-hidden="true">#</a> 2.0.0</h2><ul><li>New and better algorithm to calculate savings, resulting in a better schedule.</li><li>Removed possibility to configure maximum hours to save per day, as this does not really make much sense.</li><li>Round savings to 4 decimals.</li><li>Set last savings hour to null when 0.</li></ul><h2 id="_1-0-9" tabindex="-1"><a class="header-anchor" href="#_1-0-9" aria-hidden="true">#</a> 1.0.9</h2><ul><li>Fix bug in saving last hour of the day.</li></ul>',28),t={},d=(0,l(3744).Z)(t,[["render",function(e,i){return a}]])},3744:(e,i)=>{i.Z=(e,i)=>{const l=e.__vccOpts||e;for(const[e,a]of i)l[e]=a;return l}}}]);