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
|
@@ -10093,18 +10093,22 @@
|
|
|
10093
10093
|
<div class="myio-device-comparison-tooltip__main-stats">
|
|
10094
10094
|
<div class="myio-device-comparison-tooltip__stat-card">
|
|
10095
10095
|
<div class="myio-device-comparison-tooltip__stat-label">Consumo</div>
|
|
10096
|
-
<div class="myio-device-comparison-tooltip__stat-value consumption">${formatConsumption(
|
|
10096
|
+
<div class="myio-device-comparison-tooltip__stat-value consumption">${formatConsumption(
|
|
10097
|
+
device.consumption
|
|
10098
|
+
)}</div>
|
|
10097
10099
|
</div>
|
|
10098
10100
|
<div class="myio-device-comparison-tooltip__stat-card">
|
|
10099
10101
|
<div class="myio-device-comparison-tooltip__stat-label">Participacao</div>
|
|
10100
|
-
<div class="myio-device-comparison-tooltip__stat-value percentage">${formatPercentage(
|
|
10102
|
+
<div class="myio-device-comparison-tooltip__stat-value percentage">${formatPercentage(
|
|
10103
|
+
device.percentage
|
|
10104
|
+
)}</div>
|
|
10101
10105
|
</div>
|
|
10102
10106
|
</div>
|
|
10103
10107
|
|
|
10104
10108
|
<!-- Section: Category Comparison -->
|
|
10105
10109
|
<div class="myio-device-comparison-tooltip__section-title">
|
|
10106
10110
|
<span class="myio-device-comparison-tooltip__section-icon">\u{1F4CA}</span>
|
|
10107
|
-
|
|
10111
|
+
Compara\xE7\xE3o por Tipo
|
|
10108
10112
|
</div>
|
|
10109
10113
|
<div class="myio-device-comparison-tooltip__comparison">
|
|
10110
10114
|
<div class="myio-device-comparison-tooltip__comparison-header">
|
|
@@ -10116,21 +10120,30 @@
|
|
|
10116
10120
|
</div>
|
|
10117
10121
|
<div class="myio-device-comparison-tooltip__progress-container">
|
|
10118
10122
|
<div class="myio-device-comparison-tooltip__progress-bar">
|
|
10119
|
-
<div class="myio-device-comparison-tooltip__progress-fill category" style="width: ${Math.min(
|
|
10123
|
+
<div class="myio-device-comparison-tooltip__progress-fill category" style="width: ${Math.min(
|
|
10124
|
+
categoryGroup.devicePercentage,
|
|
10125
|
+
100
|
|
10126
|
+
)}%"></div>
|
|
10120
10127
|
</div>
|
|
10121
10128
|
</div>
|
|
10122
10129
|
<div class="myio-device-comparison-tooltip__comparison-stats">
|
|
10123
10130
|
<div class="myio-device-comparison-tooltip__comparison-stat">
|
|
10124
10131
|
<div class="myio-device-comparison-tooltip__comparison-stat-label">Este Device</div>
|
|
10125
|
-
<div class="myio-device-comparison-tooltip__comparison-stat-value">${formatConsumption(
|
|
10132
|
+
<div class="myio-device-comparison-tooltip__comparison-stat-value">${formatConsumption(
|
|
10133
|
+
device.consumption
|
|
10134
|
+
)}</div>
|
|
10126
10135
|
</div>
|
|
10127
10136
|
<div class="myio-device-comparison-tooltip__comparison-stat">
|
|
10128
10137
|
<div class="myio-device-comparison-tooltip__comparison-stat-label">Total Grupo</div>
|
|
10129
|
-
<div class="myio-device-comparison-tooltip__comparison-stat-value">${formatConsumption(
|
|
10138
|
+
<div class="myio-device-comparison-tooltip__comparison-stat-value">${formatConsumption(
|
|
10139
|
+
categoryGroup.totalConsumption
|
|
10140
|
+
)}</div>
|
|
10130
10141
|
</div>
|
|
10131
10142
|
<div class="myio-device-comparison-tooltip__comparison-stat">
|
|
10132
10143
|
<div class="myio-device-comparison-tooltip__comparison-stat-label">Participacao</div>
|
|
10133
|
-
<div class="myio-device-comparison-tooltip__comparison-stat-value highlight">${formatPercentage(
|
|
10144
|
+
<div class="myio-device-comparison-tooltip__comparison-stat-value highlight">${formatPercentage(
|
|
10145
|
+
categoryGroup.devicePercentage
|
|
10146
|
+
)}</div>
|
|
10134
10147
|
</div>
|
|
10135
10148
|
</div>
|
|
10136
10149
|
</div>
|
|
@@ -10138,7 +10151,7 @@
|
|
|
10138
10151
|
<!-- Section: Widget Scope Comparison -->
|
|
10139
10152
|
<div class="myio-device-comparison-tooltip__section-title">
|
|
10140
10153
|
<span class="myio-device-comparison-tooltip__section-icon">\u{1F3E2}</span>
|
|
10141
|
-
|
|
10154
|
+
Compara\xE7\xE3o no Grupo
|
|
10142
10155
|
</div>
|
|
10143
10156
|
<div class="myio-device-comparison-tooltip__comparison">
|
|
10144
10157
|
<div class="myio-device-comparison-tooltip__comparison-header">
|
|
@@ -10150,21 +10163,30 @@
|
|
|
10150
10163
|
</div>
|
|
10151
10164
|
<div class="myio-device-comparison-tooltip__progress-container">
|
|
10152
10165
|
<div class="myio-device-comparison-tooltip__progress-bar">
|
|
10153
|
-
<div class="myio-device-comparison-tooltip__progress-fill widget" style="width: ${Math.min(
|
|
10166
|
+
<div class="myio-device-comparison-tooltip__progress-fill widget" style="width: ${Math.min(
|
|
10167
|
+
widgetScope.devicePercentage,
|
|
10168
|
+
100
|
|
10169
|
+
)}%"></div>
|
|
10154
10170
|
</div>
|
|
10155
10171
|
</div>
|
|
10156
10172
|
<div class="myio-device-comparison-tooltip__comparison-stats">
|
|
10157
10173
|
<div class="myio-device-comparison-tooltip__comparison-stat">
|
|
10158
10174
|
<div class="myio-device-comparison-tooltip__comparison-stat-label">Este Device</div>
|
|
10159
|
-
<div class="myio-device-comparison-tooltip__comparison-stat-value">${formatConsumption(
|
|
10175
|
+
<div class="myio-device-comparison-tooltip__comparison-stat-value">${formatConsumption(
|
|
10176
|
+
device.consumption
|
|
10177
|
+
)}</div>
|
|
10160
10178
|
</div>
|
|
10161
10179
|
<div class="myio-device-comparison-tooltip__comparison-stat">
|
|
10162
10180
|
<div class="myio-device-comparison-tooltip__comparison-stat-label">Total Widget</div>
|
|
10163
|
-
<div class="myio-device-comparison-tooltip__comparison-stat-value">${formatConsumption(
|
|
10181
|
+
<div class="myio-device-comparison-tooltip__comparison-stat-value">${formatConsumption(
|
|
10182
|
+
widgetScope.totalConsumption
|
|
10183
|
+
)}</div>
|
|
10164
10184
|
</div>
|
|
10165
10185
|
<div class="myio-device-comparison-tooltip__comparison-stat">
|
|
10166
10186
|
<div class="myio-device-comparison-tooltip__comparison-stat-label">Participacao</div>
|
|
10167
|
-
<div class="myio-device-comparison-tooltip__comparison-stat-value highlight">${formatPercentage(
|
|
10187
|
+
<div class="myio-device-comparison-tooltip__comparison-stat-value highlight">${formatPercentage(
|
|
10188
|
+
widgetScope.devicePercentage
|
|
10189
|
+
)}</div>
|
|
10168
10190
|
</div>
|
|
10169
10191
|
</div>
|
|
10170
10192
|
</div>
|
|
@@ -10172,7 +10194,7 @@
|
|
|
10172
10194
|
<!-- Section: Grand Total Comparison -->
|
|
10173
10195
|
<div class="myio-device-comparison-tooltip__section-title">
|
|
10174
10196
|
<span class="myio-device-comparison-tooltip__section-icon">\u{1F310}</span>
|
|
10175
|
-
|
|
10197
|
+
Compara\xE7\xE3o Total
|
|
10176
10198
|
</div>
|
|
10177
10199
|
<div class="myio-device-comparison-tooltip__comparison">
|
|
10178
10200
|
<div class="myio-device-comparison-tooltip__comparison-header">
|
|
@@ -10184,21 +10206,30 @@
|
|
|
10184
10206
|
</div>
|
|
10185
10207
|
<div class="myio-device-comparison-tooltip__progress-container">
|
|
10186
10208
|
<div class="myio-device-comparison-tooltip__progress-bar">
|
|
10187
|
-
<div class="myio-device-comparison-tooltip__progress-fill total" style="width: ${Math.min(
|
|
10209
|
+
<div class="myio-device-comparison-tooltip__progress-fill total" style="width: ${Math.min(
|
|
10210
|
+
grandTotal.devicePercentage,
|
|
10211
|
+
100
|
|
10212
|
+
)}%"></div>
|
|
10188
10213
|
</div>
|
|
10189
10214
|
</div>
|
|
10190
10215
|
<div class="myio-device-comparison-tooltip__comparison-stats">
|
|
10191
10216
|
<div class="myio-device-comparison-tooltip__comparison-stat">
|
|
10192
10217
|
<div class="myio-device-comparison-tooltip__comparison-stat-label">Este Device</div>
|
|
10193
|
-
<div class="myio-device-comparison-tooltip__comparison-stat-value">${formatConsumption(
|
|
10218
|
+
<div class="myio-device-comparison-tooltip__comparison-stat-value">${formatConsumption(
|
|
10219
|
+
device.consumption
|
|
10220
|
+
)}</div>
|
|
10194
10221
|
</div>
|
|
10195
10222
|
<div class="myio-device-comparison-tooltip__comparison-stat">
|
|
10196
10223
|
<div class="myio-device-comparison-tooltip__comparison-stat-label">Total Geral</div>
|
|
10197
|
-
<div class="myio-device-comparison-tooltip__comparison-stat-value">${formatConsumption(
|
|
10224
|
+
<div class="myio-device-comparison-tooltip__comparison-stat-value">${formatConsumption(
|
|
10225
|
+
grandTotal.totalConsumption
|
|
10226
|
+
)}</div>
|
|
10198
10227
|
</div>
|
|
10199
10228
|
<div class="myio-device-comparison-tooltip__comparison-stat">
|
|
10200
10229
|
<div class="myio-device-comparison-tooltip__comparison-stat-label">Participacao</div>
|
|
10201
|
-
<div class="myio-device-comparison-tooltip__comparison-stat-value highlight">${formatPercentage(
|
|
10230
|
+
<div class="myio-device-comparison-tooltip__comparison-stat-value highlight">${formatPercentage(
|
|
10231
|
+
grandTotal.devicePercentage
|
|
10232
|
+
)}</div>
|
|
10202
10233
|
</div>
|
|
10203
10234
|
</div>
|
|
10204
10235
|
</div>
|
|
@@ -33878,8 +33909,11 @@
|
|
|
33878
33909
|
/**
|
|
33879
33910
|
* Build summary data from TELEMETRY_INFO STATE
|
|
33880
33911
|
* This is called by the widget controller to get data for the tooltip
|
|
33912
|
+
*
|
|
33913
|
+
* RFC-0105 Enhancement: Now fetches device lists from MyIOOrchestratorData
|
|
33914
|
+
* to populate device lists for status popup display
|
|
33881
33915
|
*/
|
|
33882
|
-
buildSummaryFromState(state5, receivedData) {
|
|
33916
|
+
buildSummaryFromState(state5, receivedData, domain = "energy") {
|
|
33883
33917
|
const summary = {
|
|
33884
33918
|
totalDevices: 0,
|
|
33885
33919
|
totalConsumption: 0,
|
|
@@ -33891,7 +33925,14 @@
|
|
|
33891
33925
|
failure: 0,
|
|
33892
33926
|
standby: 0,
|
|
33893
33927
|
offline: 0,
|
|
33894
|
-
noConsumption: 0
|
|
33928
|
+
noConsumption: 0,
|
|
33929
|
+
// Device lists - populated from orchestrator data
|
|
33930
|
+
normalDevices: [],
|
|
33931
|
+
alertDevices: [],
|
|
33932
|
+
failureDevices: [],
|
|
33933
|
+
standbyDevices: [],
|
|
33934
|
+
offlineDevices: [],
|
|
33935
|
+
noConsumptionDevices: []
|
|
33895
33936
|
},
|
|
33896
33937
|
lastUpdated: (/* @__PURE__ */ new Date()).toISOString()
|
|
33897
33938
|
};
|
|
@@ -34008,38 +34049,124 @@
|
|
|
34008
34049
|
summary.byCategory = [entrada, lojas, areaComum];
|
|
34009
34050
|
summary.totalDevices = entrada.deviceCount + lojas.deviceCount + areaComumDeviceCount;
|
|
34010
34051
|
summary.totalConsumption = state5.grandTotal || entrada.consumption;
|
|
34011
|
-
const
|
|
34012
|
-
|
|
34013
|
-
if (statusData && typeof statusData === "object") {
|
|
34052
|
+
const widgetAggregation = receivedData?.deviceStatusAggregation;
|
|
34053
|
+
if (widgetAggregation && widgetAggregation.hasData) {
|
|
34014
34054
|
summary.byStatus = {
|
|
34015
|
-
normal:
|
|
34016
|
-
alert:
|
|
34017
|
-
failure:
|
|
34018
|
-
standby:
|
|
34019
|
-
offline:
|
|
34020
|
-
noConsumption:
|
|
34055
|
+
normal: widgetAggregation.normal || 0,
|
|
34056
|
+
alert: widgetAggregation.alert || 0,
|
|
34057
|
+
failure: widgetAggregation.failure || 0,
|
|
34058
|
+
standby: widgetAggregation.standby || 0,
|
|
34059
|
+
offline: widgetAggregation.offline || 0,
|
|
34060
|
+
noConsumption: widgetAggregation.noConsumption || 0,
|
|
34061
|
+
normalDevices: widgetAggregation.normalDevices || [],
|
|
34062
|
+
alertDevices: widgetAggregation.alertDevices || [],
|
|
34063
|
+
failureDevices: widgetAggregation.failureDevices || [],
|
|
34064
|
+
standbyDevices: widgetAggregation.standbyDevices || [],
|
|
34065
|
+
offlineDevices: widgetAggregation.offlineDevices || [],
|
|
34066
|
+
noConsumptionDevices: widgetAggregation.noConsumptionDevices || []
|
|
34021
34067
|
};
|
|
34022
34068
|
} else {
|
|
34023
|
-
|
|
34024
|
-
|
|
34025
|
-
|
|
34026
|
-
|
|
34027
|
-
|
|
34028
|
-
|
|
34029
|
-
|
|
34030
|
-
|
|
34031
|
-
|
|
34032
|
-
|
|
34033
|
-
|
|
34034
|
-
|
|
34035
|
-
|
|
34036
|
-
|
|
34037
|
-
|
|
34038
|
-
|
|
34039
|
-
|
|
34040
|
-
|
|
34069
|
+
const statusAggregation = this._aggregateDeviceStatusFromOrchestrator(domain);
|
|
34070
|
+
if (statusAggregation.hasData) {
|
|
34071
|
+
summary.byStatus = statusAggregation.byStatus;
|
|
34072
|
+
} else {
|
|
34073
|
+
const totalDevices = summary.totalDevices;
|
|
34074
|
+
const statusData = receivedData?.statusCounts || receivedData?.deviceStatus || null;
|
|
34075
|
+
if (statusData && typeof statusData === "object") {
|
|
34076
|
+
summary.byStatus = {
|
|
34077
|
+
normal: statusData.normal || 0,
|
|
34078
|
+
alert: statusData.alert || 0,
|
|
34079
|
+
failure: statusData.failure || 0,
|
|
34080
|
+
standby: statusData.standby || 0,
|
|
34081
|
+
offline: statusData.offline || 0,
|
|
34082
|
+
noConsumption: statusData.noConsumption || statusData.zeroConsumption || 0
|
|
34083
|
+
};
|
|
34084
|
+
} else {
|
|
34085
|
+
summary.byStatus = {
|
|
34086
|
+
normal: Math.floor(totalDevices * 0.75),
|
|
34087
|
+
alert: Math.floor(totalDevices * 0.06),
|
|
34088
|
+
failure: Math.floor(totalDevices * 0.02),
|
|
34089
|
+
standby: Math.floor(totalDevices * 0.02),
|
|
34090
|
+
offline: Math.floor(totalDevices * 0.03),
|
|
34091
|
+
noConsumption: Math.floor(totalDevices * 0.12)
|
|
34092
|
+
};
|
|
34093
|
+
const statusSum = Object.values(summary.byStatus).reduce((a, b) => {
|
|
34094
|
+
return typeof b === "number" ? a + b : a;
|
|
34095
|
+
}, 0);
|
|
34096
|
+
if (statusSum !== totalDevices && totalDevices > 0) {
|
|
34097
|
+
summary.byStatus.normal += totalDevices - statusSum;
|
|
34098
|
+
}
|
|
34099
|
+
}
|
|
34100
|
+
}
|
|
34041
34101
|
}
|
|
34042
34102
|
return summary;
|
|
34103
|
+
},
|
|
34104
|
+
/**
|
|
34105
|
+
* RFC-0105: Aggregate device status from MyIOOrchestratorData
|
|
34106
|
+
* Iterates through all orchestrator items and groups devices by status
|
|
34107
|
+
* Returns both counts and device lists
|
|
34108
|
+
*/
|
|
34109
|
+
_aggregateDeviceStatusFromOrchestrator(domain = "energy") {
|
|
34110
|
+
const result = {
|
|
34111
|
+
normal: 0,
|
|
34112
|
+
alert: 0,
|
|
34113
|
+
failure: 0,
|
|
34114
|
+
standby: 0,
|
|
34115
|
+
offline: 0,
|
|
34116
|
+
noConsumption: 0,
|
|
34117
|
+
normalDevices: [],
|
|
34118
|
+
alertDevices: [],
|
|
34119
|
+
failureDevices: [],
|
|
34120
|
+
standbyDevices: [],
|
|
34121
|
+
offlineDevices: [],
|
|
34122
|
+
noConsumptionDevices: []
|
|
34123
|
+
};
|
|
34124
|
+
const win = typeof window !== "undefined" ? window : null;
|
|
34125
|
+
if (!win) return { hasData: false, byStatus: result };
|
|
34126
|
+
const orchestratorData = win.MyIOOrchestratorData || win.parent?.MyIOOrchestratorData;
|
|
34127
|
+
if (!orchestratorData || !orchestratorData[domain]) {
|
|
34128
|
+
return { hasData: false, byStatus: result };
|
|
34129
|
+
}
|
|
34130
|
+
const domainData = orchestratorData[domain];
|
|
34131
|
+
const items = domainData.items || [];
|
|
34132
|
+
if (!items || items.length === 0) {
|
|
34133
|
+
return { hasData: false, byStatus: result };
|
|
34134
|
+
}
|
|
34135
|
+
const NO_CONSUMPTION_THRESHOLD = 0.01;
|
|
34136
|
+
const statusMapping = {
|
|
34137
|
+
"power_on": "normal",
|
|
34138
|
+
"warning": "alert",
|
|
34139
|
+
"failure": "failure",
|
|
34140
|
+
"standby": "standby",
|
|
34141
|
+
"power_off": "offline",
|
|
34142
|
+
"maintenance": "offline",
|
|
34143
|
+
"no_info": "offline",
|
|
34144
|
+
"not_installed": "offline",
|
|
34145
|
+
"offline": "offline"
|
|
34146
|
+
};
|
|
34147
|
+
items.forEach((item) => {
|
|
34148
|
+
const deviceInfo = {
|
|
34149
|
+
id: item.id || item.deviceId || "",
|
|
34150
|
+
label: item.label || item.entityLabel || item.name || item.deviceIdentifier || "",
|
|
34151
|
+
name: item.name || item.entityLabel || ""
|
|
34152
|
+
};
|
|
34153
|
+
const deviceStatus = item.deviceStatus || "no_info";
|
|
34154
|
+
const value = Number(item.value || item.val || 0);
|
|
34155
|
+
const isOnline = !["no_info", "offline", "not_installed", "maintenance", "power_off"].includes(deviceStatus);
|
|
34156
|
+
if (isOnline && Math.abs(value) < NO_CONSUMPTION_THRESHOLD) {
|
|
34157
|
+
result.noConsumption++;
|
|
34158
|
+
result.noConsumptionDevices?.push(deviceInfo);
|
|
34159
|
+
return;
|
|
34160
|
+
}
|
|
34161
|
+
const mappedStatus = statusMapping[deviceStatus] || "offline";
|
|
34162
|
+
result[mappedStatus]++;
|
|
34163
|
+
const deviceListKey = `${mappedStatus}Devices`;
|
|
34164
|
+
const deviceList = result[deviceListKey];
|
|
34165
|
+
if (deviceList) {
|
|
34166
|
+
deviceList.push(deviceInfo);
|
|
34167
|
+
}
|
|
34168
|
+
});
|
|
34169
|
+
return { hasData: true, byStatus: result };
|
|
34043
34170
|
}
|
|
34044
34171
|
};
|
|
34045
34172
|
|
|
@@ -35197,8 +35324,11 @@
|
|
|
35197
35324
|
/**
|
|
35198
35325
|
* Build summary data from TELEMETRY_INFO STATE_WATER
|
|
35199
35326
|
* This is called by the widget controller to get data for the tooltip
|
|
35327
|
+
*
|
|
35328
|
+
* RFC-0105 Enhancement: Now fetches device lists from MyIOOrchestratorData
|
|
35329
|
+
* to populate device lists for status popup display
|
|
35200
35330
|
*/
|
|
35201
|
-
buildSummaryFromState(state5, receivedData, includeBathrooms = false) {
|
|
35331
|
+
buildSummaryFromState(state5, receivedData, includeBathrooms = false, domain = "water") {
|
|
35202
35332
|
const summary = {
|
|
35203
35333
|
totalDevices: 0,
|
|
35204
35334
|
totalConsumption: 0,
|
|
@@ -35210,7 +35340,14 @@
|
|
|
35210
35340
|
failure: 0,
|
|
35211
35341
|
standby: 0,
|
|
35212
35342
|
offline: 0,
|
|
35213
|
-
noConsumption: 0
|
|
35343
|
+
noConsumption: 0,
|
|
35344
|
+
// Device lists - populated from orchestrator data
|
|
35345
|
+
normalDevices: [],
|
|
35346
|
+
alertDevices: [],
|
|
35347
|
+
failureDevices: [],
|
|
35348
|
+
standbyDevices: [],
|
|
35349
|
+
offlineDevices: [],
|
|
35350
|
+
noConsumptionDevices: []
|
|
35214
35351
|
},
|
|
35215
35352
|
lastUpdated: (/* @__PURE__ */ new Date()).toISOString(),
|
|
35216
35353
|
includeBathrooms
|
|
@@ -35266,32 +35403,124 @@
|
|
|
35266
35403
|
}
|
|
35267
35404
|
summary.totalDevices = summary.byCategory.reduce((sum, cat) => sum + cat.deviceCount, 0);
|
|
35268
35405
|
summary.totalConsumption = state5.entrada?.total || 0;
|
|
35269
|
-
const
|
|
35270
|
-
|
|
35271
|
-
if (statusData && typeof statusData === "object") {
|
|
35406
|
+
const widgetAggregation = receivedData?.deviceStatusAggregation;
|
|
35407
|
+
if (widgetAggregation && widgetAggregation.hasData) {
|
|
35272
35408
|
summary.byStatus = {
|
|
35273
|
-
normal:
|
|
35274
|
-
alert:
|
|
35275
|
-
failure:
|
|
35276
|
-
standby:
|
|
35277
|
-
offline:
|
|
35278
|
-
noConsumption:
|
|
35409
|
+
normal: widgetAggregation.normal || 0,
|
|
35410
|
+
alert: widgetAggregation.alert || 0,
|
|
35411
|
+
failure: widgetAggregation.failure || 0,
|
|
35412
|
+
standby: widgetAggregation.standby || 0,
|
|
35413
|
+
offline: widgetAggregation.offline || 0,
|
|
35414
|
+
noConsumption: widgetAggregation.noConsumption || 0,
|
|
35415
|
+
normalDevices: widgetAggregation.normalDevices || [],
|
|
35416
|
+
alertDevices: widgetAggregation.alertDevices || [],
|
|
35417
|
+
failureDevices: widgetAggregation.failureDevices || [],
|
|
35418
|
+
standbyDevices: widgetAggregation.standbyDevices || [],
|
|
35419
|
+
offlineDevices: widgetAggregation.offlineDevices || [],
|
|
35420
|
+
noConsumptionDevices: widgetAggregation.noConsumptionDevices || []
|
|
35279
35421
|
};
|
|
35280
35422
|
} else {
|
|
35281
|
-
|
|
35282
|
-
|
|
35283
|
-
|
|
35284
|
-
|
|
35285
|
-
|
|
35286
|
-
|
|
35287
|
-
|
|
35288
|
-
|
|
35289
|
-
|
|
35290
|
-
|
|
35291
|
-
|
|
35292
|
-
|
|
35423
|
+
const statusAggregation = this._aggregateDeviceStatusFromOrchestrator(domain);
|
|
35424
|
+
if (statusAggregation.hasData) {
|
|
35425
|
+
summary.byStatus = statusAggregation.byStatus;
|
|
35426
|
+
} else {
|
|
35427
|
+
const totalDevices = summary.totalDevices;
|
|
35428
|
+
const statusData = receivedData?.statusCounts || receivedData?.deviceStatus || null;
|
|
35429
|
+
if (statusData && typeof statusData === "object") {
|
|
35430
|
+
summary.byStatus = {
|
|
35431
|
+
normal: statusData.normal || 0,
|
|
35432
|
+
alert: statusData.alert || 0,
|
|
35433
|
+
failure: statusData.failure || 0,
|
|
35434
|
+
standby: statusData.standby || 0,
|
|
35435
|
+
offline: statusData.offline || 0,
|
|
35436
|
+
noConsumption: statusData.noConsumption || statusData.zeroConsumption || 0
|
|
35437
|
+
};
|
|
35438
|
+
} else {
|
|
35439
|
+
summary.byStatus = {
|
|
35440
|
+
normal: Math.floor(totalDevices * 0.8),
|
|
35441
|
+
alert: Math.floor(totalDevices * 0.05),
|
|
35442
|
+
failure: Math.floor(totalDevices * 0.02),
|
|
35443
|
+
standby: Math.floor(totalDevices * 0.02),
|
|
35444
|
+
offline: Math.floor(totalDevices * 0.03),
|
|
35445
|
+
noConsumption: Math.floor(totalDevices * 0.08)
|
|
35446
|
+
};
|
|
35447
|
+
const statusSum = Object.values(summary.byStatus).reduce((a, b) => {
|
|
35448
|
+
return typeof b === "number" ? a + b : a;
|
|
35449
|
+
}, 0);
|
|
35450
|
+
if (statusSum !== totalDevices && totalDevices > 0) {
|
|
35451
|
+
summary.byStatus.normal += totalDevices - statusSum;
|
|
35452
|
+
}
|
|
35453
|
+
}
|
|
35454
|
+
}
|
|
35293
35455
|
}
|
|
35294
35456
|
return summary;
|
|
35457
|
+
},
|
|
35458
|
+
/**
|
|
35459
|
+
* RFC-0105: Aggregate device status from MyIOOrchestratorData
|
|
35460
|
+
* Iterates through all orchestrator items and groups devices by status
|
|
35461
|
+
* Returns both counts and device lists
|
|
35462
|
+
*/
|
|
35463
|
+
_aggregateDeviceStatusFromOrchestrator(domain = "water") {
|
|
35464
|
+
const result = {
|
|
35465
|
+
normal: 0,
|
|
35466
|
+
alert: 0,
|
|
35467
|
+
failure: 0,
|
|
35468
|
+
standby: 0,
|
|
35469
|
+
offline: 0,
|
|
35470
|
+
noConsumption: 0,
|
|
35471
|
+
normalDevices: [],
|
|
35472
|
+
alertDevices: [],
|
|
35473
|
+
failureDevices: [],
|
|
35474
|
+
standbyDevices: [],
|
|
35475
|
+
offlineDevices: [],
|
|
35476
|
+
noConsumptionDevices: []
|
|
35477
|
+
};
|
|
35478
|
+
const win = typeof window !== "undefined" ? window : null;
|
|
35479
|
+
if (!win) return { hasData: false, byStatus: result };
|
|
35480
|
+
const orchestratorData = win.MyIOOrchestratorData || win.parent?.MyIOOrchestratorData;
|
|
35481
|
+
if (!orchestratorData || !orchestratorData[domain]) {
|
|
35482
|
+
return { hasData: false, byStatus: result };
|
|
35483
|
+
}
|
|
35484
|
+
const domainData = orchestratorData[domain];
|
|
35485
|
+
const items = domainData.items || [];
|
|
35486
|
+
if (!items || items.length === 0) {
|
|
35487
|
+
return { hasData: false, byStatus: result };
|
|
35488
|
+
}
|
|
35489
|
+
const NO_CONSUMPTION_THRESHOLD = 1e-3;
|
|
35490
|
+
const statusMapping = {
|
|
35491
|
+
"power_on": "normal",
|
|
35492
|
+
"warning": "alert",
|
|
35493
|
+
"failure": "failure",
|
|
35494
|
+
"standby": "standby",
|
|
35495
|
+
"power_off": "offline",
|
|
35496
|
+
"maintenance": "offline",
|
|
35497
|
+
"no_info": "offline",
|
|
35498
|
+
"not_installed": "offline",
|
|
35499
|
+
"offline": "offline"
|
|
35500
|
+
};
|
|
35501
|
+
items.forEach((item) => {
|
|
35502
|
+
const deviceInfo = {
|
|
35503
|
+
id: item.id || item.deviceId || "",
|
|
35504
|
+
label: item.label || item.entityLabel || item.name || item.deviceIdentifier || "",
|
|
35505
|
+
name: item.name || item.entityLabel || ""
|
|
35506
|
+
};
|
|
35507
|
+
const deviceStatus = item.deviceStatus || "no_info";
|
|
35508
|
+
const value = Number(item.value || item.val || 0);
|
|
35509
|
+
const isOnline = !["no_info", "offline", "not_installed", "maintenance", "power_off"].includes(deviceStatus);
|
|
35510
|
+
if (isOnline && Math.abs(value) < NO_CONSUMPTION_THRESHOLD) {
|
|
35511
|
+
result.noConsumption++;
|
|
35512
|
+
result.noConsumptionDevices?.push(deviceInfo);
|
|
35513
|
+
return;
|
|
35514
|
+
}
|
|
35515
|
+
const mappedStatus = statusMapping[deviceStatus] || "offline";
|
|
35516
|
+
result[mappedStatus]++;
|
|
35517
|
+
const deviceListKey = `${mappedStatus}Devices`;
|
|
35518
|
+
const deviceList = result[deviceListKey];
|
|
35519
|
+
if (deviceList) {
|
|
35520
|
+
deviceList.push(deviceInfo);
|
|
35521
|
+
}
|
|
35522
|
+
});
|
|
35523
|
+
return { hasData: true, byStatus: result };
|
|
35295
35524
|
}
|
|
35296
35525
|
};
|
|
35297
35526
|
|