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.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,124 @@ 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
|
-
if (statusData && typeof statusData === "object") {
|
|
34238
|
+
const widgetAggregation = receivedData?.deviceStatusAggregation;
|
|
34239
|
+
if (widgetAggregation && widgetAggregation.hasData) {
|
|
34200
34240
|
summary.byStatus = {
|
|
34201
|
-
normal:
|
|
34202
|
-
alert:
|
|
34203
|
-
failure:
|
|
34204
|
-
standby:
|
|
34205
|
-
offline:
|
|
34206
|
-
noConsumption:
|
|
34241
|
+
normal: widgetAggregation.normal || 0,
|
|
34242
|
+
alert: widgetAggregation.alert || 0,
|
|
34243
|
+
failure: widgetAggregation.failure || 0,
|
|
34244
|
+
standby: widgetAggregation.standby || 0,
|
|
34245
|
+
offline: widgetAggregation.offline || 0,
|
|
34246
|
+
noConsumption: widgetAggregation.noConsumption || 0,
|
|
34247
|
+
normalDevices: widgetAggregation.normalDevices || [],
|
|
34248
|
+
alertDevices: widgetAggregation.alertDevices || [],
|
|
34249
|
+
failureDevices: widgetAggregation.failureDevices || [],
|
|
34250
|
+
standbyDevices: widgetAggregation.standbyDevices || [],
|
|
34251
|
+
offlineDevices: widgetAggregation.offlineDevices || [],
|
|
34252
|
+
noConsumptionDevices: widgetAggregation.noConsumptionDevices || []
|
|
34207
34253
|
};
|
|
34208
34254
|
} else {
|
|
34209
|
-
|
|
34210
|
-
|
|
34211
|
-
|
|
34212
|
-
|
|
34213
|
-
|
|
34214
|
-
|
|
34215
|
-
|
|
34216
|
-
|
|
34217
|
-
|
|
34218
|
-
|
|
34219
|
-
|
|
34220
|
-
|
|
34221
|
-
|
|
34222
|
-
|
|
34223
|
-
|
|
34224
|
-
|
|
34225
|
-
|
|
34226
|
-
|
|
34255
|
+
const statusAggregation = this._aggregateDeviceStatusFromOrchestrator(domain);
|
|
34256
|
+
if (statusAggregation.hasData) {
|
|
34257
|
+
summary.byStatus = statusAggregation.byStatus;
|
|
34258
|
+
} else {
|
|
34259
|
+
const totalDevices = summary.totalDevices;
|
|
34260
|
+
const statusData = receivedData?.statusCounts || receivedData?.deviceStatus || null;
|
|
34261
|
+
if (statusData && typeof statusData === "object") {
|
|
34262
|
+
summary.byStatus = {
|
|
34263
|
+
normal: statusData.normal || 0,
|
|
34264
|
+
alert: statusData.alert || 0,
|
|
34265
|
+
failure: statusData.failure || 0,
|
|
34266
|
+
standby: statusData.standby || 0,
|
|
34267
|
+
offline: statusData.offline || 0,
|
|
34268
|
+
noConsumption: statusData.noConsumption || statusData.zeroConsumption || 0
|
|
34269
|
+
};
|
|
34270
|
+
} else {
|
|
34271
|
+
summary.byStatus = {
|
|
34272
|
+
normal: Math.floor(totalDevices * 0.75),
|
|
34273
|
+
alert: Math.floor(totalDevices * 0.06),
|
|
34274
|
+
failure: Math.floor(totalDevices * 0.02),
|
|
34275
|
+
standby: Math.floor(totalDevices * 0.02),
|
|
34276
|
+
offline: Math.floor(totalDevices * 0.03),
|
|
34277
|
+
noConsumption: Math.floor(totalDevices * 0.12)
|
|
34278
|
+
};
|
|
34279
|
+
const statusSum = Object.values(summary.byStatus).reduce((a, b) => {
|
|
34280
|
+
return typeof b === "number" ? a + b : a;
|
|
34281
|
+
}, 0);
|
|
34282
|
+
if (statusSum !== totalDevices && totalDevices > 0) {
|
|
34283
|
+
summary.byStatus.normal += totalDevices - statusSum;
|
|
34284
|
+
}
|
|
34285
|
+
}
|
|
34286
|
+
}
|
|
34227
34287
|
}
|
|
34228
34288
|
return summary;
|
|
34289
|
+
},
|
|
34290
|
+
/**
|
|
34291
|
+
* RFC-0105: Aggregate device status from MyIOOrchestratorData
|
|
34292
|
+
* Iterates through all orchestrator items and groups devices by status
|
|
34293
|
+
* Returns both counts and device lists
|
|
34294
|
+
*/
|
|
34295
|
+
_aggregateDeviceStatusFromOrchestrator(domain = "energy") {
|
|
34296
|
+
const result = {
|
|
34297
|
+
normal: 0,
|
|
34298
|
+
alert: 0,
|
|
34299
|
+
failure: 0,
|
|
34300
|
+
standby: 0,
|
|
34301
|
+
offline: 0,
|
|
34302
|
+
noConsumption: 0,
|
|
34303
|
+
normalDevices: [],
|
|
34304
|
+
alertDevices: [],
|
|
34305
|
+
failureDevices: [],
|
|
34306
|
+
standbyDevices: [],
|
|
34307
|
+
offlineDevices: [],
|
|
34308
|
+
noConsumptionDevices: []
|
|
34309
|
+
};
|
|
34310
|
+
const win = typeof window !== "undefined" ? window : null;
|
|
34311
|
+
if (!win) return { hasData: false, byStatus: result };
|
|
34312
|
+
const orchestratorData = win.MyIOOrchestratorData || win.parent?.MyIOOrchestratorData;
|
|
34313
|
+
if (!orchestratorData || !orchestratorData[domain]) {
|
|
34314
|
+
return { hasData: false, byStatus: result };
|
|
34315
|
+
}
|
|
34316
|
+
const domainData = orchestratorData[domain];
|
|
34317
|
+
const items = domainData.items || [];
|
|
34318
|
+
if (!items || items.length === 0) {
|
|
34319
|
+
return { hasData: false, byStatus: result };
|
|
34320
|
+
}
|
|
34321
|
+
const NO_CONSUMPTION_THRESHOLD = 0.01;
|
|
34322
|
+
const statusMapping = {
|
|
34323
|
+
"power_on": "normal",
|
|
34324
|
+
"warning": "alert",
|
|
34325
|
+
"failure": "failure",
|
|
34326
|
+
"standby": "standby",
|
|
34327
|
+
"power_off": "offline",
|
|
34328
|
+
"maintenance": "offline",
|
|
34329
|
+
"no_info": "offline",
|
|
34330
|
+
"not_installed": "offline",
|
|
34331
|
+
"offline": "offline"
|
|
34332
|
+
};
|
|
34333
|
+
items.forEach((item) => {
|
|
34334
|
+
const deviceInfo = {
|
|
34335
|
+
id: item.id || item.deviceId || "",
|
|
34336
|
+
label: item.label || item.entityLabel || item.name || item.deviceIdentifier || "",
|
|
34337
|
+
name: item.name || item.entityLabel || ""
|
|
34338
|
+
};
|
|
34339
|
+
const deviceStatus = item.deviceStatus || "no_info";
|
|
34340
|
+
const value = Number(item.value || item.val || 0);
|
|
34341
|
+
const isOnline = !["no_info", "offline", "not_installed", "maintenance", "power_off"].includes(deviceStatus);
|
|
34342
|
+
if (isOnline && Math.abs(value) < NO_CONSUMPTION_THRESHOLD) {
|
|
34343
|
+
result.noConsumption++;
|
|
34344
|
+
result.noConsumptionDevices?.push(deviceInfo);
|
|
34345
|
+
return;
|
|
34346
|
+
}
|
|
34347
|
+
const mappedStatus = statusMapping[deviceStatus] || "offline";
|
|
34348
|
+
result[mappedStatus]++;
|
|
34349
|
+
const deviceListKey = `${mappedStatus}Devices`;
|
|
34350
|
+
const deviceList = result[deviceListKey];
|
|
34351
|
+
if (deviceList) {
|
|
34352
|
+
deviceList.push(deviceInfo);
|
|
34353
|
+
}
|
|
34354
|
+
});
|
|
34355
|
+
return { hasData: true, byStatus: result };
|
|
34229
34356
|
}
|
|
34230
34357
|
};
|
|
34231
34358
|
|
|
@@ -35383,8 +35510,11 @@ var WaterSummaryTooltip = {
|
|
|
35383
35510
|
/**
|
|
35384
35511
|
* Build summary data from TELEMETRY_INFO STATE_WATER
|
|
35385
35512
|
* This is called by the widget controller to get data for the tooltip
|
|
35513
|
+
*
|
|
35514
|
+
* RFC-0105 Enhancement: Now fetches device lists from MyIOOrchestratorData
|
|
35515
|
+
* to populate device lists for status popup display
|
|
35386
35516
|
*/
|
|
35387
|
-
buildSummaryFromState(state5, receivedData, includeBathrooms = false) {
|
|
35517
|
+
buildSummaryFromState(state5, receivedData, includeBathrooms = false, domain = "water") {
|
|
35388
35518
|
const summary = {
|
|
35389
35519
|
totalDevices: 0,
|
|
35390
35520
|
totalConsumption: 0,
|
|
@@ -35396,7 +35526,14 @@ var WaterSummaryTooltip = {
|
|
|
35396
35526
|
failure: 0,
|
|
35397
35527
|
standby: 0,
|
|
35398
35528
|
offline: 0,
|
|
35399
|
-
noConsumption: 0
|
|
35529
|
+
noConsumption: 0,
|
|
35530
|
+
// Device lists - populated from orchestrator data
|
|
35531
|
+
normalDevices: [],
|
|
35532
|
+
alertDevices: [],
|
|
35533
|
+
failureDevices: [],
|
|
35534
|
+
standbyDevices: [],
|
|
35535
|
+
offlineDevices: [],
|
|
35536
|
+
noConsumptionDevices: []
|
|
35400
35537
|
},
|
|
35401
35538
|
lastUpdated: (/* @__PURE__ */ new Date()).toISOString(),
|
|
35402
35539
|
includeBathrooms
|
|
@@ -35452,32 +35589,124 @@ var WaterSummaryTooltip = {
|
|
|
35452
35589
|
}
|
|
35453
35590
|
summary.totalDevices = summary.byCategory.reduce((sum, cat) => sum + cat.deviceCount, 0);
|
|
35454
35591
|
summary.totalConsumption = state5.entrada?.total || 0;
|
|
35455
|
-
const
|
|
35456
|
-
|
|
35457
|
-
if (statusData && typeof statusData === "object") {
|
|
35592
|
+
const widgetAggregation = receivedData?.deviceStatusAggregation;
|
|
35593
|
+
if (widgetAggregation && widgetAggregation.hasData) {
|
|
35458
35594
|
summary.byStatus = {
|
|
35459
|
-
normal:
|
|
35460
|
-
alert:
|
|
35461
|
-
failure:
|
|
35462
|
-
standby:
|
|
35463
|
-
offline:
|
|
35464
|
-
noConsumption:
|
|
35595
|
+
normal: widgetAggregation.normal || 0,
|
|
35596
|
+
alert: widgetAggregation.alert || 0,
|
|
35597
|
+
failure: widgetAggregation.failure || 0,
|
|
35598
|
+
standby: widgetAggregation.standby || 0,
|
|
35599
|
+
offline: widgetAggregation.offline || 0,
|
|
35600
|
+
noConsumption: widgetAggregation.noConsumption || 0,
|
|
35601
|
+
normalDevices: widgetAggregation.normalDevices || [],
|
|
35602
|
+
alertDevices: widgetAggregation.alertDevices || [],
|
|
35603
|
+
failureDevices: widgetAggregation.failureDevices || [],
|
|
35604
|
+
standbyDevices: widgetAggregation.standbyDevices || [],
|
|
35605
|
+
offlineDevices: widgetAggregation.offlineDevices || [],
|
|
35606
|
+
noConsumptionDevices: widgetAggregation.noConsumptionDevices || []
|
|
35465
35607
|
};
|
|
35466
35608
|
} else {
|
|
35467
|
-
|
|
35468
|
-
|
|
35469
|
-
|
|
35470
|
-
|
|
35471
|
-
|
|
35472
|
-
|
|
35473
|
-
|
|
35474
|
-
|
|
35475
|
-
|
|
35476
|
-
|
|
35477
|
-
|
|
35478
|
-
|
|
35609
|
+
const statusAggregation = this._aggregateDeviceStatusFromOrchestrator(domain);
|
|
35610
|
+
if (statusAggregation.hasData) {
|
|
35611
|
+
summary.byStatus = statusAggregation.byStatus;
|
|
35612
|
+
} else {
|
|
35613
|
+
const totalDevices = summary.totalDevices;
|
|
35614
|
+
const statusData = receivedData?.statusCounts || receivedData?.deviceStatus || null;
|
|
35615
|
+
if (statusData && typeof statusData === "object") {
|
|
35616
|
+
summary.byStatus = {
|
|
35617
|
+
normal: statusData.normal || 0,
|
|
35618
|
+
alert: statusData.alert || 0,
|
|
35619
|
+
failure: statusData.failure || 0,
|
|
35620
|
+
standby: statusData.standby || 0,
|
|
35621
|
+
offline: statusData.offline || 0,
|
|
35622
|
+
noConsumption: statusData.noConsumption || statusData.zeroConsumption || 0
|
|
35623
|
+
};
|
|
35624
|
+
} else {
|
|
35625
|
+
summary.byStatus = {
|
|
35626
|
+
normal: Math.floor(totalDevices * 0.8),
|
|
35627
|
+
alert: Math.floor(totalDevices * 0.05),
|
|
35628
|
+
failure: Math.floor(totalDevices * 0.02),
|
|
35629
|
+
standby: Math.floor(totalDevices * 0.02),
|
|
35630
|
+
offline: Math.floor(totalDevices * 0.03),
|
|
35631
|
+
noConsumption: Math.floor(totalDevices * 0.08)
|
|
35632
|
+
};
|
|
35633
|
+
const statusSum = Object.values(summary.byStatus).reduce((a, b) => {
|
|
35634
|
+
return typeof b === "number" ? a + b : a;
|
|
35635
|
+
}, 0);
|
|
35636
|
+
if (statusSum !== totalDevices && totalDevices > 0) {
|
|
35637
|
+
summary.byStatus.normal += totalDevices - statusSum;
|
|
35638
|
+
}
|
|
35639
|
+
}
|
|
35640
|
+
}
|
|
35479
35641
|
}
|
|
35480
35642
|
return summary;
|
|
35643
|
+
},
|
|
35644
|
+
/**
|
|
35645
|
+
* RFC-0105: Aggregate device status from MyIOOrchestratorData
|
|
35646
|
+
* Iterates through all orchestrator items and groups devices by status
|
|
35647
|
+
* Returns both counts and device lists
|
|
35648
|
+
*/
|
|
35649
|
+
_aggregateDeviceStatusFromOrchestrator(domain = "water") {
|
|
35650
|
+
const result = {
|
|
35651
|
+
normal: 0,
|
|
35652
|
+
alert: 0,
|
|
35653
|
+
failure: 0,
|
|
35654
|
+
standby: 0,
|
|
35655
|
+
offline: 0,
|
|
35656
|
+
noConsumption: 0,
|
|
35657
|
+
normalDevices: [],
|
|
35658
|
+
alertDevices: [],
|
|
35659
|
+
failureDevices: [],
|
|
35660
|
+
standbyDevices: [],
|
|
35661
|
+
offlineDevices: [],
|
|
35662
|
+
noConsumptionDevices: []
|
|
35663
|
+
};
|
|
35664
|
+
const win = typeof window !== "undefined" ? window : null;
|
|
35665
|
+
if (!win) return { hasData: false, byStatus: result };
|
|
35666
|
+
const orchestratorData = win.MyIOOrchestratorData || win.parent?.MyIOOrchestratorData;
|
|
35667
|
+
if (!orchestratorData || !orchestratorData[domain]) {
|
|
35668
|
+
return { hasData: false, byStatus: result };
|
|
35669
|
+
}
|
|
35670
|
+
const domainData = orchestratorData[domain];
|
|
35671
|
+
const items = domainData.items || [];
|
|
35672
|
+
if (!items || items.length === 0) {
|
|
35673
|
+
return { hasData: false, byStatus: result };
|
|
35674
|
+
}
|
|
35675
|
+
const NO_CONSUMPTION_THRESHOLD = 1e-3;
|
|
35676
|
+
const statusMapping = {
|
|
35677
|
+
"power_on": "normal",
|
|
35678
|
+
"warning": "alert",
|
|
35679
|
+
"failure": "failure",
|
|
35680
|
+
"standby": "standby",
|
|
35681
|
+
"power_off": "offline",
|
|
35682
|
+
"maintenance": "offline",
|
|
35683
|
+
"no_info": "offline",
|
|
35684
|
+
"not_installed": "offline",
|
|
35685
|
+
"offline": "offline"
|
|
35686
|
+
};
|
|
35687
|
+
items.forEach((item) => {
|
|
35688
|
+
const deviceInfo = {
|
|
35689
|
+
id: item.id || item.deviceId || "",
|
|
35690
|
+
label: item.label || item.entityLabel || item.name || item.deviceIdentifier || "",
|
|
35691
|
+
name: item.name || item.entityLabel || ""
|
|
35692
|
+
};
|
|
35693
|
+
const deviceStatus = item.deviceStatus || "no_info";
|
|
35694
|
+
const value = Number(item.value || item.val || 0);
|
|
35695
|
+
const isOnline = !["no_info", "offline", "not_installed", "maintenance", "power_off"].includes(deviceStatus);
|
|
35696
|
+
if (isOnline && Math.abs(value) < NO_CONSUMPTION_THRESHOLD) {
|
|
35697
|
+
result.noConsumption++;
|
|
35698
|
+
result.noConsumptionDevices?.push(deviceInfo);
|
|
35699
|
+
return;
|
|
35700
|
+
}
|
|
35701
|
+
const mappedStatus = statusMapping[deviceStatus] || "offline";
|
|
35702
|
+
result[mappedStatus]++;
|
|
35703
|
+
const deviceListKey = `${mappedStatus}Devices`;
|
|
35704
|
+
const deviceList = result[deviceListKey];
|
|
35705
|
+
if (deviceList) {
|
|
35706
|
+
deviceList.push(deviceInfo);
|
|
35707
|
+
}
|
|
35708
|
+
});
|
|
35709
|
+
return { hasData: true, byStatus: result };
|
|
35481
35710
|
}
|
|
35482
35711
|
};
|
|
35483
35712
|
|