myio-js-library 0.1.239 → 0.1.241

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 CHANGED
@@ -712,6 +712,7 @@ __export(index_exports, {
712
712
  groupByDay: () => groupByDay,
713
713
  handleDeviceType: () => handleDeviceType,
714
714
  interpolateTemperature: () => interpolateTemperature,
715
+ isConnectionStale: () => isConnectionStale,
715
716
  isDeviceOffline: () => isDeviceOffline,
716
717
  isEnergyDevice: () => isEnergyDevice,
717
718
  isHydrometerDevice: () => isHydrometerDevice,
@@ -1604,6 +1605,27 @@ function normalizeConnectionStatus(rawStatus) {
1604
1605
  }
1605
1606
  return "offline";
1606
1607
  }
1608
+ function isConnectionStale({
1609
+ lastConnectTime = null,
1610
+ lastDisconnectTime = null,
1611
+ delayTimeConnectionInMins = 60
1612
+ } = {}) {
1613
+ if (!lastConnectTime) {
1614
+ return false;
1615
+ }
1616
+ const lastConnect = new Date(lastConnectTime);
1617
+ const lastDisconnect = lastDisconnectTime ? new Date(lastDisconnectTime) : null;
1618
+ const now = /* @__PURE__ */ new Date();
1619
+ const delayMs = delayTimeConnectionInMins * 60 * 1e3;
1620
+ if (lastDisconnect && lastDisconnect.getTime() > lastConnect.getTime()) {
1621
+ return true;
1622
+ }
1623
+ const timeSinceConnect = now.getTime() - lastConnect.getTime();
1624
+ if (timeSinceConnect > delayMs) {
1625
+ return true;
1626
+ }
1627
+ return false;
1628
+ }
1607
1629
  function mapConnectionStatus(rawStatus) {
1608
1630
  return normalizeConnectionStatus(rawStatus);
1609
1631
  }
@@ -1670,14 +1692,26 @@ function calculateDeviceStatus({
1670
1692
  lastConsumptionValue,
1671
1693
  limitOfPowerOnStandByWatts,
1672
1694
  limitOfPowerOnAlertWatts,
1673
- limitOfPowerOnFailureWatts
1695
+ limitOfPowerOnFailureWatts,
1696
+ // RFC-0110: Optional timestamp parameters for stale connection detection
1697
+ lastConnectTime = null,
1698
+ lastDisconnectTime = null,
1699
+ delayTimeConnectionInMins = 60
1674
1700
  }) {
1675
1701
  const normalizedStatus = normalizeConnectionStatus(connectionStatus);
1676
1702
  if (normalizedStatus === "waiting") {
1677
1703
  return DeviceStatusType.NOT_INSTALLED;
1678
1704
  }
1679
1705
  if (normalizedStatus === "offline") {
1680
- return DeviceStatusType.NO_INFO;
1706
+ return DeviceStatusType.OFFLINE;
1707
+ }
1708
+ const connectionStale = isConnectionStale({
1709
+ lastConnectTime,
1710
+ lastDisconnectTime,
1711
+ delayTimeConnectionInMins
1712
+ });
1713
+ if (connectionStale && normalizedStatus === "online") {
1714
+ return DeviceStatusType.OFFLINE;
1681
1715
  }
1682
1716
  if (normalizedStatus === "bad") {
1683
1717
  return DeviceStatusType.WEAK_CONNECTION;
@@ -1708,14 +1742,26 @@ function calculateDeviceStatus({
1708
1742
  function calculateDeviceStatusWithRanges({
1709
1743
  connectionStatus,
1710
1744
  lastConsumptionValue,
1711
- ranges
1745
+ ranges,
1746
+ // RFC-0110: Optional timestamp parameters for stale connection detection
1747
+ lastConnectTime = null,
1748
+ lastDisconnectTime = null,
1749
+ delayTimeConnectionInMins = 60
1712
1750
  }) {
1713
1751
  const normalizedStatus = normalizeConnectionStatus(connectionStatus);
1714
1752
  if (normalizedStatus === "waiting") {
1715
1753
  return DeviceStatusType.NOT_INSTALLED;
1716
1754
  }
1717
1755
  if (normalizedStatus === "offline") {
1718
- return DeviceStatusType.NO_INFO;
1756
+ return DeviceStatusType.OFFLINE;
1757
+ }
1758
+ const connectionStale = isConnectionStale({
1759
+ lastConnectTime,
1760
+ lastDisconnectTime,
1761
+ delayTimeConnectionInMins
1762
+ });
1763
+ if (connectionStale && normalizedStatus === "online") {
1764
+ return DeviceStatusType.OFFLINE;
1719
1765
  }
1720
1766
  if (normalizedStatus === "bad") {
1721
1767
  return DeviceStatusType.WEAK_CONNECTION;
@@ -1851,7 +1897,9 @@ function createDeviceItem(entityId, meta, options = {}) {
1851
1897
  labelWidget = null,
1852
1898
  apiRow = null,
1853
1899
  globalMapInstantaneousPower = null,
1854
- temperatureLimits = null
1900
+ temperatureLimits = null,
1901
+ // RFC-0110: Configurable delay time for stale connection detection (default 60 min)
1902
+ delayTimeConnectionInMins = 60
1855
1903
  } = options;
1856
1904
  const deviceType = meta.deviceType || meta.deviceProfile || "";
1857
1905
  const deviceProfile = meta.deviceProfile || deviceType || "";
@@ -1874,11 +1922,19 @@ function createDeviceItem(entityId, meta, options = {}) {
1874
1922
  deviceStatus = calculateDeviceStatusWithRanges({
1875
1923
  connectionStatus,
1876
1924
  lastConsumptionValue: consumptionValue,
1877
- ranges
1925
+ ranges,
1926
+ lastConnectTime: meta.lastConnectTime ?? null,
1927
+ lastDisconnectTime: meta.lastDisconnectTime ?? null,
1928
+ delayTimeConnectionInMins
1878
1929
  });
1879
1930
  } else {
1880
- if (connectionStatus === "offline") {
1881
- deviceStatus = DeviceStatusType.NO_INFO;
1931
+ const staleConnection = isConnectionStale({
1932
+ lastConnectTime: meta.lastConnectTime,
1933
+ lastDisconnectTime: meta.lastDisconnectTime,
1934
+ delayTimeConnectionInMins
1935
+ });
1936
+ if (connectionStatus === "offline" || staleConnection) {
1937
+ deviceStatus = DeviceStatusType.OFFLINE;
1882
1938
  } else if (connectionStatus === "bad") {
1883
1939
  deviceStatus = DeviceStatusType.WEAK_CONNECTION;
1884
1940
  } else if (connectionStatus === "waiting") {
@@ -2001,7 +2057,10 @@ function recalculateDeviceStatus(item, newData = {}, options = {}) {
2001
2057
  ...newData,
2002
2058
  connectionStatus: newData.connectionStatus ?? item.connectionStatus,
2003
2059
  consumption: newData.value ?? newData.consumption ?? item.consumptionPower ?? item.value,
2004
- deviceMapInstaneousPower: newData.deviceMapInstaneousPower ?? item.deviceMapInstaneousPower
2060
+ deviceMapInstaneousPower: newData.deviceMapInstaneousPower ?? item.deviceMapInstaneousPower,
2061
+ // RFC-0110: Ensure timestamps are passed through
2062
+ lastConnectTime: newData.lastConnectTime ?? item.lastConnectTime,
2063
+ lastDisconnectTime: newData.lastDisconnectTime ?? item.lastDisconnectTime
2005
2064
  };
2006
2065
  const updatedOptions = {
2007
2066
  domain: options.domain ?? getDomainFromDeviceType(item.deviceType),
@@ -2010,7 +2069,9 @@ function recalculateDeviceStatus(item, newData = {}, options = {}) {
2010
2069
  temperatureLimits: options.temperatureLimits ?? {
2011
2070
  min: item.temperatureMin,
2012
2071
  max: item.temperatureMax
2013
- }
2072
+ },
2073
+ // RFC-0110: Pass delay time for stale connection detection
2074
+ delayTimeConnectionInMins: options.delayTimeConnectionInMins ?? 60
2014
2075
  };
2015
2076
  return createDeviceItem(item.tbId, updatedMeta, updatedOptions);
2016
2077
  }
@@ -34225,10 +34286,10 @@ var ENERGY_SUMMARY_TOOLTIP_CSS = `
34225
34286
  font-size: 11px;
34226
34287
  }
34227
34288
 
34228
- /* Status Matrix */
34289
+ /* Status Matrix - RFC-0109: 8 status items (4 columns x 2 rows) */
34229
34290
  .energy-summary-tooltip__status-matrix {
34230
34291
  display: grid;
34231
- grid-template-columns: repeat(3, 1fr);
34292
+ grid-template-columns: repeat(4, 1fr);
34232
34293
  gap: 6px;
34233
34294
  margin: 6px 0 12px 0;
34234
34295
  }
@@ -34268,6 +34329,17 @@ var ENERGY_SUMMARY_TOOLTIP_CSS = `
34268
34329
  color: #6b7280;
34269
34330
  }
34270
34331
 
34332
+ .energy-summary-tooltip__status-item.waiting {
34333
+ background: #fef3c7;
34334
+ color: #92400e;
34335
+ border: 1px dashed #f59e0b;
34336
+ }
34337
+
34338
+ .energy-summary-tooltip__status-item.weak-connection {
34339
+ background: #ffedd5;
34340
+ color: #c2410c;
34341
+ }
34342
+
34271
34343
  .energy-summary-tooltip__status-item.no-consumption {
34272
34344
  background: #f8fafc;
34273
34345
  color: #9ca3af;
@@ -34286,6 +34358,8 @@ var ENERGY_SUMMARY_TOOLTIP_CSS = `
34286
34358
  .energy-summary-tooltip__status-dot.failure { background: #ef4444; }
34287
34359
  .energy-summary-tooltip__status-dot.standby { background: #3b82f6; }
34288
34360
  .energy-summary-tooltip__status-dot.offline { background: #6b7280; }
34361
+ .energy-summary-tooltip__status-dot.waiting { background: #fbbf24; }
34362
+ .energy-summary-tooltip__status-dot.weak-connection { background: #fb923c; }
34289
34363
  .energy-summary-tooltip__status-dot.no-consumption { background: #d1d5db; }
34290
34364
 
34291
34365
  .energy-summary-tooltip__status-count {
@@ -34349,6 +34423,16 @@ var ENERGY_SUMMARY_TOOLTIP_CSS = `
34349
34423
  color: white;
34350
34424
  }
34351
34425
 
34426
+ .energy-summary-tooltip__status-item.waiting .energy-summary-tooltip__status-expand:hover {
34427
+ background: #92400e;
34428
+ color: white;
34429
+ }
34430
+
34431
+ .energy-summary-tooltip__status-item.weak-connection .energy-summary-tooltip__status-expand:hover {
34432
+ background: #c2410c;
34433
+ color: white;
34434
+ }
34435
+
34352
34436
  .energy-summary-tooltip__status-item.no-consumption .energy-summary-tooltip__status-expand:hover {
34353
34437
  background: #9ca3af;
34354
34438
  color: white;
@@ -34363,6 +34447,8 @@ var ENERGY_SUMMARY_TOOLTIP_CSS = `
34363
34447
  .energy-summary-tooltip__device-dot.failure { background: #ef4444; }
34364
34448
  .energy-summary-tooltip__device-dot.standby { background: #3b82f6; }
34365
34449
  .energy-summary-tooltip__device-dot.offline { background: #6b7280; }
34450
+ .energy-summary-tooltip__device-dot.waiting { background: #fbbf24; }
34451
+ .energy-summary-tooltip__device-dot.weak-connection { background: #fb923c; }
34366
34452
  .energy-summary-tooltip__device-dot.no-consumption { background: #d1d5db; }
34367
34453
 
34368
34454
  /* Total Consumption Footer */
@@ -34447,6 +34533,12 @@ var ENERGY_SUMMARY_TOOLTIP_CSS = `
34447
34533
  }
34448
34534
 
34449
34535
  /* Responsive adjustments */
34536
+ @media (max-width: 800px) {
34537
+ .energy-summary-tooltip__status-matrix {
34538
+ grid-template-columns: repeat(3, 1fr);
34539
+ }
34540
+ }
34541
+
34450
34542
  @media (max-width: 600px) {
34451
34543
  .energy-summary-tooltip__content {
34452
34544
  min-width: 360px;
@@ -34566,17 +34658,23 @@ var EnergySummaryTooltip = {
34566
34658
  },
34567
34659
  /**
34568
34660
  * Render status matrix with expand buttons
34661
+ * RFC-0109: Reorganized to show connectivity status separately from consumption status
34662
+ * Note: A device can appear in multiple categories (e.g., offline AND noConsumption)
34569
34663
  */
34570
34664
  renderStatusMatrix(status) {
34571
- const items = [
34665
+ const connectivityItems = [
34666
+ { key: "waiting", label: "N\xE3o Instalado", count: status.waiting, devices: status.waitingDevices },
34667
+ { key: "weak-connection", label: "Conex\xE3o Fraca", count: status.weakConnection, devices: status.weakConnectionDevices },
34668
+ { key: "offline", label: "Offline", count: status.offline, devices: status.offlineDevices }
34669
+ ];
34670
+ const consumptionItems = [
34572
34671
  { key: "normal", label: "Normal", count: status.normal, devices: status.normalDevices },
34573
34672
  { key: "alert", label: "Alerta", count: status.alert, devices: status.alertDevices },
34574
34673
  { key: "failure", label: "Falha", count: status.failure, devices: status.failureDevices },
34575
34674
  { key: "standby", label: "Standby", count: status.standby, devices: status.standbyDevices },
34576
- { key: "offline", label: "Offline", count: status.offline, devices: status.offlineDevices },
34577
34675
  { key: "no-consumption", label: "Sem Consumo", count: status.noConsumption, devices: status.noConsumptionDevices }
34578
34676
  ];
34579
- return items.map((item) => {
34677
+ const renderItem = (item) => {
34580
34678
  const expandBtn = item.count > 0 ? `
34581
34679
  <button
34582
34680
  class="energy-summary-tooltip__status-expand"
@@ -34593,7 +34691,9 @@ var EnergySummaryTooltip = {
34593
34691
  ${expandBtn}
34594
34692
  </div>
34595
34693
  `;
34596
- }).join("");
34694
+ };
34695
+ const allItems = [...connectivityItems, ...consumptionItems];
34696
+ return allItems.map(renderItem).join("");
34597
34697
  },
34598
34698
  /**
34599
34699
  * Render excluded devices notice (if any devices are excluded from CAG)
@@ -34853,11 +34953,15 @@ var EnergySummaryTooltip = {
34853
34953
  _getDevicesForStatus(statusKey) {
34854
34954
  if (!this._currentStatus) return [];
34855
34955
  const deviceMap = {
34956
+ // Connectivity status (RFC-0109)
34957
+ "waiting": this._currentStatus.waitingDevices,
34958
+ "weak-connection": this._currentStatus.weakConnectionDevices,
34959
+ "offline": this._currentStatus.offlineDevices,
34960
+ // Consumption status
34856
34961
  "normal": this._currentStatus.normalDevices,
34857
34962
  "alert": this._currentStatus.alertDevices,
34858
34963
  "failure": this._currentStatus.failureDevices,
34859
34964
  "standby": this._currentStatus.standbyDevices,
34860
- "offline": this._currentStatus.offlineDevices,
34861
34965
  "no-consumption": this._currentStatus.noConsumptionDevices
34862
34966
  };
34863
34967
  return deviceMap[statusKey] || [];
@@ -34867,11 +34971,15 @@ var EnergySummaryTooltip = {
34867
34971
  */
34868
34972
  _getStatusIcon(statusKey) {
34869
34973
  const icons = {
34974
+ // Connectivity status (RFC-0109)
34975
+ "waiting": "\u{1F4E6}",
34976
+ "weak-connection": "\u{1F4F6}",
34977
+ "offline": "\u{1F4F4}",
34978
+ // Consumption status
34870
34979
  "normal": "\u2705",
34871
34980
  "alert": "\u26A0\uFE0F",
34872
34981
  "failure": "\u274C",
34873
34982
  "standby": "\u{1F4A4}",
34874
- "offline": "\u{1F4F4}",
34875
34983
  "no-consumption": "\u{1F50C}"
34876
34984
  };
34877
34985
  return icons[statusKey] || "\u{1F4CB}";
@@ -35234,18 +35342,24 @@ var EnergySummaryTooltip = {
35234
35342
  unit: "kWh",
35235
35343
  byCategory: [],
35236
35344
  byStatus: {
35345
+ // Connectivity status (RFC-0109)
35346
+ waiting: 0,
35347
+ weakConnection: 0,
35348
+ offline: 0,
35349
+ // Consumption status
35237
35350
  normal: 0,
35238
35351
  alert: 0,
35239
35352
  failure: 0,
35240
35353
  standby: 0,
35241
- offline: 0,
35242
35354
  noConsumption: 0,
35243
35355
  // Device lists - populated from orchestrator data
35356
+ waitingDevices: [],
35357
+ weakConnectionDevices: [],
35358
+ offlineDevices: [],
35244
35359
  normalDevices: [],
35245
35360
  alertDevices: [],
35246
35361
  failureDevices: [],
35247
35362
  standbyDevices: [],
35248
- offlineDevices: [],
35249
35363
  noConsumptionDevices: []
35250
35364
  },
35251
35365
  lastUpdated: (/* @__PURE__ */ new Date()).toISOString()
@@ -35366,20 +35480,27 @@ var EnergySummaryTooltip = {
35366
35480
  const widgetAggregation = receivedData?.deviceStatusAggregation;
35367
35481
  if (widgetAggregation && widgetAggregation.hasData) {
35368
35482
  summary.byStatus = {
35483
+ // Connectivity status (RFC-0109)
35484
+ waiting: widgetAggregation.waiting || 0,
35485
+ weakConnection: widgetAggregation.weakConnection || 0,
35486
+ offline: widgetAggregation.offline || 0,
35487
+ // Consumption status
35369
35488
  normal: widgetAggregation.normal || 0,
35370
35489
  alert: widgetAggregation.alert || 0,
35371
35490
  failure: widgetAggregation.failure || 0,
35372
35491
  standby: widgetAggregation.standby || 0,
35373
- offline: widgetAggregation.offline || 0,
35374
35492
  noConsumption: widgetAggregation.noConsumption || 0,
35493
+ // Device lists
35494
+ waitingDevices: widgetAggregation.waitingDevices || [],
35495
+ weakConnectionDevices: widgetAggregation.weakConnectionDevices || [],
35496
+ offlineDevices: widgetAggregation.offlineDevices || [],
35375
35497
  normalDevices: widgetAggregation.normalDevices || [],
35376
35498
  alertDevices: widgetAggregation.alertDevices || [],
35377
35499
  failureDevices: widgetAggregation.failureDevices || [],
35378
35500
  standbyDevices: widgetAggregation.standbyDevices || [],
35379
- offlineDevices: widgetAggregation.offlineDevices || [],
35380
35501
  noConsumptionDevices: widgetAggregation.noConsumptionDevices || []
35381
35502
  };
35382
- const orchestratorTotal = (widgetAggregation.normal || 0) + (widgetAggregation.alert || 0) + (widgetAggregation.failure || 0) + (widgetAggregation.standby || 0) + (widgetAggregation.offline || 0) + (widgetAggregation.noConsumption || 0);
35503
+ const orchestratorTotal = (widgetAggregation.waiting || 0) + (widgetAggregation.weakConnection || 0) + (widgetAggregation.offline || 0) + (widgetAggregation.normal || 0) + (widgetAggregation.alert || 0) + (widgetAggregation.failure || 0) + (widgetAggregation.standby || 0);
35383
35504
  if (orchestratorTotal > 0) {
35384
35505
  summary.totalDevices = orchestratorTotal;
35385
35506
  }
@@ -35387,7 +35508,7 @@ var EnergySummaryTooltip = {
35387
35508
  const statusAggregation = this._aggregateDeviceStatusFromOrchestrator(domain);
35388
35509
  if (statusAggregation.hasData) {
35389
35510
  summary.byStatus = statusAggregation.byStatus;
35390
- const orchestratorTotal = statusAggregation.byStatus.normal + statusAggregation.byStatus.alert + statusAggregation.byStatus.failure + statusAggregation.byStatus.standby + statusAggregation.byStatus.offline + statusAggregation.byStatus.noConsumption;
35511
+ const orchestratorTotal = statusAggregation.byStatus.waiting + statusAggregation.byStatus.weakConnection + statusAggregation.byStatus.offline + statusAggregation.byStatus.normal + statusAggregation.byStatus.alert + statusAggregation.byStatus.failure + statusAggregation.byStatus.standby;
35391
35512
  if (orchestratorTotal > 0) {
35392
35513
  summary.totalDevices = orchestratorTotal;
35393
35514
  }
@@ -35396,25 +35517,31 @@ var EnergySummaryTooltip = {
35396
35517
  const statusData = receivedData?.statusCounts || receivedData?.deviceStatus || null;
35397
35518
  if (statusData && typeof statusData === "object") {
35398
35519
  summary.byStatus = {
35520
+ // Connectivity status (RFC-0109)
35521
+ waiting: statusData.waiting || statusData.notInstalled || 0,
35522
+ weakConnection: statusData.weakConnection || statusData.badConnection || 0,
35523
+ offline: statusData.offline || 0,
35524
+ // Consumption status
35399
35525
  normal: statusData.normal || 0,
35400
35526
  alert: statusData.alert || 0,
35401
35527
  failure: statusData.failure || 0,
35402
35528
  standby: statusData.standby || 0,
35403
- offline: statusData.offline || 0,
35404
35529
  noConsumption: statusData.noConsumption || statusData.zeroConsumption || 0
35405
35530
  };
35406
35531
  } else {
35407
35532
  summary.byStatus = {
35408
- normal: Math.floor(totalDevices * 0.75),
35533
+ // Connectivity status (RFC-0109) - estimated
35534
+ waiting: Math.floor(totalDevices * 0.01),
35535
+ weakConnection: Math.floor(totalDevices * 0.02),
35536
+ offline: Math.floor(totalDevices * 0.03),
35537
+ // Consumption status - estimated
35538
+ normal: Math.floor(totalDevices * 0.72),
35409
35539
  alert: Math.floor(totalDevices * 0.06),
35410
35540
  failure: Math.floor(totalDevices * 0.02),
35411
35541
  standby: Math.floor(totalDevices * 0.02),
35412
- offline: Math.floor(totalDevices * 0.03),
35413
35542
  noConsumption: Math.floor(totalDevices * 0.12)
35414
35543
  };
35415
- const statusSum = Object.values(summary.byStatus).reduce((a, b) => {
35416
- return typeof b === "number" ? a + b : a;
35417
- }, 0);
35544
+ const statusSum = (summary.byStatus.waiting || 0) + (summary.byStatus.weakConnection || 0) + (summary.byStatus.offline || 0) + (summary.byStatus.normal || 0) + (summary.byStatus.alert || 0) + (summary.byStatus.failure || 0) + (summary.byStatus.standby || 0);
35418
35545
  if (statusSum !== totalDevices && totalDevices > 0) {
35419
35546
  summary.byStatus.normal += totalDevices - statusSum;
35420
35547
  }
@@ -35424,23 +35551,36 @@ var EnergySummaryTooltip = {
35424
35551
  return summary;
35425
35552
  },
35426
35553
  /**
35427
- * RFC-0105: Aggregate device status from MyIOOrchestratorData
35428
- * Iterates through all orchestrator items and groups devices by status
35429
- * Returns both counts and device lists
35554
+ * RFC-0109: Aggregate device status from MyIOOrchestratorData
35555
+ * Iterates through all orchestrator items and groups devices by:
35556
+ * 1. Connectivity status (waiting, weakConnection, offline) - independent dimension
35557
+ * 2. Consumption status (normal, alert, failure, standby, noConsumption) - for online devices
35558
+ *
35559
+ * IMPORTANT: A device can appear in multiple lists:
35560
+ * - An offline device can ALSO be in noConsumption
35561
+ * - A weakConnection device can ALSO be in normal/alert/failure/standby
35562
+ * EXCEPTION: waiting devices should NOT appear in noConsumption (not installed yet)
35430
35563
  */
35431
35564
  _aggregateDeviceStatusFromOrchestrator(domain = "energy") {
35432
35565
  const result = {
35566
+ // Connectivity status (RFC-0109)
35567
+ waiting: 0,
35568
+ weakConnection: 0,
35569
+ offline: 0,
35570
+ // Consumption status
35433
35571
  normal: 0,
35434
35572
  alert: 0,
35435
35573
  failure: 0,
35436
35574
  standby: 0,
35437
- offline: 0,
35438
35575
  noConsumption: 0,
35576
+ // Device lists
35577
+ waitingDevices: [],
35578
+ weakConnectionDevices: [],
35579
+ offlineDevices: [],
35439
35580
  normalDevices: [],
35440
35581
  alertDevices: [],
35441
35582
  failureDevices: [],
35442
35583
  standbyDevices: [],
35443
- offlineDevices: [],
35444
35584
  noConsumptionDevices: []
35445
35585
  };
35446
35586
  const win = typeof window !== "undefined" ? window : null;
@@ -35455,16 +35595,11 @@ var EnergySummaryTooltip = {
35455
35595
  return { hasData: false, byStatus: result };
35456
35596
  }
35457
35597
  const NO_CONSUMPTION_THRESHOLD = 0.01;
35458
- const statusMapping = {
35598
+ const consumptionStatusMapping = {
35459
35599
  "power_on": "normal",
35460
35600
  "warning": "alert",
35461
35601
  "failure": "failure",
35462
- "standby": "standby",
35463
- "power_off": "offline",
35464
- "maintenance": "offline",
35465
- "no_info": "offline",
35466
- "not_installed": "offline",
35467
- "offline": "offline"
35602
+ "standby": "standby"
35468
35603
  };
35469
35604
  items.forEach((item) => {
35470
35605
  const deviceInfo = {
@@ -35473,19 +35608,45 @@ var EnergySummaryTooltip = {
35473
35608
  name: item.name || item.entityLabel || ""
35474
35609
  };
35475
35610
  const deviceStatus = item.deviceStatus || "no_info";
35611
+ const connectionStatus = item.connectionStatus || "";
35476
35612
  const value = Number(item.value || item.val || 0);
35477
- const isOnline = !["no_info", "offline", "not_installed", "maintenance", "power_off"].includes(deviceStatus);
35478
- if (isOnline && Math.abs(value) < NO_CONSUMPTION_THRESHOLD) {
35479
- result.noConsumption++;
35480
- result.noConsumptionDevices?.push(deviceInfo);
35613
+ const isWaiting = deviceStatus === "not_installed" || connectionStatus === "waiting";
35614
+ const isWeakConnection = deviceStatus === "weak_connection" || connectionStatus === "bad" || ["bad", "weak", "unstable", "poor", "degraded"].includes(String(connectionStatus).toLowerCase());
35615
+ const isOffline = deviceStatus === "offline" || deviceStatus === "no_info" || deviceStatus === "power_off" || deviceStatus === "maintenance" || connectionStatus === "offline" || connectionStatus === "disconnected";
35616
+ if (isWaiting) {
35617
+ result.waiting++;
35618
+ result.waitingDevices?.push(deviceInfo);
35619
+ return;
35620
+ } else if (isWeakConnection) {
35621
+ result.weakConnection++;
35622
+ result.weakConnectionDevices?.push(deviceInfo);
35623
+ } else if (isOffline) {
35624
+ result.offline++;
35625
+ result.offlineDevices?.push(deviceInfo);
35626
+ if (Math.abs(value) < NO_CONSUMPTION_THRESHOLD || value === null || value === void 0) {
35627
+ result.noConsumption++;
35628
+ result.noConsumptionDevices?.push(deviceInfo);
35629
+ }
35481
35630
  return;
35482
35631
  }
35483
- const mappedStatus = statusMapping[deviceStatus] || "offline";
35484
- result[mappedStatus]++;
35485
- const deviceListKey = `${mappedStatus}Devices`;
35486
- const deviceList = result[deviceListKey];
35487
- if (deviceList) {
35488
- deviceList.push(deviceInfo);
35632
+ const isOnline = !isOffline && !isWaiting;
35633
+ if (isOnline) {
35634
+ if (Math.abs(value) < NO_CONSUMPTION_THRESHOLD) {
35635
+ result.noConsumption++;
35636
+ result.noConsumptionDevices?.push(deviceInfo);
35637
+ }
35638
+ const consumptionCategory = consumptionStatusMapping[deviceStatus];
35639
+ if (consumptionCategory) {
35640
+ result[consumptionCategory]++;
35641
+ const deviceListKey = `${consumptionCategory}Devices`;
35642
+ const deviceList = result[deviceListKey];
35643
+ if (deviceList) {
35644
+ deviceList.push(deviceInfo);
35645
+ }
35646
+ } else {
35647
+ result.normal++;
35648
+ result.normalDevices?.push(deviceInfo);
35649
+ }
35489
35650
  }
35490
35651
  });
35491
35652
  return { hasData: true, byStatus: result };
@@ -48144,6 +48305,7 @@ ${errors.slice(0, 5).join("\n")}` + (errors.length > 5 ? `
48144
48305
  groupByDay,
48145
48306
  handleDeviceType,
48146
48307
  interpolateTemperature,
48308
+ isConnectionStale,
48147
48309
  isDeviceOffline,
48148
48310
  isEnergyDevice,
48149
48311
  isHydrometerDevice,