myio-js-library 0.1.187 → 0.1.189
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 +298 -69
- package/dist/index.d.cts +26 -2
- package/dist/index.js +298 -69
- package/dist/myio-js-library.umd.js +298 -69
- 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,124 @@ 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
|
-
if (statusData && typeof statusData === "object") {
|
|
34407
|
+
const widgetAggregation = receivedData?.deviceStatusAggregation;
|
|
34408
|
+
if (widgetAggregation && widgetAggregation.hasData) {
|
|
34369
34409
|
summary.byStatus = {
|
|
34370
|
-
normal:
|
|
34371
|
-
alert:
|
|
34372
|
-
failure:
|
|
34373
|
-
standby:
|
|
34374
|
-
offline:
|
|
34375
|
-
noConsumption:
|
|
34410
|
+
normal: widgetAggregation.normal || 0,
|
|
34411
|
+
alert: widgetAggregation.alert || 0,
|
|
34412
|
+
failure: widgetAggregation.failure || 0,
|
|
34413
|
+
standby: widgetAggregation.standby || 0,
|
|
34414
|
+
offline: widgetAggregation.offline || 0,
|
|
34415
|
+
noConsumption: widgetAggregation.noConsumption || 0,
|
|
34416
|
+
normalDevices: widgetAggregation.normalDevices || [],
|
|
34417
|
+
alertDevices: widgetAggregation.alertDevices || [],
|
|
34418
|
+
failureDevices: widgetAggregation.failureDevices || [],
|
|
34419
|
+
standbyDevices: widgetAggregation.standbyDevices || [],
|
|
34420
|
+
offlineDevices: widgetAggregation.offlineDevices || [],
|
|
34421
|
+
noConsumptionDevices: widgetAggregation.noConsumptionDevices || []
|
|
34376
34422
|
};
|
|
34377
34423
|
} else {
|
|
34378
|
-
|
|
34379
|
-
|
|
34380
|
-
|
|
34381
|
-
|
|
34382
|
-
|
|
34383
|
-
|
|
34384
|
-
|
|
34385
|
-
|
|
34386
|
-
|
|
34387
|
-
|
|
34388
|
-
|
|
34389
|
-
|
|
34390
|
-
|
|
34391
|
-
|
|
34392
|
-
|
|
34393
|
-
|
|
34394
|
-
|
|
34395
|
-
|
|
34424
|
+
const statusAggregation = this._aggregateDeviceStatusFromOrchestrator(domain);
|
|
34425
|
+
if (statusAggregation.hasData) {
|
|
34426
|
+
summary.byStatus = statusAggregation.byStatus;
|
|
34427
|
+
} else {
|
|
34428
|
+
const totalDevices = summary.totalDevices;
|
|
34429
|
+
const statusData = receivedData?.statusCounts || receivedData?.deviceStatus || null;
|
|
34430
|
+
if (statusData && typeof statusData === "object") {
|
|
34431
|
+
summary.byStatus = {
|
|
34432
|
+
normal: statusData.normal || 0,
|
|
34433
|
+
alert: statusData.alert || 0,
|
|
34434
|
+
failure: statusData.failure || 0,
|
|
34435
|
+
standby: statusData.standby || 0,
|
|
34436
|
+
offline: statusData.offline || 0,
|
|
34437
|
+
noConsumption: statusData.noConsumption || statusData.zeroConsumption || 0
|
|
34438
|
+
};
|
|
34439
|
+
} else {
|
|
34440
|
+
summary.byStatus = {
|
|
34441
|
+
normal: Math.floor(totalDevices * 0.75),
|
|
34442
|
+
alert: Math.floor(totalDevices * 0.06),
|
|
34443
|
+
failure: Math.floor(totalDevices * 0.02),
|
|
34444
|
+
standby: Math.floor(totalDevices * 0.02),
|
|
34445
|
+
offline: Math.floor(totalDevices * 0.03),
|
|
34446
|
+
noConsumption: Math.floor(totalDevices * 0.12)
|
|
34447
|
+
};
|
|
34448
|
+
const statusSum = Object.values(summary.byStatus).reduce((a, b) => {
|
|
34449
|
+
return typeof b === "number" ? a + b : a;
|
|
34450
|
+
}, 0);
|
|
34451
|
+
if (statusSum !== totalDevices && totalDevices > 0) {
|
|
34452
|
+
summary.byStatus.normal += totalDevices - statusSum;
|
|
34453
|
+
}
|
|
34454
|
+
}
|
|
34455
|
+
}
|
|
34396
34456
|
}
|
|
34397
34457
|
return summary;
|
|
34458
|
+
},
|
|
34459
|
+
/**
|
|
34460
|
+
* RFC-0105: Aggregate device status from MyIOOrchestratorData
|
|
34461
|
+
* Iterates through all orchestrator items and groups devices by status
|
|
34462
|
+
* Returns both counts and device lists
|
|
34463
|
+
*/
|
|
34464
|
+
_aggregateDeviceStatusFromOrchestrator(domain = "energy") {
|
|
34465
|
+
const result = {
|
|
34466
|
+
normal: 0,
|
|
34467
|
+
alert: 0,
|
|
34468
|
+
failure: 0,
|
|
34469
|
+
standby: 0,
|
|
34470
|
+
offline: 0,
|
|
34471
|
+
noConsumption: 0,
|
|
34472
|
+
normalDevices: [],
|
|
34473
|
+
alertDevices: [],
|
|
34474
|
+
failureDevices: [],
|
|
34475
|
+
standbyDevices: [],
|
|
34476
|
+
offlineDevices: [],
|
|
34477
|
+
noConsumptionDevices: []
|
|
34478
|
+
};
|
|
34479
|
+
const win = typeof window !== "undefined" ? window : null;
|
|
34480
|
+
if (!win) return { hasData: false, byStatus: result };
|
|
34481
|
+
const orchestratorData = win.MyIOOrchestratorData || win.parent?.MyIOOrchestratorData;
|
|
34482
|
+
if (!orchestratorData || !orchestratorData[domain]) {
|
|
34483
|
+
return { hasData: false, byStatus: result };
|
|
34484
|
+
}
|
|
34485
|
+
const domainData = orchestratorData[domain];
|
|
34486
|
+
const items = domainData.items || [];
|
|
34487
|
+
if (!items || items.length === 0) {
|
|
34488
|
+
return { hasData: false, byStatus: result };
|
|
34489
|
+
}
|
|
34490
|
+
const NO_CONSUMPTION_THRESHOLD = 0.01;
|
|
34491
|
+
const statusMapping = {
|
|
34492
|
+
"power_on": "normal",
|
|
34493
|
+
"warning": "alert",
|
|
34494
|
+
"failure": "failure",
|
|
34495
|
+
"standby": "standby",
|
|
34496
|
+
"power_off": "offline",
|
|
34497
|
+
"maintenance": "offline",
|
|
34498
|
+
"no_info": "offline",
|
|
34499
|
+
"not_installed": "offline",
|
|
34500
|
+
"offline": "offline"
|
|
34501
|
+
};
|
|
34502
|
+
items.forEach((item) => {
|
|
34503
|
+
const deviceInfo = {
|
|
34504
|
+
id: item.id || item.deviceId || "",
|
|
34505
|
+
label: item.label || item.entityLabel || item.name || item.deviceIdentifier || "",
|
|
34506
|
+
name: item.name || item.entityLabel || ""
|
|
34507
|
+
};
|
|
34508
|
+
const deviceStatus = item.deviceStatus || "no_info";
|
|
34509
|
+
const value = Number(item.value || item.val || 0);
|
|
34510
|
+
const isOnline = !["no_info", "offline", "not_installed", "maintenance", "power_off"].includes(deviceStatus);
|
|
34511
|
+
if (isOnline && Math.abs(value) < NO_CONSUMPTION_THRESHOLD) {
|
|
34512
|
+
result.noConsumption++;
|
|
34513
|
+
result.noConsumptionDevices?.push(deviceInfo);
|
|
34514
|
+
return;
|
|
34515
|
+
}
|
|
34516
|
+
const mappedStatus = statusMapping[deviceStatus] || "offline";
|
|
34517
|
+
result[mappedStatus]++;
|
|
34518
|
+
const deviceListKey = `${mappedStatus}Devices`;
|
|
34519
|
+
const deviceList = result[deviceListKey];
|
|
34520
|
+
if (deviceList) {
|
|
34521
|
+
deviceList.push(deviceInfo);
|
|
34522
|
+
}
|
|
34523
|
+
});
|
|
34524
|
+
return { hasData: true, byStatus: result };
|
|
34398
34525
|
}
|
|
34399
34526
|
};
|
|
34400
34527
|
|
|
@@ -35552,8 +35679,11 @@ var WaterSummaryTooltip = {
|
|
|
35552
35679
|
/**
|
|
35553
35680
|
* Build summary data from TELEMETRY_INFO STATE_WATER
|
|
35554
35681
|
* This is called by the widget controller to get data for the tooltip
|
|
35682
|
+
*
|
|
35683
|
+
* RFC-0105 Enhancement: Now fetches device lists from MyIOOrchestratorData
|
|
35684
|
+
* to populate device lists for status popup display
|
|
35555
35685
|
*/
|
|
35556
|
-
buildSummaryFromState(state5, receivedData, includeBathrooms = false) {
|
|
35686
|
+
buildSummaryFromState(state5, receivedData, includeBathrooms = false, domain = "water") {
|
|
35557
35687
|
const summary = {
|
|
35558
35688
|
totalDevices: 0,
|
|
35559
35689
|
totalConsumption: 0,
|
|
@@ -35565,7 +35695,14 @@ var WaterSummaryTooltip = {
|
|
|
35565
35695
|
failure: 0,
|
|
35566
35696
|
standby: 0,
|
|
35567
35697
|
offline: 0,
|
|
35568
|
-
noConsumption: 0
|
|
35698
|
+
noConsumption: 0,
|
|
35699
|
+
// Device lists - populated from orchestrator data
|
|
35700
|
+
normalDevices: [],
|
|
35701
|
+
alertDevices: [],
|
|
35702
|
+
failureDevices: [],
|
|
35703
|
+
standbyDevices: [],
|
|
35704
|
+
offlineDevices: [],
|
|
35705
|
+
noConsumptionDevices: []
|
|
35569
35706
|
},
|
|
35570
35707
|
lastUpdated: (/* @__PURE__ */ new Date()).toISOString(),
|
|
35571
35708
|
includeBathrooms
|
|
@@ -35621,32 +35758,124 @@ var WaterSummaryTooltip = {
|
|
|
35621
35758
|
}
|
|
35622
35759
|
summary.totalDevices = summary.byCategory.reduce((sum, cat) => sum + cat.deviceCount, 0);
|
|
35623
35760
|
summary.totalConsumption = state5.entrada?.total || 0;
|
|
35624
|
-
const
|
|
35625
|
-
|
|
35626
|
-
if (statusData && typeof statusData === "object") {
|
|
35761
|
+
const widgetAggregation = receivedData?.deviceStatusAggregation;
|
|
35762
|
+
if (widgetAggregation && widgetAggregation.hasData) {
|
|
35627
35763
|
summary.byStatus = {
|
|
35628
|
-
normal:
|
|
35629
|
-
alert:
|
|
35630
|
-
failure:
|
|
35631
|
-
standby:
|
|
35632
|
-
offline:
|
|
35633
|
-
noConsumption:
|
|
35764
|
+
normal: widgetAggregation.normal || 0,
|
|
35765
|
+
alert: widgetAggregation.alert || 0,
|
|
35766
|
+
failure: widgetAggregation.failure || 0,
|
|
35767
|
+
standby: widgetAggregation.standby || 0,
|
|
35768
|
+
offline: widgetAggregation.offline || 0,
|
|
35769
|
+
noConsumption: widgetAggregation.noConsumption || 0,
|
|
35770
|
+
normalDevices: widgetAggregation.normalDevices || [],
|
|
35771
|
+
alertDevices: widgetAggregation.alertDevices || [],
|
|
35772
|
+
failureDevices: widgetAggregation.failureDevices || [],
|
|
35773
|
+
standbyDevices: widgetAggregation.standbyDevices || [],
|
|
35774
|
+
offlineDevices: widgetAggregation.offlineDevices || [],
|
|
35775
|
+
noConsumptionDevices: widgetAggregation.noConsumptionDevices || []
|
|
35634
35776
|
};
|
|
35635
35777
|
} else {
|
|
35636
|
-
|
|
35637
|
-
|
|
35638
|
-
|
|
35639
|
-
|
|
35640
|
-
|
|
35641
|
-
|
|
35642
|
-
|
|
35643
|
-
|
|
35644
|
-
|
|
35645
|
-
|
|
35646
|
-
|
|
35647
|
-
|
|
35778
|
+
const statusAggregation = this._aggregateDeviceStatusFromOrchestrator(domain);
|
|
35779
|
+
if (statusAggregation.hasData) {
|
|
35780
|
+
summary.byStatus = statusAggregation.byStatus;
|
|
35781
|
+
} else {
|
|
35782
|
+
const totalDevices = summary.totalDevices;
|
|
35783
|
+
const statusData = receivedData?.statusCounts || receivedData?.deviceStatus || null;
|
|
35784
|
+
if (statusData && typeof statusData === "object") {
|
|
35785
|
+
summary.byStatus = {
|
|
35786
|
+
normal: statusData.normal || 0,
|
|
35787
|
+
alert: statusData.alert || 0,
|
|
35788
|
+
failure: statusData.failure || 0,
|
|
35789
|
+
standby: statusData.standby || 0,
|
|
35790
|
+
offline: statusData.offline || 0,
|
|
35791
|
+
noConsumption: statusData.noConsumption || statusData.zeroConsumption || 0
|
|
35792
|
+
};
|
|
35793
|
+
} else {
|
|
35794
|
+
summary.byStatus = {
|
|
35795
|
+
normal: Math.floor(totalDevices * 0.8),
|
|
35796
|
+
alert: Math.floor(totalDevices * 0.05),
|
|
35797
|
+
failure: Math.floor(totalDevices * 0.02),
|
|
35798
|
+
standby: Math.floor(totalDevices * 0.02),
|
|
35799
|
+
offline: Math.floor(totalDevices * 0.03),
|
|
35800
|
+
noConsumption: Math.floor(totalDevices * 0.08)
|
|
35801
|
+
};
|
|
35802
|
+
const statusSum = Object.values(summary.byStatus).reduce((a, b) => {
|
|
35803
|
+
return typeof b === "number" ? a + b : a;
|
|
35804
|
+
}, 0);
|
|
35805
|
+
if (statusSum !== totalDevices && totalDevices > 0) {
|
|
35806
|
+
summary.byStatus.normal += totalDevices - statusSum;
|
|
35807
|
+
}
|
|
35808
|
+
}
|
|
35809
|
+
}
|
|
35648
35810
|
}
|
|
35649
35811
|
return summary;
|
|
35812
|
+
},
|
|
35813
|
+
/**
|
|
35814
|
+
* RFC-0105: Aggregate device status from MyIOOrchestratorData
|
|
35815
|
+
* Iterates through all orchestrator items and groups devices by status
|
|
35816
|
+
* Returns both counts and device lists
|
|
35817
|
+
*/
|
|
35818
|
+
_aggregateDeviceStatusFromOrchestrator(domain = "water") {
|
|
35819
|
+
const result = {
|
|
35820
|
+
normal: 0,
|
|
35821
|
+
alert: 0,
|
|
35822
|
+
failure: 0,
|
|
35823
|
+
standby: 0,
|
|
35824
|
+
offline: 0,
|
|
35825
|
+
noConsumption: 0,
|
|
35826
|
+
normalDevices: [],
|
|
35827
|
+
alertDevices: [],
|
|
35828
|
+
failureDevices: [],
|
|
35829
|
+
standbyDevices: [],
|
|
35830
|
+
offlineDevices: [],
|
|
35831
|
+
noConsumptionDevices: []
|
|
35832
|
+
};
|
|
35833
|
+
const win = typeof window !== "undefined" ? window : null;
|
|
35834
|
+
if (!win) return { hasData: false, byStatus: result };
|
|
35835
|
+
const orchestratorData = win.MyIOOrchestratorData || win.parent?.MyIOOrchestratorData;
|
|
35836
|
+
if (!orchestratorData || !orchestratorData[domain]) {
|
|
35837
|
+
return { hasData: false, byStatus: result };
|
|
35838
|
+
}
|
|
35839
|
+
const domainData = orchestratorData[domain];
|
|
35840
|
+
const items = domainData.items || [];
|
|
35841
|
+
if (!items || items.length === 0) {
|
|
35842
|
+
return { hasData: false, byStatus: result };
|
|
35843
|
+
}
|
|
35844
|
+
const NO_CONSUMPTION_THRESHOLD = 1e-3;
|
|
35845
|
+
const statusMapping = {
|
|
35846
|
+
"power_on": "normal",
|
|
35847
|
+
"warning": "alert",
|
|
35848
|
+
"failure": "failure",
|
|
35849
|
+
"standby": "standby",
|
|
35850
|
+
"power_off": "offline",
|
|
35851
|
+
"maintenance": "offline",
|
|
35852
|
+
"no_info": "offline",
|
|
35853
|
+
"not_installed": "offline",
|
|
35854
|
+
"offline": "offline"
|
|
35855
|
+
};
|
|
35856
|
+
items.forEach((item) => {
|
|
35857
|
+
const deviceInfo = {
|
|
35858
|
+
id: item.id || item.deviceId || "",
|
|
35859
|
+
label: item.label || item.entityLabel || item.name || item.deviceIdentifier || "",
|
|
35860
|
+
name: item.name || item.entityLabel || ""
|
|
35861
|
+
};
|
|
35862
|
+
const deviceStatus = item.deviceStatus || "no_info";
|
|
35863
|
+
const value = Number(item.value || item.val || 0);
|
|
35864
|
+
const isOnline = !["no_info", "offline", "not_installed", "maintenance", "power_off"].includes(deviceStatus);
|
|
35865
|
+
if (isOnline && Math.abs(value) < NO_CONSUMPTION_THRESHOLD) {
|
|
35866
|
+
result.noConsumption++;
|
|
35867
|
+
result.noConsumptionDevices?.push(deviceInfo);
|
|
35868
|
+
return;
|
|
35869
|
+
}
|
|
35870
|
+
const mappedStatus = statusMapping[deviceStatus] || "offline";
|
|
35871
|
+
result[mappedStatus]++;
|
|
35872
|
+
const deviceListKey = `${mappedStatus}Devices`;
|
|
35873
|
+
const deviceList = result[deviceListKey];
|
|
35874
|
+
if (deviceList) {
|
|
35875
|
+
deviceList.push(deviceInfo);
|
|
35876
|
+
}
|
|
35877
|
+
});
|
|
35878
|
+
return { hasData: true, byStatus: result };
|
|
35650
35879
|
}
|
|
35651
35880
|
};
|
|
35652
35881
|
|
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
|
/**
|