myio-js-library 0.1.187 → 0.1.188
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 +266 -73
- package/dist/index.d.cts +26 -2
- package/dist/index.js +266 -73
- package/dist/myio-js-library.umd.js +266 -73
- package/dist/myio-js-library.umd.min.js +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -10274,18 +10274,22 @@ function generateBodyHTML(data) {
|
|
|
10274
10274
|
<div class="myio-device-comparison-tooltip__main-stats">
|
|
10275
10275
|
<div class="myio-device-comparison-tooltip__stat-card">
|
|
10276
10276
|
<div class="myio-device-comparison-tooltip__stat-label">Consumo</div>
|
|
10277
|
-
<div class="myio-device-comparison-tooltip__stat-value consumption">${formatConsumption(
|
|
10277
|
+
<div class="myio-device-comparison-tooltip__stat-value consumption">${formatConsumption(
|
|
10278
|
+
device.consumption
|
|
10279
|
+
)}</div>
|
|
10278
10280
|
</div>
|
|
10279
10281
|
<div class="myio-device-comparison-tooltip__stat-card">
|
|
10280
10282
|
<div class="myio-device-comparison-tooltip__stat-label">Participacao</div>
|
|
10281
|
-
<div class="myio-device-comparison-tooltip__stat-value percentage">${formatPercentage(
|
|
10283
|
+
<div class="myio-device-comparison-tooltip__stat-value percentage">${formatPercentage(
|
|
10284
|
+
device.percentage
|
|
10285
|
+
)}</div>
|
|
10282
10286
|
</div>
|
|
10283
10287
|
</div>
|
|
10284
10288
|
|
|
10285
10289
|
<!-- Section: Category Comparison -->
|
|
10286
10290
|
<div class="myio-device-comparison-tooltip__section-title">
|
|
10287
10291
|
<span class="myio-device-comparison-tooltip__section-icon">\u{1F4CA}</span>
|
|
10288
|
-
|
|
10292
|
+
Compara\xE7\xE3o por Tipo
|
|
10289
10293
|
</div>
|
|
10290
10294
|
<div class="myio-device-comparison-tooltip__comparison">
|
|
10291
10295
|
<div class="myio-device-comparison-tooltip__comparison-header">
|
|
@@ -10297,21 +10301,30 @@ function generateBodyHTML(data) {
|
|
|
10297
10301
|
</div>
|
|
10298
10302
|
<div class="myio-device-comparison-tooltip__progress-container">
|
|
10299
10303
|
<div class="myio-device-comparison-tooltip__progress-bar">
|
|
10300
|
-
<div class="myio-device-comparison-tooltip__progress-fill category" style="width: ${Math.min(
|
|
10304
|
+
<div class="myio-device-comparison-tooltip__progress-fill category" style="width: ${Math.min(
|
|
10305
|
+
categoryGroup.devicePercentage,
|
|
10306
|
+
100
|
|
10307
|
+
)}%"></div>
|
|
10301
10308
|
</div>
|
|
10302
10309
|
</div>
|
|
10303
10310
|
<div class="myio-device-comparison-tooltip__comparison-stats">
|
|
10304
10311
|
<div class="myio-device-comparison-tooltip__comparison-stat">
|
|
10305
10312
|
<div class="myio-device-comparison-tooltip__comparison-stat-label">Este Device</div>
|
|
10306
|
-
<div class="myio-device-comparison-tooltip__comparison-stat-value">${formatConsumption(
|
|
10313
|
+
<div class="myio-device-comparison-tooltip__comparison-stat-value">${formatConsumption(
|
|
10314
|
+
device.consumption
|
|
10315
|
+
)}</div>
|
|
10307
10316
|
</div>
|
|
10308
10317
|
<div class="myio-device-comparison-tooltip__comparison-stat">
|
|
10309
10318
|
<div class="myio-device-comparison-tooltip__comparison-stat-label">Total Grupo</div>
|
|
10310
|
-
<div class="myio-device-comparison-tooltip__comparison-stat-value">${formatConsumption(
|
|
10319
|
+
<div class="myio-device-comparison-tooltip__comparison-stat-value">${formatConsumption(
|
|
10320
|
+
categoryGroup.totalConsumption
|
|
10321
|
+
)}</div>
|
|
10311
10322
|
</div>
|
|
10312
10323
|
<div class="myio-device-comparison-tooltip__comparison-stat">
|
|
10313
10324
|
<div class="myio-device-comparison-tooltip__comparison-stat-label">Participacao</div>
|
|
10314
|
-
<div class="myio-device-comparison-tooltip__comparison-stat-value highlight">${formatPercentage(
|
|
10325
|
+
<div class="myio-device-comparison-tooltip__comparison-stat-value highlight">${formatPercentage(
|
|
10326
|
+
categoryGroup.devicePercentage
|
|
10327
|
+
)}</div>
|
|
10315
10328
|
</div>
|
|
10316
10329
|
</div>
|
|
10317
10330
|
</div>
|
|
@@ -10319,7 +10332,7 @@ function generateBodyHTML(data) {
|
|
|
10319
10332
|
<!-- Section: Widget Scope Comparison -->
|
|
10320
10333
|
<div class="myio-device-comparison-tooltip__section-title">
|
|
10321
10334
|
<span class="myio-device-comparison-tooltip__section-icon">\u{1F3E2}</span>
|
|
10322
|
-
|
|
10335
|
+
Compara\xE7\xE3o no Grupo
|
|
10323
10336
|
</div>
|
|
10324
10337
|
<div class="myio-device-comparison-tooltip__comparison">
|
|
10325
10338
|
<div class="myio-device-comparison-tooltip__comparison-header">
|
|
@@ -10331,21 +10344,30 @@ function generateBodyHTML(data) {
|
|
|
10331
10344
|
</div>
|
|
10332
10345
|
<div class="myio-device-comparison-tooltip__progress-container">
|
|
10333
10346
|
<div class="myio-device-comparison-tooltip__progress-bar">
|
|
10334
|
-
<div class="myio-device-comparison-tooltip__progress-fill widget" style="width: ${Math.min(
|
|
10347
|
+
<div class="myio-device-comparison-tooltip__progress-fill widget" style="width: ${Math.min(
|
|
10348
|
+
widgetScope.devicePercentage,
|
|
10349
|
+
100
|
|
10350
|
+
)}%"></div>
|
|
10335
10351
|
</div>
|
|
10336
10352
|
</div>
|
|
10337
10353
|
<div class="myio-device-comparison-tooltip__comparison-stats">
|
|
10338
10354
|
<div class="myio-device-comparison-tooltip__comparison-stat">
|
|
10339
10355
|
<div class="myio-device-comparison-tooltip__comparison-stat-label">Este Device</div>
|
|
10340
|
-
<div class="myio-device-comparison-tooltip__comparison-stat-value">${formatConsumption(
|
|
10356
|
+
<div class="myio-device-comparison-tooltip__comparison-stat-value">${formatConsumption(
|
|
10357
|
+
device.consumption
|
|
10358
|
+
)}</div>
|
|
10341
10359
|
</div>
|
|
10342
10360
|
<div class="myio-device-comparison-tooltip__comparison-stat">
|
|
10343
10361
|
<div class="myio-device-comparison-tooltip__comparison-stat-label">Total Widget</div>
|
|
10344
|
-
<div class="myio-device-comparison-tooltip__comparison-stat-value">${formatConsumption(
|
|
10362
|
+
<div class="myio-device-comparison-tooltip__comparison-stat-value">${formatConsumption(
|
|
10363
|
+
widgetScope.totalConsumption
|
|
10364
|
+
)}</div>
|
|
10345
10365
|
</div>
|
|
10346
10366
|
<div class="myio-device-comparison-tooltip__comparison-stat">
|
|
10347
10367
|
<div class="myio-device-comparison-tooltip__comparison-stat-label">Participacao</div>
|
|
10348
|
-
<div class="myio-device-comparison-tooltip__comparison-stat-value highlight">${formatPercentage(
|
|
10368
|
+
<div class="myio-device-comparison-tooltip__comparison-stat-value highlight">${formatPercentage(
|
|
10369
|
+
widgetScope.devicePercentage
|
|
10370
|
+
)}</div>
|
|
10349
10371
|
</div>
|
|
10350
10372
|
</div>
|
|
10351
10373
|
</div>
|
|
@@ -10353,7 +10375,7 @@ function generateBodyHTML(data) {
|
|
|
10353
10375
|
<!-- Section: Grand Total Comparison -->
|
|
10354
10376
|
<div class="myio-device-comparison-tooltip__section-title">
|
|
10355
10377
|
<span class="myio-device-comparison-tooltip__section-icon">\u{1F310}</span>
|
|
10356
|
-
|
|
10378
|
+
Compara\xE7\xE3o Total
|
|
10357
10379
|
</div>
|
|
10358
10380
|
<div class="myio-device-comparison-tooltip__comparison">
|
|
10359
10381
|
<div class="myio-device-comparison-tooltip__comparison-header">
|
|
@@ -10365,21 +10387,30 @@ function generateBodyHTML(data) {
|
|
|
10365
10387
|
</div>
|
|
10366
10388
|
<div class="myio-device-comparison-tooltip__progress-container">
|
|
10367
10389
|
<div class="myio-device-comparison-tooltip__progress-bar">
|
|
10368
|
-
<div class="myio-device-comparison-tooltip__progress-fill total" style="width: ${Math.min(
|
|
10390
|
+
<div class="myio-device-comparison-tooltip__progress-fill total" style="width: ${Math.min(
|
|
10391
|
+
grandTotal.devicePercentage,
|
|
10392
|
+
100
|
|
10393
|
+
)}%"></div>
|
|
10369
10394
|
</div>
|
|
10370
10395
|
</div>
|
|
10371
10396
|
<div class="myio-device-comparison-tooltip__comparison-stats">
|
|
10372
10397
|
<div class="myio-device-comparison-tooltip__comparison-stat">
|
|
10373
10398
|
<div class="myio-device-comparison-tooltip__comparison-stat-label">Este Device</div>
|
|
10374
|
-
<div class="myio-device-comparison-tooltip__comparison-stat-value">${formatConsumption(
|
|
10399
|
+
<div class="myio-device-comparison-tooltip__comparison-stat-value">${formatConsumption(
|
|
10400
|
+
device.consumption
|
|
10401
|
+
)}</div>
|
|
10375
10402
|
</div>
|
|
10376
10403
|
<div class="myio-device-comparison-tooltip__comparison-stat">
|
|
10377
10404
|
<div class="myio-device-comparison-tooltip__comparison-stat-label">Total Geral</div>
|
|
10378
|
-
<div class="myio-device-comparison-tooltip__comparison-stat-value">${formatConsumption(
|
|
10405
|
+
<div class="myio-device-comparison-tooltip__comparison-stat-value">${formatConsumption(
|
|
10406
|
+
grandTotal.totalConsumption
|
|
10407
|
+
)}</div>
|
|
10379
10408
|
</div>
|
|
10380
10409
|
<div class="myio-device-comparison-tooltip__comparison-stat">
|
|
10381
10410
|
<div class="myio-device-comparison-tooltip__comparison-stat-label">Participacao</div>
|
|
10382
|
-
<div class="myio-device-comparison-tooltip__comparison-stat-value highlight">${formatPercentage(
|
|
10411
|
+
<div class="myio-device-comparison-tooltip__comparison-stat-value highlight">${formatPercentage(
|
|
10412
|
+
grandTotal.devicePercentage
|
|
10413
|
+
)}</div>
|
|
10383
10414
|
</div>
|
|
10384
10415
|
</div>
|
|
10385
10416
|
</div>
|
|
@@ -34233,8 +34264,11 @@ var EnergySummaryTooltip = {
|
|
|
34233
34264
|
/**
|
|
34234
34265
|
* Build summary data from TELEMETRY_INFO STATE
|
|
34235
34266
|
* This is called by the widget controller to get data for the tooltip
|
|
34267
|
+
*
|
|
34268
|
+
* RFC-0105 Enhancement: Now fetches device lists from MyIOOrchestratorData
|
|
34269
|
+
* to populate device lists for status popup display
|
|
34236
34270
|
*/
|
|
34237
|
-
buildSummaryFromState(state5, receivedData) {
|
|
34271
|
+
buildSummaryFromState(state5, receivedData, domain = "energy") {
|
|
34238
34272
|
const summary = {
|
|
34239
34273
|
totalDevices: 0,
|
|
34240
34274
|
totalConsumption: 0,
|
|
@@ -34246,7 +34280,14 @@ var EnergySummaryTooltip = {
|
|
|
34246
34280
|
failure: 0,
|
|
34247
34281
|
standby: 0,
|
|
34248
34282
|
offline: 0,
|
|
34249
|
-
noConsumption: 0
|
|
34283
|
+
noConsumption: 0,
|
|
34284
|
+
// Device lists - populated from orchestrator data
|
|
34285
|
+
normalDevices: [],
|
|
34286
|
+
alertDevices: [],
|
|
34287
|
+
failureDevices: [],
|
|
34288
|
+
standbyDevices: [],
|
|
34289
|
+
offlineDevices: [],
|
|
34290
|
+
noConsumptionDevices: []
|
|
34250
34291
|
},
|
|
34251
34292
|
lastUpdated: (/* @__PURE__ */ new Date()).toISOString()
|
|
34252
34293
|
};
|
|
@@ -34363,38 +34404,106 @@ var EnergySummaryTooltip = {
|
|
|
34363
34404
|
summary.byCategory = [entrada, lojas, areaComum];
|
|
34364
34405
|
summary.totalDevices = entrada.deviceCount + lojas.deviceCount + areaComumDeviceCount;
|
|
34365
34406
|
summary.totalConsumption = state5.grandTotal || entrada.consumption;
|
|
34366
|
-
const
|
|
34367
|
-
|
|
34368
|
-
|
|
34369
|
-
summary.byStatus = {
|
|
34370
|
-
normal: statusData.normal || 0,
|
|
34371
|
-
alert: statusData.alert || 0,
|
|
34372
|
-
failure: statusData.failure || 0,
|
|
34373
|
-
standby: statusData.standby || 0,
|
|
34374
|
-
offline: statusData.offline || 0,
|
|
34375
|
-
noConsumption: statusData.noConsumption || statusData.zeroConsumption || 0
|
|
34376
|
-
};
|
|
34407
|
+
const statusAggregation = this._aggregateDeviceStatusFromOrchestrator(domain);
|
|
34408
|
+
if (statusAggregation.hasData) {
|
|
34409
|
+
summary.byStatus = statusAggregation.byStatus;
|
|
34377
34410
|
} else {
|
|
34378
|
-
|
|
34379
|
-
|
|
34380
|
-
|
|
34381
|
-
|
|
34382
|
-
|
|
34383
|
-
|
|
34384
|
-
|
|
34385
|
-
|
|
34386
|
-
|
|
34387
|
-
|
|
34388
|
-
|
|
34389
|
-
|
|
34390
|
-
|
|
34391
|
-
|
|
34392
|
-
|
|
34393
|
-
|
|
34394
|
-
|
|
34395
|
-
|
|
34411
|
+
const totalDevices = summary.totalDevices;
|
|
34412
|
+
const statusData = receivedData?.statusCounts || receivedData?.deviceStatus || null;
|
|
34413
|
+
if (statusData && typeof statusData === "object") {
|
|
34414
|
+
summary.byStatus = {
|
|
34415
|
+
normal: statusData.normal || 0,
|
|
34416
|
+
alert: statusData.alert || 0,
|
|
34417
|
+
failure: statusData.failure || 0,
|
|
34418
|
+
standby: statusData.standby || 0,
|
|
34419
|
+
offline: statusData.offline || 0,
|
|
34420
|
+
noConsumption: statusData.noConsumption || statusData.zeroConsumption || 0
|
|
34421
|
+
};
|
|
34422
|
+
} else {
|
|
34423
|
+
summary.byStatus = {
|
|
34424
|
+
normal: Math.floor(totalDevices * 0.75),
|
|
34425
|
+
alert: Math.floor(totalDevices * 0.06),
|
|
34426
|
+
failure: Math.floor(totalDevices * 0.02),
|
|
34427
|
+
standby: Math.floor(totalDevices * 0.02),
|
|
34428
|
+
offline: Math.floor(totalDevices * 0.03),
|
|
34429
|
+
noConsumption: Math.floor(totalDevices * 0.12)
|
|
34430
|
+
};
|
|
34431
|
+
const statusSum = Object.values(summary.byStatus).reduce((a, b) => {
|
|
34432
|
+
return typeof b === "number" ? a + b : a;
|
|
34433
|
+
}, 0);
|
|
34434
|
+
if (statusSum !== totalDevices && totalDevices > 0) {
|
|
34435
|
+
summary.byStatus.normal += totalDevices - statusSum;
|
|
34436
|
+
}
|
|
34437
|
+
}
|
|
34396
34438
|
}
|
|
34397
34439
|
return summary;
|
|
34440
|
+
},
|
|
34441
|
+
/**
|
|
34442
|
+
* RFC-0105: Aggregate device status from MyIOOrchestratorData
|
|
34443
|
+
* Iterates through all orchestrator items and groups devices by status
|
|
34444
|
+
* Returns both counts and device lists
|
|
34445
|
+
*/
|
|
34446
|
+
_aggregateDeviceStatusFromOrchestrator(domain = "energy") {
|
|
34447
|
+
const result = {
|
|
34448
|
+
normal: 0,
|
|
34449
|
+
alert: 0,
|
|
34450
|
+
failure: 0,
|
|
34451
|
+
standby: 0,
|
|
34452
|
+
offline: 0,
|
|
34453
|
+
noConsumption: 0,
|
|
34454
|
+
normalDevices: [],
|
|
34455
|
+
alertDevices: [],
|
|
34456
|
+
failureDevices: [],
|
|
34457
|
+
standbyDevices: [],
|
|
34458
|
+
offlineDevices: [],
|
|
34459
|
+
noConsumptionDevices: []
|
|
34460
|
+
};
|
|
34461
|
+
const win = typeof window !== "undefined" ? window : null;
|
|
34462
|
+
if (!win) return { hasData: false, byStatus: result };
|
|
34463
|
+
const orchestratorData = win.MyIOOrchestratorData || win.parent?.MyIOOrchestratorData;
|
|
34464
|
+
if (!orchestratorData || !orchestratorData[domain]) {
|
|
34465
|
+
return { hasData: false, byStatus: result };
|
|
34466
|
+
}
|
|
34467
|
+
const domainData = orchestratorData[domain];
|
|
34468
|
+
const items = domainData.items || [];
|
|
34469
|
+
if (!items || items.length === 0) {
|
|
34470
|
+
return { hasData: false, byStatus: result };
|
|
34471
|
+
}
|
|
34472
|
+
const NO_CONSUMPTION_THRESHOLD = 0.01;
|
|
34473
|
+
const statusMapping = {
|
|
34474
|
+
"power_on": "normal",
|
|
34475
|
+
"warning": "alert",
|
|
34476
|
+
"failure": "failure",
|
|
34477
|
+
"standby": "standby",
|
|
34478
|
+
"power_off": "offline",
|
|
34479
|
+
"maintenance": "offline",
|
|
34480
|
+
"no_info": "offline",
|
|
34481
|
+
"not_installed": "offline",
|
|
34482
|
+
"offline": "offline"
|
|
34483
|
+
};
|
|
34484
|
+
items.forEach((item) => {
|
|
34485
|
+
const deviceInfo = {
|
|
34486
|
+
id: item.id || item.deviceId || "",
|
|
34487
|
+
label: item.label || item.entityLabel || item.name || item.deviceIdentifier || "",
|
|
34488
|
+
name: item.name || item.entityLabel || ""
|
|
34489
|
+
};
|
|
34490
|
+
const deviceStatus = item.deviceStatus || "no_info";
|
|
34491
|
+
const value = Number(item.value || item.val || 0);
|
|
34492
|
+
const isOnline = !["no_info", "offline", "not_installed", "maintenance", "power_off"].includes(deviceStatus);
|
|
34493
|
+
if (isOnline && Math.abs(value) < NO_CONSUMPTION_THRESHOLD) {
|
|
34494
|
+
result.noConsumption++;
|
|
34495
|
+
result.noConsumptionDevices?.push(deviceInfo);
|
|
34496
|
+
return;
|
|
34497
|
+
}
|
|
34498
|
+
const mappedStatus = statusMapping[deviceStatus] || "offline";
|
|
34499
|
+
result[mappedStatus]++;
|
|
34500
|
+
const deviceListKey = `${mappedStatus}Devices`;
|
|
34501
|
+
const deviceList = result[deviceListKey];
|
|
34502
|
+
if (deviceList) {
|
|
34503
|
+
deviceList.push(deviceInfo);
|
|
34504
|
+
}
|
|
34505
|
+
});
|
|
34506
|
+
return { hasData: true, byStatus: result };
|
|
34398
34507
|
}
|
|
34399
34508
|
};
|
|
34400
34509
|
|
|
@@ -35552,8 +35661,11 @@ var WaterSummaryTooltip = {
|
|
|
35552
35661
|
/**
|
|
35553
35662
|
* Build summary data from TELEMETRY_INFO STATE_WATER
|
|
35554
35663
|
* This is called by the widget controller to get data for the tooltip
|
|
35664
|
+
*
|
|
35665
|
+
* RFC-0105 Enhancement: Now fetches device lists from MyIOOrchestratorData
|
|
35666
|
+
* to populate device lists for status popup display
|
|
35555
35667
|
*/
|
|
35556
|
-
buildSummaryFromState(state5, receivedData, includeBathrooms = false) {
|
|
35668
|
+
buildSummaryFromState(state5, receivedData, includeBathrooms = false, domain = "water") {
|
|
35557
35669
|
const summary = {
|
|
35558
35670
|
totalDevices: 0,
|
|
35559
35671
|
totalConsumption: 0,
|
|
@@ -35565,7 +35677,14 @@ var WaterSummaryTooltip = {
|
|
|
35565
35677
|
failure: 0,
|
|
35566
35678
|
standby: 0,
|
|
35567
35679
|
offline: 0,
|
|
35568
|
-
noConsumption: 0
|
|
35680
|
+
noConsumption: 0,
|
|
35681
|
+
// Device lists - populated from orchestrator data
|
|
35682
|
+
normalDevices: [],
|
|
35683
|
+
alertDevices: [],
|
|
35684
|
+
failureDevices: [],
|
|
35685
|
+
standbyDevices: [],
|
|
35686
|
+
offlineDevices: [],
|
|
35687
|
+
noConsumptionDevices: []
|
|
35569
35688
|
},
|
|
35570
35689
|
lastUpdated: (/* @__PURE__ */ new Date()).toISOString(),
|
|
35571
35690
|
includeBathrooms
|
|
@@ -35621,32 +35740,106 @@ var WaterSummaryTooltip = {
|
|
|
35621
35740
|
}
|
|
35622
35741
|
summary.totalDevices = summary.byCategory.reduce((sum, cat) => sum + cat.deviceCount, 0);
|
|
35623
35742
|
summary.totalConsumption = state5.entrada?.total || 0;
|
|
35624
|
-
const
|
|
35625
|
-
|
|
35626
|
-
|
|
35627
|
-
summary.byStatus = {
|
|
35628
|
-
normal: statusData.normal || 0,
|
|
35629
|
-
alert: statusData.alert || 0,
|
|
35630
|
-
failure: statusData.failure || 0,
|
|
35631
|
-
standby: statusData.standby || 0,
|
|
35632
|
-
offline: statusData.offline || 0,
|
|
35633
|
-
noConsumption: statusData.noConsumption || statusData.zeroConsumption || 0
|
|
35634
|
-
};
|
|
35743
|
+
const statusAggregation = this._aggregateDeviceStatusFromOrchestrator(domain);
|
|
35744
|
+
if (statusAggregation.hasData) {
|
|
35745
|
+
summary.byStatus = statusAggregation.byStatus;
|
|
35635
35746
|
} else {
|
|
35636
|
-
|
|
35637
|
-
|
|
35638
|
-
|
|
35639
|
-
|
|
35640
|
-
|
|
35641
|
-
|
|
35642
|
-
|
|
35643
|
-
|
|
35644
|
-
|
|
35645
|
-
|
|
35646
|
-
|
|
35647
|
-
|
|
35747
|
+
const totalDevices = summary.totalDevices;
|
|
35748
|
+
const statusData = receivedData?.statusCounts || receivedData?.deviceStatus || null;
|
|
35749
|
+
if (statusData && typeof statusData === "object") {
|
|
35750
|
+
summary.byStatus = {
|
|
35751
|
+
normal: statusData.normal || 0,
|
|
35752
|
+
alert: statusData.alert || 0,
|
|
35753
|
+
failure: statusData.failure || 0,
|
|
35754
|
+
standby: statusData.standby || 0,
|
|
35755
|
+
offline: statusData.offline || 0,
|
|
35756
|
+
noConsumption: statusData.noConsumption || statusData.zeroConsumption || 0
|
|
35757
|
+
};
|
|
35758
|
+
} else {
|
|
35759
|
+
summary.byStatus = {
|
|
35760
|
+
normal: Math.floor(totalDevices * 0.8),
|
|
35761
|
+
alert: Math.floor(totalDevices * 0.05),
|
|
35762
|
+
failure: Math.floor(totalDevices * 0.02),
|
|
35763
|
+
standby: Math.floor(totalDevices * 0.02),
|
|
35764
|
+
offline: Math.floor(totalDevices * 0.03),
|
|
35765
|
+
noConsumption: Math.floor(totalDevices * 0.08)
|
|
35766
|
+
};
|
|
35767
|
+
const statusSum = Object.values(summary.byStatus).reduce((a, b) => {
|
|
35768
|
+
return typeof b === "number" ? a + b : a;
|
|
35769
|
+
}, 0);
|
|
35770
|
+
if (statusSum !== totalDevices && totalDevices > 0) {
|
|
35771
|
+
summary.byStatus.normal += totalDevices - statusSum;
|
|
35772
|
+
}
|
|
35773
|
+
}
|
|
35648
35774
|
}
|
|
35649
35775
|
return summary;
|
|
35776
|
+
},
|
|
35777
|
+
/**
|
|
35778
|
+
* RFC-0105: Aggregate device status from MyIOOrchestratorData
|
|
35779
|
+
* Iterates through all orchestrator items and groups devices by status
|
|
35780
|
+
* Returns both counts and device lists
|
|
35781
|
+
*/
|
|
35782
|
+
_aggregateDeviceStatusFromOrchestrator(domain = "water") {
|
|
35783
|
+
const result = {
|
|
35784
|
+
normal: 0,
|
|
35785
|
+
alert: 0,
|
|
35786
|
+
failure: 0,
|
|
35787
|
+
standby: 0,
|
|
35788
|
+
offline: 0,
|
|
35789
|
+
noConsumption: 0,
|
|
35790
|
+
normalDevices: [],
|
|
35791
|
+
alertDevices: [],
|
|
35792
|
+
failureDevices: [],
|
|
35793
|
+
standbyDevices: [],
|
|
35794
|
+
offlineDevices: [],
|
|
35795
|
+
noConsumptionDevices: []
|
|
35796
|
+
};
|
|
35797
|
+
const win = typeof window !== "undefined" ? window : null;
|
|
35798
|
+
if (!win) return { hasData: false, byStatus: result };
|
|
35799
|
+
const orchestratorData = win.MyIOOrchestratorData || win.parent?.MyIOOrchestratorData;
|
|
35800
|
+
if (!orchestratorData || !orchestratorData[domain]) {
|
|
35801
|
+
return { hasData: false, byStatus: result };
|
|
35802
|
+
}
|
|
35803
|
+
const domainData = orchestratorData[domain];
|
|
35804
|
+
const items = domainData.items || [];
|
|
35805
|
+
if (!items || items.length === 0) {
|
|
35806
|
+
return { hasData: false, byStatus: result };
|
|
35807
|
+
}
|
|
35808
|
+
const NO_CONSUMPTION_THRESHOLD = 1e-3;
|
|
35809
|
+
const statusMapping = {
|
|
35810
|
+
"power_on": "normal",
|
|
35811
|
+
"warning": "alert",
|
|
35812
|
+
"failure": "failure",
|
|
35813
|
+
"standby": "standby",
|
|
35814
|
+
"power_off": "offline",
|
|
35815
|
+
"maintenance": "offline",
|
|
35816
|
+
"no_info": "offline",
|
|
35817
|
+
"not_installed": "offline",
|
|
35818
|
+
"offline": "offline"
|
|
35819
|
+
};
|
|
35820
|
+
items.forEach((item) => {
|
|
35821
|
+
const deviceInfo = {
|
|
35822
|
+
id: item.id || item.deviceId || "",
|
|
35823
|
+
label: item.label || item.entityLabel || item.name || item.deviceIdentifier || "",
|
|
35824
|
+
name: item.name || item.entityLabel || ""
|
|
35825
|
+
};
|
|
35826
|
+
const deviceStatus = item.deviceStatus || "no_info";
|
|
35827
|
+
const value = Number(item.value || item.val || 0);
|
|
35828
|
+
const isOnline = !["no_info", "offline", "not_installed", "maintenance", "power_off"].includes(deviceStatus);
|
|
35829
|
+
if (isOnline && Math.abs(value) < NO_CONSUMPTION_THRESHOLD) {
|
|
35830
|
+
result.noConsumption++;
|
|
35831
|
+
result.noConsumptionDevices?.push(deviceInfo);
|
|
35832
|
+
return;
|
|
35833
|
+
}
|
|
35834
|
+
const mappedStatus = statusMapping[deviceStatus] || "offline";
|
|
35835
|
+
result[mappedStatus]++;
|
|
35836
|
+
const deviceListKey = `${mappedStatus}Devices`;
|
|
35837
|
+
const deviceList = result[deviceListKey];
|
|
35838
|
+
if (deviceList) {
|
|
35839
|
+
deviceList.push(deviceInfo);
|
|
35840
|
+
}
|
|
35841
|
+
});
|
|
35842
|
+
return { hasData: true, byStatus: result };
|
|
35650
35843
|
}
|
|
35651
35844
|
};
|
|
35652
35845
|
|
package/dist/index.d.cts
CHANGED
|
@@ -3248,8 +3248,20 @@ declare const EnergySummaryTooltip: {
|
|
|
3248
3248
|
/**
|
|
3249
3249
|
* Build summary data from TELEMETRY_INFO STATE
|
|
3250
3250
|
* This is called by the widget controller to get data for the tooltip
|
|
3251
|
+
*
|
|
3252
|
+
* RFC-0105 Enhancement: Now fetches device lists from MyIOOrchestratorData
|
|
3253
|
+
* to populate device lists for status popup display
|
|
3254
|
+
*/
|
|
3255
|
+
buildSummaryFromState(state: any, receivedData: any, domain?: string): DashboardEnergySummary;
|
|
3256
|
+
/**
|
|
3257
|
+
* RFC-0105: Aggregate device status from MyIOOrchestratorData
|
|
3258
|
+
* Iterates through all orchestrator items and groups devices by status
|
|
3259
|
+
* Returns both counts and device lists
|
|
3251
3260
|
*/
|
|
3252
|
-
|
|
3261
|
+
_aggregateDeviceStatusFromOrchestrator(domain?: string): {
|
|
3262
|
+
hasData: boolean;
|
|
3263
|
+
byStatus: StatusSummary$1;
|
|
3264
|
+
};
|
|
3253
3265
|
};
|
|
3254
3266
|
|
|
3255
3267
|
/**
|
|
@@ -3433,8 +3445,20 @@ declare const WaterSummaryTooltip: {
|
|
|
3433
3445
|
/**
|
|
3434
3446
|
* Build summary data from TELEMETRY_INFO STATE_WATER
|
|
3435
3447
|
* This is called by the widget controller to get data for the tooltip
|
|
3448
|
+
*
|
|
3449
|
+
* RFC-0105 Enhancement: Now fetches device lists from MyIOOrchestratorData
|
|
3450
|
+
* to populate device lists for status popup display
|
|
3451
|
+
*/
|
|
3452
|
+
buildSummaryFromState(state: any, receivedData: any, includeBathrooms?: boolean, domain?: string): DashboardWaterSummary;
|
|
3453
|
+
/**
|
|
3454
|
+
* RFC-0105: Aggregate device status from MyIOOrchestratorData
|
|
3455
|
+
* Iterates through all orchestrator items and groups devices by status
|
|
3456
|
+
* Returns both counts and device lists
|
|
3436
3457
|
*/
|
|
3437
|
-
|
|
3458
|
+
_aggregateDeviceStatusFromOrchestrator(domain?: string): {
|
|
3459
|
+
hasData: boolean;
|
|
3460
|
+
byStatus: StatusSummary;
|
|
3461
|
+
};
|
|
3438
3462
|
};
|
|
3439
3463
|
|
|
3440
3464
|
/**
|