node-red-contrib-power-saver 3.0.2 → 3.0.6

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 (37) hide show
  1. package/docs/.vuepress/dist/404.html +3 -3
  2. package/docs/.vuepress/dist/assets/js/{app.4ee3384b.js → app.342dc054.js} +1 -1
  3. package/docs/.vuepress/dist/assets/js/runtime~app.0d53f24f.js +1 -0
  4. package/docs/.vuepress/dist/assets/js/v-510ed0d4.129ef915.js +1 -0
  5. package/docs/.vuepress/dist/changelog/index.html +3 -3
  6. package/docs/.vuepress/dist/contribute/index.html +2 -2
  7. package/docs/.vuepress/dist/examples/example-nordpool-current-state.html +2 -2
  8. package/docs/.vuepress/dist/examples/example-nordpool-events-state.html +2 -2
  9. package/docs/.vuepress/dist/examples/example-tibber-mqtt.html +2 -2
  10. package/docs/.vuepress/dist/examples/index.html +2 -2
  11. package/docs/.vuepress/dist/guide/index.html +2 -2
  12. package/docs/.vuepress/dist/index.html +2 -2
  13. package/docs/.vuepress/dist/nodes/index.html +2 -2
  14. package/docs/.vuepress/dist/nodes/old-power-saver-doc.html +2 -2
  15. package/docs/.vuepress/dist/nodes/power-saver.html +2 -2
  16. package/docs/.vuepress/dist/nodes/ps-elvia-add-tariff.html +2 -2
  17. package/docs/.vuepress/dist/nodes/ps-receive-price.html +2 -2
  18. package/docs/.vuepress/dist/nodes/ps-strategy-best-save.html +2 -2
  19. package/docs/.vuepress/dist/nodes/ps-strategy-lowest-price.html +2 -2
  20. package/docs/.vuepress/dist/nodes/strategy-input.html +2 -2
  21. package/docs/changelog/README.md +19 -1
  22. package/package.json +3 -3
  23. package/src/handle-input.js +1 -1
  24. package/src/receive-price-functions.js +14 -10
  25. package/src/receive-price.js +2 -2
  26. package/src/strategy-lowest-price.html +1 -1
  27. package/src/strategy-lowest-price.js +2 -2
  28. package/test/data/converted-prices.json +1 -0
  29. package/test/data/tibber-data-end-0-24h.json +197 -0
  30. package/test/data/tibber-data-end-0.json +101 -0
  31. package/test/data/tibber-result-end-0-24h.json +320 -0
  32. package/test/data/tibber-result-end-0.json +168 -0
  33. package/test/receive-price-functions.test.js +20 -0
  34. package/test/receive-price.test.js +4 -4
  35. package/test/strategy-lowest-price.test.js +66 -0
  36. package/docs/.vuepress/dist/assets/js/runtime~app.cafd6537.js +0 -1
  37. package/docs/.vuepress/dist/assets/js/v-510ed0d4.204a09ec.js +0 -1
@@ -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) {
@@ -1 +0,0 @@
1
- (()=>{"use strict";var e,r,a,t={},o={};function n(e){var r=o[e];if(void 0!==r)return r.exports;var a=o[e]={exports:{}};return t[e].call(a.exports,a,a.exports,n),a.exports}n.m=t,e=[],n.O=(r,a,t,o)=>{if(!a){var d=1/0;for(v=0;v<e.length;v++){for(var[a,t,o]=e[v],i=!0,c=0;c<a.length;c++)(!1&o||d>=o)&&Object.keys(n.O).every((e=>n.O[e](a[c])))?a.splice(c--,1):(i=!1,o<d&&(d=o));if(i){e.splice(v--,1);var s=t();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]=[a,t,o]},n.d=(e,r)=>{for(var a in r)n.o(r,a)&&!n.o(e,a)&&Object.defineProperty(e,a,{enumerable:!0,get:r[a]})},n.f={},n.e=e=>Promise.all(Object.keys(n.f).reduce(((r,a)=>(n.f[a](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:"204a09ec",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={},a="node-red-contrib-power-saver:",n.l=(e,t,o,d)=>{if(r[e])r[e].push(t);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")==a+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",a+o),i.src=e),r[e]=[t];var b=(a,t)=>{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(t))),a)return a(t)},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,a)=>{var t=n.o(e,r)?e[r]:void 0;if(0!==t)if(t)a.push(t[2]);else if(/^(460|523)$/.test(r))e[r]=0;else{var o=new Promise(((a,o)=>t=e[r]=[a,o]));a.push(t[2]=o);var d=n.p+n.u(r),i=new Error;n.l(d,(a=>{if(n.o(e,r)&&(0!==(t=e[r])&&(e[r]=void 0),t)){var o=a&&("load"===a.type?"missing":a.type),d=a&&a.target&&a.target.src;i.message="Loading chunk "+r+" failed.\n("+o+": "+d+")",i.name="ChunkLoadError",i.type=o,i.request=d,t[1](i)}}),"chunk-"+r,r)}},n.O.j=r=>0===e[r];var r=(r,a)=>{var t,o,[d,i,c]=a,s=0;if(d.some((r=>0!==e[r]))){for(t in i)n.o(i,t)&&(n.m[t]=i[t]);if(c)var v=c(n)}for(r&&r(a);s<d.length;s++)o=d[s],n.o(e,o)&&e[o]&&e[o][0](),e[d[s]]=0;return n.O(v)},a=self.webpackChunknode_red_contrib_power_saver=self.webpackChunknode_red_contrib_power_saver||[];a.forEach(r.bind(null,0)),a.push=r.bind(null,a.push.bind(a))})()})();
@@ -1 +0,0 @@
1
- "use strict";(self.webpackChunknode_red_contrib_power_saver=self.webpackChunknode_red_contrib_power_saver||[]).push([[495],{3707:(e,i,a)=>{a.r(i),a.d(i,{data:()=>l});const l={key:"v-510ed0d4",path:"/changelog/",title:"Change Log",lang:"en-US",frontmatter:{sidebar:"auto"},excerpt:"",headers:[{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:1639408562e3,contributors:[{name:"Otto Paulsen",email:"ottpau@gmail.com",commits:2}]}}},5066:(e,i,a)=>{a.r(i),a.d(i,{default:()=>d});const l=(0,a(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-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>',22),t={},d=(0,a(3744).Z)(t,[["render",function(e,i){return l}]])},3744:(e,i)=>{i.Z=(e,i)=>{const a=e.__vccOpts||e;for(const[e,l]of i)a[e]=l;return a}}}]);