node-red-contrib-power-saver 5.1.3 → 5.1.4
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.
- package/package.json +2 -2
- package/src/handle-input.js +8 -7
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "node-red-contrib-power-saver",
|
|
3
|
-
"version": "5.1.
|
|
3
|
+
"version": "5.1.4",
|
|
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": {
|
|
@@ -66,7 +66,7 @@
|
|
|
66
66
|
"dependencies": {
|
|
67
67
|
"floating-vue": "5.2.2",
|
|
68
68
|
"lodash.clonedeep": "4.5.0",
|
|
69
|
-
"luxon": "3.
|
|
69
|
+
"luxon": "3.7.2",
|
|
70
70
|
"nano-time": "1.0.0"
|
|
71
71
|
}
|
|
72
72
|
}
|
package/src/handle-input.js
CHANGED
|
@@ -58,15 +58,16 @@ function makePlanFromPriceData(node, msg, config, doPlanning, calcSavings) {
|
|
|
58
58
|
const priceDatePerMinute = priceDataWithDayBefore.flatMap((d, i) => {
|
|
59
59
|
const res = [];
|
|
60
60
|
const start = DateTime.fromISO(d.start);
|
|
61
|
-
const end = DateTime.fromISO(d.end ?? priceDataWithDayBefore[i + 1].start)
|
|
62
|
-
if(!end) {
|
|
61
|
+
const end = DateTime.fromISO(d.end ?? priceDataWithDayBefore[i + 1].start);
|
|
62
|
+
if (!end) {
|
|
63
63
|
console.error("End time is missing for price data entry", d);
|
|
64
|
-
return res
|
|
64
|
+
return res;
|
|
65
65
|
}
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
66
|
+
const zone = start.zone;
|
|
67
|
+
const startMs = start.toMillis();
|
|
68
|
+
const endMs = end.toMillis();
|
|
69
|
+
for (let ms = startMs; ms < endMs; ms += 60000) {
|
|
70
|
+
res.push({ start: DateTime.fromMillis(ms, { zone }).toISO(), value: d.value });
|
|
70
71
|
}
|
|
71
72
|
return res;
|
|
72
73
|
});
|