myio-js-library 0.1.71 → 0.1.73
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/dist/index.cjs +42 -28
- package/dist/index.d.cts +1 -0
- package/dist/index.js +42 -28
- package/dist/myio-js-library.umd.js +42 -28
- package/dist/myio-js-library.umd.min.js +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -11401,11 +11401,13 @@ async function fetchTelemetryData(token, deviceId, startDate, endDate, queryPara
|
|
|
11401
11401
|
const data = await response.json();
|
|
11402
11402
|
return data;
|
|
11403
11403
|
}
|
|
11404
|
-
function processMultiSeriesChartData(rawData, keys, correctionFactor, locale) {
|
|
11404
|
+
function processMultiSeriesChartData(rawData, keys, correctionFactor, locale, aggregation, timezoneOffset) {
|
|
11405
11405
|
const seriesKeys = keys.split(",").map((k) => k.trim());
|
|
11406
11406
|
const seriesData = [];
|
|
11407
11407
|
let globalPeak = null;
|
|
11408
11408
|
let isEmpty = true;
|
|
11409
|
+
const tzOffset = timezoneOffset !== void 0 ? timezoneOffset : -3;
|
|
11410
|
+
const tzOffsetMs = tzOffset * 60 * 60 * 1e3;
|
|
11409
11411
|
const colors = ["#4A148C", "#2196F3", "#4CAF50", "#FF9800", "#F44336", "#9C27B0", "#795548", "#607D8B"];
|
|
11410
11412
|
seriesKeys.forEach((key, index) => {
|
|
11411
11413
|
const rawSeries = rawData[key] || [];
|
|
@@ -11416,25 +11418,39 @@ function processMultiSeriesChartData(rawData, keys, correctionFactor, locale) {
|
|
|
11416
11418
|
isEmpty = false;
|
|
11417
11419
|
const sortedData = rawSeries.sort((a, b) => a.ts - b.ts);
|
|
11418
11420
|
const points = [];
|
|
11419
|
-
|
|
11420
|
-
|
|
11421
|
-
|
|
11422
|
-
|
|
11423
|
-
|
|
11424
|
-
|
|
11425
|
-
|
|
11426
|
-
|
|
11427
|
-
|
|
11428
|
-
|
|
11429
|
-
|
|
11430
|
-
|
|
11431
|
-
|
|
11432
|
-
|
|
11433
|
-
|
|
11421
|
+
const isAggregated = aggregation && aggregation !== "NONE";
|
|
11422
|
+
if (isAggregated) {
|
|
11423
|
+
for (let i = 0; i < sortedData.length; i++) {
|
|
11424
|
+
const current = sortedData[i];
|
|
11425
|
+
const value = parseFloat(current.value) * correctionFactor;
|
|
11426
|
+
const timestamp = current.ts + tzOffsetMs;
|
|
11427
|
+
points.push({
|
|
11428
|
+
x: timestamp,
|
|
11429
|
+
y: value
|
|
11430
|
+
});
|
|
11431
|
+
}
|
|
11432
|
+
} else {
|
|
11433
|
+
let previousValue = 0;
|
|
11434
|
+
let previousTs = 0;
|
|
11435
|
+
for (let i = 0; i < sortedData.length; i++) {
|
|
11436
|
+
const current = sortedData[i];
|
|
11437
|
+
const currentValue = parseFloat(current.value);
|
|
11438
|
+
const currentTs = current.ts;
|
|
11439
|
+
if (i > 0) {
|
|
11440
|
+
const deltaWh = currentValue - previousValue;
|
|
11441
|
+
const deltaHours = (currentTs - previousTs) / (1e3 * 60 * 60);
|
|
11442
|
+
if (deltaWh > 0 && deltaHours > 0) {
|
|
11443
|
+
const demandKw = deltaWh / 1e3 / deltaHours * correctionFactor;
|
|
11444
|
+
const timestamp = currentTs + tzOffsetMs;
|
|
11445
|
+
points.push({
|
|
11446
|
+
x: timestamp,
|
|
11447
|
+
y: demandKw
|
|
11448
|
+
});
|
|
11449
|
+
}
|
|
11434
11450
|
}
|
|
11451
|
+
previousValue = currentValue;
|
|
11452
|
+
previousTs = currentTs;
|
|
11435
11453
|
}
|
|
11436
|
-
previousValue = currentValue;
|
|
11437
|
-
previousTs = currentTs;
|
|
11438
11454
|
}
|
|
11439
11455
|
let seriesPeak = null;
|
|
11440
11456
|
if (points.length > 0) {
|
|
@@ -11816,7 +11832,11 @@ async function openDemandModal(params) {
|
|
|
11816
11832
|
rawData,
|
|
11817
11833
|
params.telemetryQuery?.keys || "consumption",
|
|
11818
11834
|
params.correctionFactor || 1,
|
|
11819
|
-
locale
|
|
11835
|
+
locale,
|
|
11836
|
+
params.telemetryQuery?.agg || "MAX",
|
|
11837
|
+
// Pass aggregation type
|
|
11838
|
+
params.timezoneOffset
|
|
11839
|
+
// Pass timezone offset (default: -3)
|
|
11820
11840
|
);
|
|
11821
11841
|
if (chartData.isEmpty) {
|
|
11822
11842
|
errorEl.style.display = "flex";
|
|
@@ -11856,9 +11876,7 @@ async function openDemandModal(params) {
|
|
|
11856
11876
|
return date.toLocaleDateString(locale, {
|
|
11857
11877
|
day: "2-digit",
|
|
11858
11878
|
month: "2-digit",
|
|
11859
|
-
year: "numeric"
|
|
11860
|
-
hour: "2-digit",
|
|
11861
|
-
minute: "2-digit"
|
|
11879
|
+
year: "numeric"
|
|
11862
11880
|
});
|
|
11863
11881
|
},
|
|
11864
11882
|
label: function(context) {
|
|
@@ -11898,9 +11916,7 @@ async function openDemandModal(params) {
|
|
|
11898
11916
|
return date.toLocaleDateString(locale, {
|
|
11899
11917
|
day: "2-digit",
|
|
11900
11918
|
month: "2-digit",
|
|
11901
|
-
year: "numeric"
|
|
11902
|
-
hour: "2-digit",
|
|
11903
|
-
minute: "2-digit"
|
|
11919
|
+
year: "numeric"
|
|
11904
11920
|
});
|
|
11905
11921
|
},
|
|
11906
11922
|
label: function(context) {
|
|
@@ -11936,10 +11952,8 @@ async function openDemandModal(params) {
|
|
|
11936
11952
|
callback: function(value) {
|
|
11937
11953
|
const date = new Date(value);
|
|
11938
11954
|
return date.toLocaleDateString(locale, {
|
|
11939
|
-
month: "2-digit",
|
|
11940
11955
|
day: "2-digit",
|
|
11941
|
-
|
|
11942
|
-
minute: "2-digit"
|
|
11956
|
+
month: "2-digit"
|
|
11943
11957
|
});
|
|
11944
11958
|
}
|
|
11945
11959
|
}
|
package/dist/index.d.cts
CHANGED
package/dist/index.js
CHANGED
|
@@ -11327,11 +11327,13 @@ async function fetchTelemetryData(token, deviceId, startDate, endDate, queryPara
|
|
|
11327
11327
|
const data = await response.json();
|
|
11328
11328
|
return data;
|
|
11329
11329
|
}
|
|
11330
|
-
function processMultiSeriesChartData(rawData, keys, correctionFactor, locale) {
|
|
11330
|
+
function processMultiSeriesChartData(rawData, keys, correctionFactor, locale, aggregation, timezoneOffset) {
|
|
11331
11331
|
const seriesKeys = keys.split(",").map((k) => k.trim());
|
|
11332
11332
|
const seriesData = [];
|
|
11333
11333
|
let globalPeak = null;
|
|
11334
11334
|
let isEmpty = true;
|
|
11335
|
+
const tzOffset = timezoneOffset !== void 0 ? timezoneOffset : -3;
|
|
11336
|
+
const tzOffsetMs = tzOffset * 60 * 60 * 1e3;
|
|
11335
11337
|
const colors = ["#4A148C", "#2196F3", "#4CAF50", "#FF9800", "#F44336", "#9C27B0", "#795548", "#607D8B"];
|
|
11336
11338
|
seriesKeys.forEach((key, index) => {
|
|
11337
11339
|
const rawSeries = rawData[key] || [];
|
|
@@ -11342,25 +11344,39 @@ function processMultiSeriesChartData(rawData, keys, correctionFactor, locale) {
|
|
|
11342
11344
|
isEmpty = false;
|
|
11343
11345
|
const sortedData = rawSeries.sort((a, b) => a.ts - b.ts);
|
|
11344
11346
|
const points = [];
|
|
11345
|
-
|
|
11346
|
-
|
|
11347
|
-
|
|
11348
|
-
|
|
11349
|
-
|
|
11350
|
-
|
|
11351
|
-
|
|
11352
|
-
|
|
11353
|
-
|
|
11354
|
-
|
|
11355
|
-
|
|
11356
|
-
|
|
11357
|
-
|
|
11358
|
-
|
|
11359
|
-
|
|
11347
|
+
const isAggregated = aggregation && aggregation !== "NONE";
|
|
11348
|
+
if (isAggregated) {
|
|
11349
|
+
for (let i = 0; i < sortedData.length; i++) {
|
|
11350
|
+
const current = sortedData[i];
|
|
11351
|
+
const value = parseFloat(current.value) * correctionFactor;
|
|
11352
|
+
const timestamp = current.ts + tzOffsetMs;
|
|
11353
|
+
points.push({
|
|
11354
|
+
x: timestamp,
|
|
11355
|
+
y: value
|
|
11356
|
+
});
|
|
11357
|
+
}
|
|
11358
|
+
} else {
|
|
11359
|
+
let previousValue = 0;
|
|
11360
|
+
let previousTs = 0;
|
|
11361
|
+
for (let i = 0; i < sortedData.length; i++) {
|
|
11362
|
+
const current = sortedData[i];
|
|
11363
|
+
const currentValue = parseFloat(current.value);
|
|
11364
|
+
const currentTs = current.ts;
|
|
11365
|
+
if (i > 0) {
|
|
11366
|
+
const deltaWh = currentValue - previousValue;
|
|
11367
|
+
const deltaHours = (currentTs - previousTs) / (1e3 * 60 * 60);
|
|
11368
|
+
if (deltaWh > 0 && deltaHours > 0) {
|
|
11369
|
+
const demandKw = deltaWh / 1e3 / deltaHours * correctionFactor;
|
|
11370
|
+
const timestamp = currentTs + tzOffsetMs;
|
|
11371
|
+
points.push({
|
|
11372
|
+
x: timestamp,
|
|
11373
|
+
y: demandKw
|
|
11374
|
+
});
|
|
11375
|
+
}
|
|
11360
11376
|
}
|
|
11377
|
+
previousValue = currentValue;
|
|
11378
|
+
previousTs = currentTs;
|
|
11361
11379
|
}
|
|
11362
|
-
previousValue = currentValue;
|
|
11363
|
-
previousTs = currentTs;
|
|
11364
11380
|
}
|
|
11365
11381
|
let seriesPeak = null;
|
|
11366
11382
|
if (points.length > 0) {
|
|
@@ -11742,7 +11758,11 @@ async function openDemandModal(params) {
|
|
|
11742
11758
|
rawData,
|
|
11743
11759
|
params.telemetryQuery?.keys || "consumption",
|
|
11744
11760
|
params.correctionFactor || 1,
|
|
11745
|
-
locale
|
|
11761
|
+
locale,
|
|
11762
|
+
params.telemetryQuery?.agg || "MAX",
|
|
11763
|
+
// Pass aggregation type
|
|
11764
|
+
params.timezoneOffset
|
|
11765
|
+
// Pass timezone offset (default: -3)
|
|
11746
11766
|
);
|
|
11747
11767
|
if (chartData.isEmpty) {
|
|
11748
11768
|
errorEl.style.display = "flex";
|
|
@@ -11782,9 +11802,7 @@ async function openDemandModal(params) {
|
|
|
11782
11802
|
return date.toLocaleDateString(locale, {
|
|
11783
11803
|
day: "2-digit",
|
|
11784
11804
|
month: "2-digit",
|
|
11785
|
-
year: "numeric"
|
|
11786
|
-
hour: "2-digit",
|
|
11787
|
-
minute: "2-digit"
|
|
11805
|
+
year: "numeric"
|
|
11788
11806
|
});
|
|
11789
11807
|
},
|
|
11790
11808
|
label: function(context) {
|
|
@@ -11824,9 +11842,7 @@ async function openDemandModal(params) {
|
|
|
11824
11842
|
return date.toLocaleDateString(locale, {
|
|
11825
11843
|
day: "2-digit",
|
|
11826
11844
|
month: "2-digit",
|
|
11827
|
-
year: "numeric"
|
|
11828
|
-
hour: "2-digit",
|
|
11829
|
-
minute: "2-digit"
|
|
11845
|
+
year: "numeric"
|
|
11830
11846
|
});
|
|
11831
11847
|
},
|
|
11832
11848
|
label: function(context) {
|
|
@@ -11862,10 +11878,8 @@ async function openDemandModal(params) {
|
|
|
11862
11878
|
callback: function(value) {
|
|
11863
11879
|
const date = new Date(value);
|
|
11864
11880
|
return date.toLocaleDateString(locale, {
|
|
11865
|
-
month: "2-digit",
|
|
11866
11881
|
day: "2-digit",
|
|
11867
|
-
|
|
11868
|
-
minute: "2-digit"
|
|
11882
|
+
month: "2-digit"
|
|
11869
11883
|
});
|
|
11870
11884
|
}
|
|
11871
11885
|
}
|
|
@@ -11316,11 +11316,13 @@
|
|
|
11316
11316
|
const data = await response.json();
|
|
11317
11317
|
return data;
|
|
11318
11318
|
}
|
|
11319
|
-
function processMultiSeriesChartData(rawData, keys, correctionFactor, locale) {
|
|
11319
|
+
function processMultiSeriesChartData(rawData, keys, correctionFactor, locale, aggregation, timezoneOffset) {
|
|
11320
11320
|
const seriesKeys = keys.split(",").map((k) => k.trim());
|
|
11321
11321
|
const seriesData = [];
|
|
11322
11322
|
let globalPeak = null;
|
|
11323
11323
|
let isEmpty = true;
|
|
11324
|
+
const tzOffset = timezoneOffset !== void 0 ? timezoneOffset : -3;
|
|
11325
|
+
const tzOffsetMs = tzOffset * 60 * 60 * 1e3;
|
|
11324
11326
|
const colors = ["#4A148C", "#2196F3", "#4CAF50", "#FF9800", "#F44336", "#9C27B0", "#795548", "#607D8B"];
|
|
11325
11327
|
seriesKeys.forEach((key, index) => {
|
|
11326
11328
|
const rawSeries = rawData[key] || [];
|
|
@@ -11331,25 +11333,39 @@
|
|
|
11331
11333
|
isEmpty = false;
|
|
11332
11334
|
const sortedData = rawSeries.sort((a, b) => a.ts - b.ts);
|
|
11333
11335
|
const points = [];
|
|
11334
|
-
|
|
11335
|
-
|
|
11336
|
-
|
|
11337
|
-
|
|
11338
|
-
|
|
11339
|
-
|
|
11340
|
-
|
|
11341
|
-
|
|
11342
|
-
|
|
11343
|
-
|
|
11344
|
-
|
|
11345
|
-
|
|
11346
|
-
|
|
11347
|
-
|
|
11348
|
-
|
|
11336
|
+
const isAggregated = aggregation !== "NONE";
|
|
11337
|
+
if (isAggregated) {
|
|
11338
|
+
for (let i = 0; i < sortedData.length; i++) {
|
|
11339
|
+
const current = sortedData[i];
|
|
11340
|
+
const value = parseFloat(current.value) * correctionFactor;
|
|
11341
|
+
const timestamp = current.ts + tzOffsetMs;
|
|
11342
|
+
points.push({
|
|
11343
|
+
x: timestamp,
|
|
11344
|
+
y: value
|
|
11345
|
+
});
|
|
11346
|
+
}
|
|
11347
|
+
} else {
|
|
11348
|
+
let previousValue = 0;
|
|
11349
|
+
let previousTs = 0;
|
|
11350
|
+
for (let i = 0; i < sortedData.length; i++) {
|
|
11351
|
+
const current = sortedData[i];
|
|
11352
|
+
const currentValue = parseFloat(current.value);
|
|
11353
|
+
const currentTs = current.ts;
|
|
11354
|
+
if (i > 0) {
|
|
11355
|
+
const deltaWh = currentValue - previousValue;
|
|
11356
|
+
const deltaHours = (currentTs - previousTs) / (1e3 * 60 * 60);
|
|
11357
|
+
if (deltaWh > 0 && deltaHours > 0) {
|
|
11358
|
+
const demandKw = deltaWh / 1e3 / deltaHours * correctionFactor;
|
|
11359
|
+
const timestamp = currentTs + tzOffsetMs;
|
|
11360
|
+
points.push({
|
|
11361
|
+
x: timestamp,
|
|
11362
|
+
y: demandKw
|
|
11363
|
+
});
|
|
11364
|
+
}
|
|
11349
11365
|
}
|
|
11366
|
+
previousValue = currentValue;
|
|
11367
|
+
previousTs = currentTs;
|
|
11350
11368
|
}
|
|
11351
|
-
previousValue = currentValue;
|
|
11352
|
-
previousTs = currentTs;
|
|
11353
11369
|
}
|
|
11354
11370
|
let seriesPeak = null;
|
|
11355
11371
|
if (points.length > 0) {
|
|
@@ -11731,7 +11747,11 @@
|
|
|
11731
11747
|
rawData,
|
|
11732
11748
|
params.telemetryQuery?.keys || "consumption",
|
|
11733
11749
|
params.correctionFactor || 1,
|
|
11734
|
-
locale
|
|
11750
|
+
locale,
|
|
11751
|
+
params.telemetryQuery?.agg || "MAX",
|
|
11752
|
+
// Pass aggregation type
|
|
11753
|
+
params.timezoneOffset
|
|
11754
|
+
// Pass timezone offset (default: -3)
|
|
11735
11755
|
);
|
|
11736
11756
|
if (chartData.isEmpty) {
|
|
11737
11757
|
errorEl.style.display = "flex";
|
|
@@ -11771,9 +11791,7 @@
|
|
|
11771
11791
|
return date.toLocaleDateString(locale, {
|
|
11772
11792
|
day: "2-digit",
|
|
11773
11793
|
month: "2-digit",
|
|
11774
|
-
year: "numeric"
|
|
11775
|
-
hour: "2-digit",
|
|
11776
|
-
minute: "2-digit"
|
|
11794
|
+
year: "numeric"
|
|
11777
11795
|
});
|
|
11778
11796
|
},
|
|
11779
11797
|
label: function(context) {
|
|
@@ -11813,9 +11831,7 @@
|
|
|
11813
11831
|
return date.toLocaleDateString(locale, {
|
|
11814
11832
|
day: "2-digit",
|
|
11815
11833
|
month: "2-digit",
|
|
11816
|
-
year: "numeric"
|
|
11817
|
-
hour: "2-digit",
|
|
11818
|
-
minute: "2-digit"
|
|
11834
|
+
year: "numeric"
|
|
11819
11835
|
});
|
|
11820
11836
|
},
|
|
11821
11837
|
label: function(context) {
|
|
@@ -11851,10 +11867,8 @@
|
|
|
11851
11867
|
callback: function(value) {
|
|
11852
11868
|
const date = new Date(value);
|
|
11853
11869
|
return date.toLocaleDateString(locale, {
|
|
11854
|
-
month: "2-digit",
|
|
11855
11870
|
day: "2-digit",
|
|
11856
|
-
|
|
11857
|
-
minute: "2-digit"
|
|
11871
|
+
month: "2-digit"
|
|
11858
11872
|
});
|
|
11859
11873
|
}
|
|
11860
11874
|
}
|