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.js
CHANGED
|
@@ -10105,18 +10105,22 @@ function generateBodyHTML(data) {
|
|
|
10105
10105
|
<div class="myio-device-comparison-tooltip__main-stats">
|
|
10106
10106
|
<div class="myio-device-comparison-tooltip__stat-card">
|
|
10107
10107
|
<div class="myio-device-comparison-tooltip__stat-label">Consumo</div>
|
|
10108
|
-
<div class="myio-device-comparison-tooltip__stat-value consumption">${formatConsumption(
|
|
10108
|
+
<div class="myio-device-comparison-tooltip__stat-value consumption">${formatConsumption(
|
|
10109
|
+
device.consumption
|
|
10110
|
+
)}</div>
|
|
10109
10111
|
</div>
|
|
10110
10112
|
<div class="myio-device-comparison-tooltip__stat-card">
|
|
10111
10113
|
<div class="myio-device-comparison-tooltip__stat-label">Participacao</div>
|
|
10112
|
-
<div class="myio-device-comparison-tooltip__stat-value percentage">${formatPercentage(
|
|
10114
|
+
<div class="myio-device-comparison-tooltip__stat-value percentage">${formatPercentage(
|
|
10115
|
+
device.percentage
|
|
10116
|
+
)}</div>
|
|
10113
10117
|
</div>
|
|
10114
10118
|
</div>
|
|
10115
10119
|
|
|
10116
10120
|
<!-- Section: Category Comparison -->
|
|
10117
10121
|
<div class="myio-device-comparison-tooltip__section-title">
|
|
10118
10122
|
<span class="myio-device-comparison-tooltip__section-icon">\u{1F4CA}</span>
|
|
10119
|
-
|
|
10123
|
+
Compara\xE7\xE3o por Tipo
|
|
10120
10124
|
</div>
|
|
10121
10125
|
<div class="myio-device-comparison-tooltip__comparison">
|
|
10122
10126
|
<div class="myio-device-comparison-tooltip__comparison-header">
|
|
@@ -10128,21 +10132,30 @@ function generateBodyHTML(data) {
|
|
|
10128
10132
|
</div>
|
|
10129
10133
|
<div class="myio-device-comparison-tooltip__progress-container">
|
|
10130
10134
|
<div class="myio-device-comparison-tooltip__progress-bar">
|
|
10131
|
-
<div class="myio-device-comparison-tooltip__progress-fill category" style="width: ${Math.min(
|
|
10135
|
+
<div class="myio-device-comparison-tooltip__progress-fill category" style="width: ${Math.min(
|
|
10136
|
+
categoryGroup.devicePercentage,
|
|
10137
|
+
100
|
|
10138
|
+
)}%"></div>
|
|
10132
10139
|
</div>
|
|
10133
10140
|
</div>
|
|
10134
10141
|
<div class="myio-device-comparison-tooltip__comparison-stats">
|
|
10135
10142
|
<div class="myio-device-comparison-tooltip__comparison-stat">
|
|
10136
10143
|
<div class="myio-device-comparison-tooltip__comparison-stat-label">Este Device</div>
|
|
10137
|
-
<div class="myio-device-comparison-tooltip__comparison-stat-value">${formatConsumption(
|
|
10144
|
+
<div class="myio-device-comparison-tooltip__comparison-stat-value">${formatConsumption(
|
|
10145
|
+
device.consumption
|
|
10146
|
+
)}</div>
|
|
10138
10147
|
</div>
|
|
10139
10148
|
<div class="myio-device-comparison-tooltip__comparison-stat">
|
|
10140
10149
|
<div class="myio-device-comparison-tooltip__comparison-stat-label">Total Grupo</div>
|
|
10141
|
-
<div class="myio-device-comparison-tooltip__comparison-stat-value">${formatConsumption(
|
|
10150
|
+
<div class="myio-device-comparison-tooltip__comparison-stat-value">${formatConsumption(
|
|
10151
|
+
categoryGroup.totalConsumption
|
|
10152
|
+
)}</div>
|
|
10142
10153
|
</div>
|
|
10143
10154
|
<div class="myio-device-comparison-tooltip__comparison-stat">
|
|
10144
10155
|
<div class="myio-device-comparison-tooltip__comparison-stat-label">Participacao</div>
|
|
10145
|
-
<div class="myio-device-comparison-tooltip__comparison-stat-value highlight">${formatPercentage(
|
|
10156
|
+
<div class="myio-device-comparison-tooltip__comparison-stat-value highlight">${formatPercentage(
|
|
10157
|
+
categoryGroup.devicePercentage
|
|
10158
|
+
)}</div>
|
|
10146
10159
|
</div>
|
|
10147
10160
|
</div>
|
|
10148
10161
|
</div>
|
|
@@ -10150,7 +10163,7 @@ function generateBodyHTML(data) {
|
|
|
10150
10163
|
<!-- Section: Widget Scope Comparison -->
|
|
10151
10164
|
<div class="myio-device-comparison-tooltip__section-title">
|
|
10152
10165
|
<span class="myio-device-comparison-tooltip__section-icon">\u{1F3E2}</span>
|
|
10153
|
-
|
|
10166
|
+
Compara\xE7\xE3o no Grupo
|
|
10154
10167
|
</div>
|
|
10155
10168
|
<div class="myio-device-comparison-tooltip__comparison">
|
|
10156
10169
|
<div class="myio-device-comparison-tooltip__comparison-header">
|
|
@@ -10162,21 +10175,30 @@ function generateBodyHTML(data) {
|
|
|
10162
10175
|
</div>
|
|
10163
10176
|
<div class="myio-device-comparison-tooltip__progress-container">
|
|
10164
10177
|
<div class="myio-device-comparison-tooltip__progress-bar">
|
|
10165
|
-
<div class="myio-device-comparison-tooltip__progress-fill widget" style="width: ${Math.min(
|
|
10178
|
+
<div class="myio-device-comparison-tooltip__progress-fill widget" style="width: ${Math.min(
|
|
10179
|
+
widgetScope.devicePercentage,
|
|
10180
|
+
100
|
|
10181
|
+
)}%"></div>
|
|
10166
10182
|
</div>
|
|
10167
10183
|
</div>
|
|
10168
10184
|
<div class="myio-device-comparison-tooltip__comparison-stats">
|
|
10169
10185
|
<div class="myio-device-comparison-tooltip__comparison-stat">
|
|
10170
10186
|
<div class="myio-device-comparison-tooltip__comparison-stat-label">Este Device</div>
|
|
10171
|
-
<div class="myio-device-comparison-tooltip__comparison-stat-value">${formatConsumption(
|
|
10187
|
+
<div class="myio-device-comparison-tooltip__comparison-stat-value">${formatConsumption(
|
|
10188
|
+
device.consumption
|
|
10189
|
+
)}</div>
|
|
10172
10190
|
</div>
|
|
10173
10191
|
<div class="myio-device-comparison-tooltip__comparison-stat">
|
|
10174
10192
|
<div class="myio-device-comparison-tooltip__comparison-stat-label">Total Widget</div>
|
|
10175
|
-
<div class="myio-device-comparison-tooltip__comparison-stat-value">${formatConsumption(
|
|
10193
|
+
<div class="myio-device-comparison-tooltip__comparison-stat-value">${formatConsumption(
|
|
10194
|
+
widgetScope.totalConsumption
|
|
10195
|
+
)}</div>
|
|
10176
10196
|
</div>
|
|
10177
10197
|
<div class="myio-device-comparison-tooltip__comparison-stat">
|
|
10178
10198
|
<div class="myio-device-comparison-tooltip__comparison-stat-label">Participacao</div>
|
|
10179
|
-
<div class="myio-device-comparison-tooltip__comparison-stat-value highlight">${formatPercentage(
|
|
10199
|
+
<div class="myio-device-comparison-tooltip__comparison-stat-value highlight">${formatPercentage(
|
|
10200
|
+
widgetScope.devicePercentage
|
|
10201
|
+
)}</div>
|
|
10180
10202
|
</div>
|
|
10181
10203
|
</div>
|
|
10182
10204
|
</div>
|
|
@@ -10184,7 +10206,7 @@ function generateBodyHTML(data) {
|
|
|
10184
10206
|
<!-- Section: Grand Total Comparison -->
|
|
10185
10207
|
<div class="myio-device-comparison-tooltip__section-title">
|
|
10186
10208
|
<span class="myio-device-comparison-tooltip__section-icon">\u{1F310}</span>
|
|
10187
|
-
|
|
10209
|
+
Compara\xE7\xE3o Total
|
|
10188
10210
|
</div>
|
|
10189
10211
|
<div class="myio-device-comparison-tooltip__comparison">
|
|
10190
10212
|
<div class="myio-device-comparison-tooltip__comparison-header">
|
|
@@ -10196,21 +10218,30 @@ function generateBodyHTML(data) {
|
|
|
10196
10218
|
</div>
|
|
10197
10219
|
<div class="myio-device-comparison-tooltip__progress-container">
|
|
10198
10220
|
<div class="myio-device-comparison-tooltip__progress-bar">
|
|
10199
|
-
<div class="myio-device-comparison-tooltip__progress-fill total" style="width: ${Math.min(
|
|
10221
|
+
<div class="myio-device-comparison-tooltip__progress-fill total" style="width: ${Math.min(
|
|
10222
|
+
grandTotal.devicePercentage,
|
|
10223
|
+
100
|
|
10224
|
+
)}%"></div>
|
|
10200
10225
|
</div>
|
|
10201
10226
|
</div>
|
|
10202
10227
|
<div class="myio-device-comparison-tooltip__comparison-stats">
|
|
10203
10228
|
<div class="myio-device-comparison-tooltip__comparison-stat">
|
|
10204
10229
|
<div class="myio-device-comparison-tooltip__comparison-stat-label">Este Device</div>
|
|
10205
|
-
<div class="myio-device-comparison-tooltip__comparison-stat-value">${formatConsumption(
|
|
10230
|
+
<div class="myio-device-comparison-tooltip__comparison-stat-value">${formatConsumption(
|
|
10231
|
+
device.consumption
|
|
10232
|
+
)}</div>
|
|
10206
10233
|
</div>
|
|
10207
10234
|
<div class="myio-device-comparison-tooltip__comparison-stat">
|
|
10208
10235
|
<div class="myio-device-comparison-tooltip__comparison-stat-label">Total Geral</div>
|
|
10209
|
-
<div class="myio-device-comparison-tooltip__comparison-stat-value">${formatConsumption(
|
|
10236
|
+
<div class="myio-device-comparison-tooltip__comparison-stat-value">${formatConsumption(
|
|
10237
|
+
grandTotal.totalConsumption
|
|
10238
|
+
)}</div>
|
|
10210
10239
|
</div>
|
|
10211
10240
|
<div class="myio-device-comparison-tooltip__comparison-stat">
|
|
10212
10241
|
<div class="myio-device-comparison-tooltip__comparison-stat-label">Participacao</div>
|
|
10213
|
-
<div class="myio-device-comparison-tooltip__comparison-stat-value highlight">${formatPercentage(
|
|
10242
|
+
<div class="myio-device-comparison-tooltip__comparison-stat-value highlight">${formatPercentage(
|
|
10243
|
+
grandTotal.devicePercentage
|
|
10244
|
+
)}</div>
|
|
10214
10245
|
</div>
|
|
10215
10246
|
</div>
|
|
10216
10247
|
</div>
|
|
@@ -34064,8 +34095,11 @@ var EnergySummaryTooltip = {
|
|
|
34064
34095
|
/**
|
|
34065
34096
|
* Build summary data from TELEMETRY_INFO STATE
|
|
34066
34097
|
* This is called by the widget controller to get data for the tooltip
|
|
34098
|
+
*
|
|
34099
|
+
* RFC-0105 Enhancement: Now fetches device lists from MyIOOrchestratorData
|
|
34100
|
+
* to populate device lists for status popup display
|
|
34067
34101
|
*/
|
|
34068
|
-
buildSummaryFromState(state5, receivedData) {
|
|
34102
|
+
buildSummaryFromState(state5, receivedData, domain = "energy") {
|
|
34069
34103
|
const summary = {
|
|
34070
34104
|
totalDevices: 0,
|
|
34071
34105
|
totalConsumption: 0,
|
|
@@ -34077,7 +34111,14 @@ var EnergySummaryTooltip = {
|
|
|
34077
34111
|
failure: 0,
|
|
34078
34112
|
standby: 0,
|
|
34079
34113
|
offline: 0,
|
|
34080
|
-
noConsumption: 0
|
|
34114
|
+
noConsumption: 0,
|
|
34115
|
+
// Device lists - populated from orchestrator data
|
|
34116
|
+
normalDevices: [],
|
|
34117
|
+
alertDevices: [],
|
|
34118
|
+
failureDevices: [],
|
|
34119
|
+
standbyDevices: [],
|
|
34120
|
+
offlineDevices: [],
|
|
34121
|
+
noConsumptionDevices: []
|
|
34081
34122
|
},
|
|
34082
34123
|
lastUpdated: (/* @__PURE__ */ new Date()).toISOString()
|
|
34083
34124
|
};
|
|
@@ -34194,38 +34235,106 @@ var EnergySummaryTooltip = {
|
|
|
34194
34235
|
summary.byCategory = [entrada, lojas, areaComum];
|
|
34195
34236
|
summary.totalDevices = entrada.deviceCount + lojas.deviceCount + areaComumDeviceCount;
|
|
34196
34237
|
summary.totalConsumption = state5.grandTotal || entrada.consumption;
|
|
34197
|
-
const
|
|
34198
|
-
|
|
34199
|
-
|
|
34200
|
-
summary.byStatus = {
|
|
34201
|
-
normal: statusData.normal || 0,
|
|
34202
|
-
alert: statusData.alert || 0,
|
|
34203
|
-
failure: statusData.failure || 0,
|
|
34204
|
-
standby: statusData.standby || 0,
|
|
34205
|
-
offline: statusData.offline || 0,
|
|
34206
|
-
noConsumption: statusData.noConsumption || statusData.zeroConsumption || 0
|
|
34207
|
-
};
|
|
34238
|
+
const statusAggregation = this._aggregateDeviceStatusFromOrchestrator(domain);
|
|
34239
|
+
if (statusAggregation.hasData) {
|
|
34240
|
+
summary.byStatus = statusAggregation.byStatus;
|
|
34208
34241
|
} else {
|
|
34209
|
-
|
|
34210
|
-
|
|
34211
|
-
|
|
34212
|
-
|
|
34213
|
-
|
|
34214
|
-
|
|
34215
|
-
|
|
34216
|
-
|
|
34217
|
-
|
|
34218
|
-
|
|
34219
|
-
|
|
34220
|
-
|
|
34221
|
-
|
|
34222
|
-
|
|
34223
|
-
|
|
34224
|
-
|
|
34225
|
-
|
|
34226
|
-
|
|
34242
|
+
const totalDevices = summary.totalDevices;
|
|
34243
|
+
const statusData = receivedData?.statusCounts || receivedData?.deviceStatus || null;
|
|
34244
|
+
if (statusData && typeof statusData === "object") {
|
|
34245
|
+
summary.byStatus = {
|
|
34246
|
+
normal: statusData.normal || 0,
|
|
34247
|
+
alert: statusData.alert || 0,
|
|
34248
|
+
failure: statusData.failure || 0,
|
|
34249
|
+
standby: statusData.standby || 0,
|
|
34250
|
+
offline: statusData.offline || 0,
|
|
34251
|
+
noConsumption: statusData.noConsumption || statusData.zeroConsumption || 0
|
|
34252
|
+
};
|
|
34253
|
+
} else {
|
|
34254
|
+
summary.byStatus = {
|
|
34255
|
+
normal: Math.floor(totalDevices * 0.75),
|
|
34256
|
+
alert: Math.floor(totalDevices * 0.06),
|
|
34257
|
+
failure: Math.floor(totalDevices * 0.02),
|
|
34258
|
+
standby: Math.floor(totalDevices * 0.02),
|
|
34259
|
+
offline: Math.floor(totalDevices * 0.03),
|
|
34260
|
+
noConsumption: Math.floor(totalDevices * 0.12)
|
|
34261
|
+
};
|
|
34262
|
+
const statusSum = Object.values(summary.byStatus).reduce((a, b) => {
|
|
34263
|
+
return typeof b === "number" ? a + b : a;
|
|
34264
|
+
}, 0);
|
|
34265
|
+
if (statusSum !== totalDevices && totalDevices > 0) {
|
|
34266
|
+
summary.byStatus.normal += totalDevices - statusSum;
|
|
34267
|
+
}
|
|
34268
|
+
}
|
|
34227
34269
|
}
|
|
34228
34270
|
return summary;
|
|
34271
|
+
},
|
|
34272
|
+
/**
|
|
34273
|
+
* RFC-0105: Aggregate device status from MyIOOrchestratorData
|
|
34274
|
+
* Iterates through all orchestrator items and groups devices by status
|
|
34275
|
+
* Returns both counts and device lists
|
|
34276
|
+
*/
|
|
34277
|
+
_aggregateDeviceStatusFromOrchestrator(domain = "energy") {
|
|
34278
|
+
const result = {
|
|
34279
|
+
normal: 0,
|
|
34280
|
+
alert: 0,
|
|
34281
|
+
failure: 0,
|
|
34282
|
+
standby: 0,
|
|
34283
|
+
offline: 0,
|
|
34284
|
+
noConsumption: 0,
|
|
34285
|
+
normalDevices: [],
|
|
34286
|
+
alertDevices: [],
|
|
34287
|
+
failureDevices: [],
|
|
34288
|
+
standbyDevices: [],
|
|
34289
|
+
offlineDevices: [],
|
|
34290
|
+
noConsumptionDevices: []
|
|
34291
|
+
};
|
|
34292
|
+
const win = typeof window !== "undefined" ? window : null;
|
|
34293
|
+
if (!win) return { hasData: false, byStatus: result };
|
|
34294
|
+
const orchestratorData = win.MyIOOrchestratorData || win.parent?.MyIOOrchestratorData;
|
|
34295
|
+
if (!orchestratorData || !orchestratorData[domain]) {
|
|
34296
|
+
return { hasData: false, byStatus: result };
|
|
34297
|
+
}
|
|
34298
|
+
const domainData = orchestratorData[domain];
|
|
34299
|
+
const items = domainData.items || [];
|
|
34300
|
+
if (!items || items.length === 0) {
|
|
34301
|
+
return { hasData: false, byStatus: result };
|
|
34302
|
+
}
|
|
34303
|
+
const NO_CONSUMPTION_THRESHOLD = 0.01;
|
|
34304
|
+
const statusMapping = {
|
|
34305
|
+
"power_on": "normal",
|
|
34306
|
+
"warning": "alert",
|
|
34307
|
+
"failure": "failure",
|
|
34308
|
+
"standby": "standby",
|
|
34309
|
+
"power_off": "offline",
|
|
34310
|
+
"maintenance": "offline",
|
|
34311
|
+
"no_info": "offline",
|
|
34312
|
+
"not_installed": "offline",
|
|
34313
|
+
"offline": "offline"
|
|
34314
|
+
};
|
|
34315
|
+
items.forEach((item) => {
|
|
34316
|
+
const deviceInfo = {
|
|
34317
|
+
id: item.id || item.deviceId || "",
|
|
34318
|
+
label: item.label || item.entityLabel || item.name || item.deviceIdentifier || "",
|
|
34319
|
+
name: item.name || item.entityLabel || ""
|
|
34320
|
+
};
|
|
34321
|
+
const deviceStatus = item.deviceStatus || "no_info";
|
|
34322
|
+
const value = Number(item.value || item.val || 0);
|
|
34323
|
+
const isOnline = !["no_info", "offline", "not_installed", "maintenance", "power_off"].includes(deviceStatus);
|
|
34324
|
+
if (isOnline && Math.abs(value) < NO_CONSUMPTION_THRESHOLD) {
|
|
34325
|
+
result.noConsumption++;
|
|
34326
|
+
result.noConsumptionDevices?.push(deviceInfo);
|
|
34327
|
+
return;
|
|
34328
|
+
}
|
|
34329
|
+
const mappedStatus = statusMapping[deviceStatus] || "offline";
|
|
34330
|
+
result[mappedStatus]++;
|
|
34331
|
+
const deviceListKey = `${mappedStatus}Devices`;
|
|
34332
|
+
const deviceList = result[deviceListKey];
|
|
34333
|
+
if (deviceList) {
|
|
34334
|
+
deviceList.push(deviceInfo);
|
|
34335
|
+
}
|
|
34336
|
+
});
|
|
34337
|
+
return { hasData: true, byStatus: result };
|
|
34229
34338
|
}
|
|
34230
34339
|
};
|
|
34231
34340
|
|
|
@@ -35383,8 +35492,11 @@ var WaterSummaryTooltip = {
|
|
|
35383
35492
|
/**
|
|
35384
35493
|
* Build summary data from TELEMETRY_INFO STATE_WATER
|
|
35385
35494
|
* This is called by the widget controller to get data for the tooltip
|
|
35495
|
+
*
|
|
35496
|
+
* RFC-0105 Enhancement: Now fetches device lists from MyIOOrchestratorData
|
|
35497
|
+
* to populate device lists for status popup display
|
|
35386
35498
|
*/
|
|
35387
|
-
buildSummaryFromState(state5, receivedData, includeBathrooms = false) {
|
|
35499
|
+
buildSummaryFromState(state5, receivedData, includeBathrooms = false, domain = "water") {
|
|
35388
35500
|
const summary = {
|
|
35389
35501
|
totalDevices: 0,
|
|
35390
35502
|
totalConsumption: 0,
|
|
@@ -35396,7 +35508,14 @@ var WaterSummaryTooltip = {
|
|
|
35396
35508
|
failure: 0,
|
|
35397
35509
|
standby: 0,
|
|
35398
35510
|
offline: 0,
|
|
35399
|
-
noConsumption: 0
|
|
35511
|
+
noConsumption: 0,
|
|
35512
|
+
// Device lists - populated from orchestrator data
|
|
35513
|
+
normalDevices: [],
|
|
35514
|
+
alertDevices: [],
|
|
35515
|
+
failureDevices: [],
|
|
35516
|
+
standbyDevices: [],
|
|
35517
|
+
offlineDevices: [],
|
|
35518
|
+
noConsumptionDevices: []
|
|
35400
35519
|
},
|
|
35401
35520
|
lastUpdated: (/* @__PURE__ */ new Date()).toISOString(),
|
|
35402
35521
|
includeBathrooms
|
|
@@ -35452,32 +35571,106 @@ var WaterSummaryTooltip = {
|
|
|
35452
35571
|
}
|
|
35453
35572
|
summary.totalDevices = summary.byCategory.reduce((sum, cat) => sum + cat.deviceCount, 0);
|
|
35454
35573
|
summary.totalConsumption = state5.entrada?.total || 0;
|
|
35455
|
-
const
|
|
35456
|
-
|
|
35457
|
-
|
|
35458
|
-
summary.byStatus = {
|
|
35459
|
-
normal: statusData.normal || 0,
|
|
35460
|
-
alert: statusData.alert || 0,
|
|
35461
|
-
failure: statusData.failure || 0,
|
|
35462
|
-
standby: statusData.standby || 0,
|
|
35463
|
-
offline: statusData.offline || 0,
|
|
35464
|
-
noConsumption: statusData.noConsumption || statusData.zeroConsumption || 0
|
|
35465
|
-
};
|
|
35574
|
+
const statusAggregation = this._aggregateDeviceStatusFromOrchestrator(domain);
|
|
35575
|
+
if (statusAggregation.hasData) {
|
|
35576
|
+
summary.byStatus = statusAggregation.byStatus;
|
|
35466
35577
|
} else {
|
|
35467
|
-
|
|
35468
|
-
|
|
35469
|
-
|
|
35470
|
-
|
|
35471
|
-
|
|
35472
|
-
|
|
35473
|
-
|
|
35474
|
-
|
|
35475
|
-
|
|
35476
|
-
|
|
35477
|
-
|
|
35478
|
-
|
|
35578
|
+
const totalDevices = summary.totalDevices;
|
|
35579
|
+
const statusData = receivedData?.statusCounts || receivedData?.deviceStatus || null;
|
|
35580
|
+
if (statusData && typeof statusData === "object") {
|
|
35581
|
+
summary.byStatus = {
|
|
35582
|
+
normal: statusData.normal || 0,
|
|
35583
|
+
alert: statusData.alert || 0,
|
|
35584
|
+
failure: statusData.failure || 0,
|
|
35585
|
+
standby: statusData.standby || 0,
|
|
35586
|
+
offline: statusData.offline || 0,
|
|
35587
|
+
noConsumption: statusData.noConsumption || statusData.zeroConsumption || 0
|
|
35588
|
+
};
|
|
35589
|
+
} else {
|
|
35590
|
+
summary.byStatus = {
|
|
35591
|
+
normal: Math.floor(totalDevices * 0.8),
|
|
35592
|
+
alert: Math.floor(totalDevices * 0.05),
|
|
35593
|
+
failure: Math.floor(totalDevices * 0.02),
|
|
35594
|
+
standby: Math.floor(totalDevices * 0.02),
|
|
35595
|
+
offline: Math.floor(totalDevices * 0.03),
|
|
35596
|
+
noConsumption: Math.floor(totalDevices * 0.08)
|
|
35597
|
+
};
|
|
35598
|
+
const statusSum = Object.values(summary.byStatus).reduce((a, b) => {
|
|
35599
|
+
return typeof b === "number" ? a + b : a;
|
|
35600
|
+
}, 0);
|
|
35601
|
+
if (statusSum !== totalDevices && totalDevices > 0) {
|
|
35602
|
+
summary.byStatus.normal += totalDevices - statusSum;
|
|
35603
|
+
}
|
|
35604
|
+
}
|
|
35479
35605
|
}
|
|
35480
35606
|
return summary;
|
|
35607
|
+
},
|
|
35608
|
+
/**
|
|
35609
|
+
* RFC-0105: Aggregate device status from MyIOOrchestratorData
|
|
35610
|
+
* Iterates through all orchestrator items and groups devices by status
|
|
35611
|
+
* Returns both counts and device lists
|
|
35612
|
+
*/
|
|
35613
|
+
_aggregateDeviceStatusFromOrchestrator(domain = "water") {
|
|
35614
|
+
const result = {
|
|
35615
|
+
normal: 0,
|
|
35616
|
+
alert: 0,
|
|
35617
|
+
failure: 0,
|
|
35618
|
+
standby: 0,
|
|
35619
|
+
offline: 0,
|
|
35620
|
+
noConsumption: 0,
|
|
35621
|
+
normalDevices: [],
|
|
35622
|
+
alertDevices: [],
|
|
35623
|
+
failureDevices: [],
|
|
35624
|
+
standbyDevices: [],
|
|
35625
|
+
offlineDevices: [],
|
|
35626
|
+
noConsumptionDevices: []
|
|
35627
|
+
};
|
|
35628
|
+
const win = typeof window !== "undefined" ? window : null;
|
|
35629
|
+
if (!win) return { hasData: false, byStatus: result };
|
|
35630
|
+
const orchestratorData = win.MyIOOrchestratorData || win.parent?.MyIOOrchestratorData;
|
|
35631
|
+
if (!orchestratorData || !orchestratorData[domain]) {
|
|
35632
|
+
return { hasData: false, byStatus: result };
|
|
35633
|
+
}
|
|
35634
|
+
const domainData = orchestratorData[domain];
|
|
35635
|
+
const items = domainData.items || [];
|
|
35636
|
+
if (!items || items.length === 0) {
|
|
35637
|
+
return { hasData: false, byStatus: result };
|
|
35638
|
+
}
|
|
35639
|
+
const NO_CONSUMPTION_THRESHOLD = 1e-3;
|
|
35640
|
+
const statusMapping = {
|
|
35641
|
+
"power_on": "normal",
|
|
35642
|
+
"warning": "alert",
|
|
35643
|
+
"failure": "failure",
|
|
35644
|
+
"standby": "standby",
|
|
35645
|
+
"power_off": "offline",
|
|
35646
|
+
"maintenance": "offline",
|
|
35647
|
+
"no_info": "offline",
|
|
35648
|
+
"not_installed": "offline",
|
|
35649
|
+
"offline": "offline"
|
|
35650
|
+
};
|
|
35651
|
+
items.forEach((item) => {
|
|
35652
|
+
const deviceInfo = {
|
|
35653
|
+
id: item.id || item.deviceId || "",
|
|
35654
|
+
label: item.label || item.entityLabel || item.name || item.deviceIdentifier || "",
|
|
35655
|
+
name: item.name || item.entityLabel || ""
|
|
35656
|
+
};
|
|
35657
|
+
const deviceStatus = item.deviceStatus || "no_info";
|
|
35658
|
+
const value = Number(item.value || item.val || 0);
|
|
35659
|
+
const isOnline = !["no_info", "offline", "not_installed", "maintenance", "power_off"].includes(deviceStatus);
|
|
35660
|
+
if (isOnline && Math.abs(value) < NO_CONSUMPTION_THRESHOLD) {
|
|
35661
|
+
result.noConsumption++;
|
|
35662
|
+
result.noConsumptionDevices?.push(deviceInfo);
|
|
35663
|
+
return;
|
|
35664
|
+
}
|
|
35665
|
+
const mappedStatus = statusMapping[deviceStatus] || "offline";
|
|
35666
|
+
result[mappedStatus]++;
|
|
35667
|
+
const deviceListKey = `${mappedStatus}Devices`;
|
|
35668
|
+
const deviceList = result[deviceListKey];
|
|
35669
|
+
if (deviceList) {
|
|
35670
|
+
deviceList.push(deviceInfo);
|
|
35671
|
+
}
|
|
35672
|
+
});
|
|
35673
|
+
return { hasData: true, byStatus: result };
|
|
35481
35674
|
}
|
|
35482
35675
|
};
|
|
35483
35676
|
|