node-red-contrib-power-saver 5.1.0 → 5.1.1
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 +1 -1
- package/src/handle-output.js +10 -10
- package/src/light-saver-functions.js +246 -196
- package/src/light-saver.js +255 -219
- package/src/receive-price-functions.js +1 -1
- package/src/schedule-merger-functions.js +3 -3
package/package.json
CHANGED
package/src/handle-output.js
CHANGED
|
@@ -123,30 +123,30 @@ function collapseMinutes(minutes) {
|
|
|
123
123
|
|
|
124
124
|
const result = [];
|
|
125
125
|
let currentValue = minutes[0];
|
|
126
|
-
let count = 1;
|
|
127
126
|
let startIndex = 0;
|
|
128
127
|
|
|
129
128
|
for (let i = 1; i < minutes.length; i++) {
|
|
130
|
-
if (itemsEqual(minutes[i], currentValue)) {
|
|
131
|
-
|
|
132
|
-
|
|
129
|
+
if (!itemsEqual(minutes[i], currentValue)) {
|
|
130
|
+
const groupStartMs = new Date(currentValue.start).getTime();
|
|
131
|
+
const nextStartMs = new Date(minutes[i].start).getTime();
|
|
132
|
+
const count = Math.round((nextStartMs - groupStartMs) / 60000);
|
|
133
133
|
result.push({ ...currentValue, count, startIndex });
|
|
134
134
|
currentValue = minutes[i];
|
|
135
|
-
count = 1;
|
|
136
135
|
startIndex = i;
|
|
137
136
|
}
|
|
138
137
|
}
|
|
139
138
|
|
|
140
|
-
|
|
141
|
-
|
|
139
|
+
const lastRecord = minutes[minutes.length - 1];
|
|
140
|
+
const lastCount = lastRecord.end
|
|
141
|
+
? Math.round((new Date(lastRecord.end).getTime() - new Date(currentValue.start).getTime()) / 60000)
|
|
142
|
+
: null;
|
|
143
|
+
result.push({ ...currentValue, count: lastCount, startIndex });
|
|
142
144
|
return result;
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
145
|
}
|
|
147
146
|
|
|
148
147
|
module.exports = {
|
|
149
148
|
handleOutput,
|
|
150
149
|
shallSendOutput,
|
|
151
150
|
strategyShallSendSchedule,
|
|
151
|
+
collapseMinutes,
|
|
152
152
|
};
|