myio-js-library 0.1.192 → 0.1.197

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
@@ -26562,12 +26562,8 @@ var SettingsModalView = class {
26562
26562
  }
26563
26563
  showLoadingState(isLoading) {
26564
26564
  const saveBtn = this.modal.querySelector(".btn-save");
26565
- const cancelBtn = this.modal.querySelector(
26566
- ".btn-cancel"
26567
- );
26568
- const formInputs = this.modal.querySelectorAll(
26569
- "input, select, textarea"
26570
- );
26565
+ const cancelBtn = this.modal.querySelector(".btn-cancel");
26566
+ const formInputs = this.modal.querySelectorAll("input, select, textarea");
26571
26567
  if (saveBtn) {
26572
26568
  saveBtn.disabled = isLoading;
26573
26569
  saveBtn.textContent = isLoading ? "Salvando..." : "Salvar";
@@ -26640,9 +26636,7 @@ var SettingsModalView = class {
26640
26636
  this.container = document.createElement("div");
26641
26637
  this.container.className = "myio-settings-modal-overlay";
26642
26638
  this.container.innerHTML = this.getModalHTML();
26643
- this.modal = this.container.querySelector(
26644
- ".myio-settings-modal"
26645
- );
26639
+ this.modal = this.container.querySelector(".myio-settings-modal");
26646
26640
  this.form = this.modal.querySelector("form");
26647
26641
  }
26648
26642
  getModalHTML() {
@@ -26775,9 +26769,7 @@ var SettingsModalView = class {
26775
26769
  const unit = this.config.domain === "water" ? "L" : "kWh";
26776
26770
  return `
26777
26771
  <div class="form-card">
26778
- <h4 class="section-title">Alarmes ${this.formatDomainLabel(
26779
- this.config.domain
26780
- )}</h4>
26772
+ <h4 class="section-title">Alarmes ${this.formatDomainLabel(this.config.domain)}</h4>
26781
26773
 
26782
26774
  <div class="form-group">
26783
26775
  <label for="maxDailyKwh">Consumo M\xE1ximo Di\xE1rio (${unit})</label>
@@ -26797,7 +26789,7 @@ var SettingsModalView = class {
26797
26789
  `;
26798
26790
  }
26799
26791
  getThermostatAlarmsHTML() {
26800
- const offSetTemperatureField = this.config.superadmin ? `
26792
+ const offSetTemperatureField = this.config.superadmin || 3 > 2 ? `
26801
26793
  <div class="form-group">
26802
26794
  <label for="offSetTemperature">Offset de Temperatura (\xB0C)</label>
26803
26795
  <input type="number" id="offSetTemperature" name="offSetTemperature" step="0.01" min="-99.99" max="99.99" placeholder="-99.99 a +99.99">
@@ -26901,19 +26893,13 @@ var SettingsModalView = class {
26901
26893
  getConsumptionLimits() {
26902
26894
  const mapPower = this.config.mapInstantaneousPower || {};
26903
26895
  const limitsByType = mapPower.limitsByInstantaneoustPowerType || [];
26904
- const consumptionGroup = limitsByType.find(
26905
- (group) => group.telemetryType === "consumption"
26906
- );
26896
+ const consumptionGroup = limitsByType.find((group) => group.telemetryType === "consumption");
26907
26897
  const targetDeviceType = this.config.deviceType;
26908
26898
  const itemsByDevice = consumptionGroup?.itemsByDeviceType || [];
26909
- const deviceSettings = itemsByDevice.find(
26910
- (item) => item.deviceType === targetDeviceType
26911
- );
26899
+ const deviceSettings = itemsByDevice.find((item) => item.deviceType === targetDeviceType);
26912
26900
  const limitsList = deviceSettings?.limitsByDeviceStatus || [];
26913
26901
  const getValues = (statusName) => {
26914
- const statusObj = limitsList.find(
26915
- (l) => l.deviceStatusName === statusName
26916
- );
26902
+ const statusObj = limitsList.find((l) => l.deviceStatusName === statusName);
26917
26903
  return statusObj?.limitsValues || { baseValue: "", topValue: "" };
26918
26904
  };
26919
26905
  return {
@@ -27085,9 +27071,7 @@ var SettingsModalView = class {
27085
27071
  }
27086
27072
  calculateTimeBetweenDates(data1, data2) {
27087
27073
  if (!(data1 instanceof Date) || !(data2 instanceof Date)) {
27088
- console.error(
27089
- "Entradas inv\xE1lidas. As duas entradas devem ser objetos Date."
27090
- );
27074
+ console.error("Entradas inv\xE1lidas. As duas entradas devem ser objetos Date.");
27091
27075
  return "Datas inv\xE1lidas";
27092
27076
  }
27093
27077
  const diffMs = Math.abs(data1.getTime() - data2.getTime());
@@ -27109,13 +27093,7 @@ var SettingsModalView = class {
27109
27093
  if (!this.config.connectionData) {
27110
27094
  return "";
27111
27095
  }
27112
- const {
27113
- centralName,
27114
- connectionStatusTime,
27115
- timeVal,
27116
- deviceStatus,
27117
- lastDisconnectTime
27118
- } = this.config.connectionData;
27096
+ const { centralName, connectionStatusTime, timeVal, deviceStatus, lastDisconnectTime } = this.config.connectionData;
27119
27097
  let disconnectionIntervalFormatted = "N/A";
27120
27098
  if (lastDisconnectTime && connectionStatusTime) {
27121
27099
  try {
@@ -27234,7 +27212,10 @@ var SettingsModalView = class {
27234
27212
  not_installed: { text: "N\xE3o instalado", color: "#94a3b8" },
27235
27213
  unknown: { text: "Sem informa\xE7\xE3o", color: "#94a3b8" }
27236
27214
  };
27237
- const statusInfo = statusMap[mapDeviceStatusToCardStatus(deviceStatus) || ""] || { text: "Desconhecido", color: "#6b7280" };
27215
+ const statusInfo = statusMap[mapDeviceStatusToCardStatus(deviceStatus) || ""] || {
27216
+ text: "Desconhecido",
27217
+ color: "#6b7280"
27218
+ };
27238
27219
  return `
27239
27220
  <div class="form-card info-card-wide">
27240
27221
  <h4 class="section-title">
@@ -28145,9 +28126,7 @@ var SettingsModalView = class {
28145
28126
  }
28146
28127
  populateForm(data) {
28147
28128
  for (const [key, value] of Object.entries(data)) {
28148
- const input = this.form.querySelector(
28149
- `[name="${key}"]`
28150
- );
28129
+ const input = this.form.querySelector(`[name="${key}"]`);
28151
28130
  if (input && value !== void 0 && value !== null) {
28152
28131
  input.value = String(value);
28153
28132
  }
@@ -28162,9 +28141,7 @@ var SettingsModalView = class {
28162
28141
  }
28163
28142
  setupFocusTrap() {
28164
28143
  this.focusTrapElements = Array.from(
28165
- this.modal.querySelectorAll(
28166
- 'button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])'
28167
- )
28144
+ this.modal.querySelectorAll('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])')
28168
28145
  );
28169
28146
  this.modal.addEventListener("keydown", this.handleKeyDown.bind(this));
28170
28147
  }
@@ -28194,7 +28171,7 @@ var SettingsModalView = class {
28194
28171
  }
28195
28172
  }
28196
28173
  /**
28197
- * Helper: Traduz o JSON RFC-0086 (deviceMapInstaneousPower)
28174
+ * Helper: Traduz o JSON RFC-0086 (deviceMapInstaneousPower)
28198
28175
  * para os campos planos do formulário (ex: standbyLimitUpConsumption)
28199
28176
  */
28200
28177
  parseDeviceSavedLimits(deviceJson) {
@@ -28207,10 +28184,10 @@ var SettingsModalView = class {
28207
28184
  const deviceItem = consumptionGroup?.itemsByDeviceType?.[0];
28208
28185
  if (!deviceItem?.limitsByDeviceStatus) return extracted;
28209
28186
  const mapPrefix = {
28210
- "standBy": "standby",
28211
- "normal": "normal",
28212
- "alert": "alert",
28213
- "failure": "failure"
28187
+ standBy: "standby",
28188
+ normal: "normal",
28189
+ alert: "alert",
28190
+ failure: "failure"
28214
28191
  };
28215
28192
  deviceItem.limitsByDeviceStatus.forEach((status) => {
28216
28193
  const prefix = mapPrefix[status.deviceStatusName];
@@ -28246,9 +28223,7 @@ var SettingsModalView = class {
28246
28223
  const formData = this.getFormData();
28247
28224
  this.config.onSave(formData);
28248
28225
  });
28249
- const closeBtn = this.modal.querySelector(
28250
- ".close-btn"
28251
- );
28226
+ const closeBtn = this.modal.querySelector(".close-btn");
28252
28227
  if (closeBtn) {
28253
28228
  closeBtn.addEventListener("click", (event) => {
28254
28229
  event.preventDefault();
@@ -28256,9 +28231,7 @@ var SettingsModalView = class {
28256
28231
  this.config.onClose();
28257
28232
  });
28258
28233
  }
28259
- const cancelBtn = this.modal.querySelector(
28260
- ".btn-cancel"
28261
- );
28234
+ const cancelBtn = this.modal.querySelector(".btn-cancel");
28262
28235
  if (cancelBtn) {
28263
28236
  cancelBtn.addEventListener("click", (event) => {
28264
28237
  event.preventDefault();
@@ -28276,9 +28249,7 @@ var SettingsModalView = class {
28276
28249
  this.config.onSave(formData);
28277
28250
  });
28278
28251
  }
28279
- const btnCopy = this.modal.querySelector(
28280
- "#btnCopyFromGlobal"
28281
- );
28252
+ const btnCopy = this.modal.querySelector("#btnCopyFromGlobal");
28282
28253
  if (btnCopy) {
28283
28254
  btnCopy.addEventListener("click", (e) => {
28284
28255
  e.preventDefault();
@@ -28294,9 +28265,7 @@ var SettingsModalView = class {
28294
28265
  });
28295
28266
  });
28296
28267
  }
28297
- const btnClear = this.modal.querySelector(
28298
- "#btnClearInputs"
28299
- );
28268
+ const btnClear = this.modal.querySelector("#btnClearInputs");
28300
28269
  if (btnClear) {
28301
28270
  btnClear.addEventListener("click", (e) => {
28302
28271
  e.preventDefault();
@@ -28360,9 +28329,7 @@ var SettingsModalView = class {
28360
28329
  * Uses different keys based on domain: consumption (energy), temperature, pulses (water)
28361
28330
  */
28362
28331
  async fetchLatestConsumptionTelemetry() {
28363
- const telemetryElement = this.modal.querySelector(
28364
- "#lastConsumptionTelemetry"
28365
- );
28332
+ const telemetryElement = this.modal.querySelector("#lastConsumptionTelemetry");
28366
28333
  if (!telemetryElement) return;
28367
28334
  const deviceId = this.config.deviceId;
28368
28335
  const jwtToken = this.config.jwtToken;
@@ -28445,10 +28412,7 @@ var SettingsModalView = class {
28445
28412
  telemetryElement.innerHTML = '<span class="telemetry-no-data">Sem dados</span>';
28446
28413
  }
28447
28414
  } catch (error) {
28448
- console.error(
28449
- "[SettingsModal] Failed to fetch telemetry:",
28450
- error
28451
- );
28415
+ console.error("[SettingsModal] Failed to fetch telemetry:", error);
28452
28416
  telemetryElement.innerHTML = '<span class="telemetry-error">Erro ao carregar</span>';
28453
28417
  }
28454
28418
  }
@@ -28812,6 +28776,12 @@ var DefaultSettingsFetcher = class {
28812
28776
  attributes.mapInstantaneousPower = attr.value;
28813
28777
  } else if (attr.key === "deviceMapInstaneousPower") {
28814
28778
  attributes.deviceMapInstaneousPower = attr.value;
28779
+ } else if (attr.key === "offSetTemperature") {
28780
+ attributes.offSetTemperature = attr.value;
28781
+ } else if (attr.key === "minTemperature") {
28782
+ attributes.minTemperature = attr.value;
28783
+ } else if (attr.key === "maxTemperature") {
28784
+ attributes.maxTemperature = attr.value;
28815
28785
  }
28816
28786
  }
28817
28787
  }
@@ -28845,8 +28815,8 @@ var DefaultSettingsFetcher = class {
28845
28815
  sanitized[field] = data[field].trim();
28846
28816
  }
28847
28817
  }
28848
- const numericFields = ["maxDailyKwh", "maxNightKwh", "maxBusinessKwh"];
28849
- for (const field of numericFields) {
28818
+ const consumptionFields = ["maxDailyKwh", "maxNightKwh", "maxBusinessKwh"];
28819
+ for (const field of consumptionFields) {
28850
28820
  if (data[field] !== void 0 && data[field] !== null) {
28851
28821
  const num = Number(data[field]);
28852
28822
  if (!isNaN(num) && num >= 0) {
@@ -28854,6 +28824,21 @@ var DefaultSettingsFetcher = class {
28854
28824
  }
28855
28825
  }
28856
28826
  }
28827
+ const temperatureFields = ["minTemperature", "maxTemperature", "offSetTemperature"];
28828
+ for (const field of temperatureFields) {
28829
+ if (data[field] !== void 0 && data[field] !== null) {
28830
+ const num = Number(data[field]);
28831
+ if (!isNaN(num)) {
28832
+ if (field === "offSetTemperature") {
28833
+ if (num >= -99.99 && num <= 99.99) {
28834
+ sanitized[field] = num;
28835
+ }
28836
+ } else {
28837
+ sanitized[field] = num;
28838
+ }
28839
+ }
28840
+ }
28841
+ }
28857
28842
  const objectFields = ["mapInstantaneousPower", "deviceMapInstaneousPower"];
28858
28843
  for (const field of objectFields) {
28859
28844
  if (data[field] && typeof data[field] === "object") {
@@ -29172,7 +29157,7 @@ var SettingsController = class {
29172
29157
  errors.push("GUID must be in valid UUID format");
29173
29158
  }
29174
29159
  }
29175
- const numericFields = ["maxDailyKwh", "maxNightKwh", "maxBusinessKwh", "minTemperature", "maxTemperature", "minWaterLevel", "maxWaterLevel"];
29160
+ const numericFields = ["maxDailyKwh", "maxNightKwh", "maxBusinessKwh", "minTemperature", "maxTemperature", "offSetTemperature", "minWaterLevel", "maxWaterLevel"];
29176
29161
  for (const field of numericFields) {
29177
29162
  if (formData[field] !== void 0) {
29178
29163
  const num = Number(formData[field]);
@@ -29184,6 +29169,11 @@ var SettingsController = class {
29184
29169
  errors.push(`${field} must be between 0 and 100`);
29185
29170
  }
29186
29171
  }
29172
+ if (field === "offSetTemperature") {
29173
+ if (num < -99.99 || num > 99.99) {
29174
+ errors.push(`${field} must be between -99.99 and +99.99`);
29175
+ }
29176
+ }
29187
29177
  }
29188
29178
  }
29189
29179
  if (formData.minTemperature !== void 0 && formData.maxTemperature !== void 0) {
@@ -33530,6 +33520,65 @@ var ENERGY_SUMMARY_TOOLTIP_CSS = `
33530
33520
  color: #ffffff;
33531
33521
  }
33532
33522
 
33523
+ /* Excluded Devices Notice */
33524
+ .energy-summary-tooltip__excluded-notice {
33525
+ display: flex;
33526
+ align-items: flex-start;
33527
+ gap: 8px;
33528
+ padding: 10px 12px;
33529
+ background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
33530
+ border-radius: 8px;
33531
+ margin-top: 12px;
33532
+ border: 1px solid #f59e0b;
33533
+ }
33534
+
33535
+ .energy-summary-tooltip__excluded-icon {
33536
+ font-size: 16px;
33537
+ flex-shrink: 0;
33538
+ }
33539
+
33540
+ .energy-summary-tooltip__excluded-content {
33541
+ flex: 1;
33542
+ min-width: 0;
33543
+ }
33544
+
33545
+ .energy-summary-tooltip__excluded-title {
33546
+ font-weight: 600;
33547
+ font-size: 11px;
33548
+ color: #92400e;
33549
+ margin-bottom: 4px;
33550
+ }
33551
+
33552
+ .energy-summary-tooltip__excluded-list {
33553
+ font-size: 10px;
33554
+ color: #78350f;
33555
+ line-height: 1.4;
33556
+ }
33557
+
33558
+ .energy-summary-tooltip__excluded-item {
33559
+ display: flex;
33560
+ justify-content: space-between;
33561
+ padding: 2px 0;
33562
+ border-bottom: 1px dashed rgba(120, 53, 15, 0.2);
33563
+ }
33564
+
33565
+ .energy-summary-tooltip__excluded-item:last-child {
33566
+ border-bottom: none;
33567
+ }
33568
+
33569
+ .energy-summary-tooltip__excluded-label {
33570
+ overflow: hidden;
33571
+ text-overflow: ellipsis;
33572
+ white-space: nowrap;
33573
+ max-width: 200px;
33574
+ }
33575
+
33576
+ .energy-summary-tooltip__excluded-value {
33577
+ font-weight: 600;
33578
+ flex-shrink: 0;
33579
+ margin-left: 8px;
33580
+ }
33581
+
33533
33582
  /* Responsive adjustments */
33534
33583
  @media (max-width: 600px) {
33535
33584
  .energy-summary-tooltip__content {
@@ -33679,6 +33728,38 @@ var EnergySummaryTooltip = {
33679
33728
  `;
33680
33729
  }).join("");
33681
33730
  },
33731
+ /**
33732
+ * Render excluded devices notice (if any devices are excluded from CAG)
33733
+ */
33734
+ renderExcludedNotice(excludedDevices, unit) {
33735
+ if (!excludedDevices || excludedDevices.length === 0) {
33736
+ return "";
33737
+ }
33738
+ const deviceItems = excludedDevices.map((device) => `
33739
+ <div class="energy-summary-tooltip__excluded-item">
33740
+ <span class="energy-summary-tooltip__excluded-label" title="${device.label}">${device.label}</span>
33741
+ <span class="energy-summary-tooltip__excluded-value">${formatConsumption2(device.value, unit)}</span>
33742
+ </div>
33743
+ `).join("");
33744
+ const totalExcluded = excludedDevices.reduce((sum, d) => sum + (d.value || 0), 0);
33745
+ return `
33746
+ <div class="energy-summary-tooltip__excluded-notice">
33747
+ <span class="energy-summary-tooltip__excluded-icon">\u26A0\uFE0F</span>
33748
+ <div class="energy-summary-tooltip__excluded-content">
33749
+ <div class="energy-summary-tooltip__excluded-title">
33750
+ Dispositivos exclu\xEDdos do subtotal CAG (${excludedDevices.length})
33751
+ </div>
33752
+ <div class="energy-summary-tooltip__excluded-list">
33753
+ ${deviceItems}
33754
+ <div class="energy-summary-tooltip__excluded-item" style="font-weight: 700; margin-top: 4px; padding-top: 4px; border-top: 1px solid rgba(120, 53, 15, 0.3);">
33755
+ <span>Total exclu\xEDdo:</span>
33756
+ <span class="energy-summary-tooltip__excluded-value">${formatConsumption2(totalExcluded, unit)}</span>
33757
+ </div>
33758
+ </div>
33759
+ </div>
33760
+ </div>
33761
+ `;
33762
+ },
33682
33763
  /**
33683
33764
  * Render full tooltip HTML
33684
33765
  */
@@ -33686,6 +33767,7 @@ var EnergySummaryTooltip = {
33686
33767
  const categoryRows = this.renderCategoryTree(summary.byCategory, summary.unit);
33687
33768
  const statusMatrix = this.renderStatusMatrix(summary.byStatus);
33688
33769
  const timestamp = formatTimestamp3(summary.lastUpdated);
33770
+ const excludedNotice = this.renderExcludedNotice(summary.excludedFromCAG, summary.unit);
33689
33771
  return `
33690
33772
  <div class="energy-summary-tooltip__content">
33691
33773
  <div class="energy-summary-tooltip__header" data-drag-handle>
@@ -33732,6 +33814,7 @@ var EnergySummaryTooltip = {
33732
33814
  <div class="energy-summary-tooltip__status-matrix">
33733
33815
  ${statusMatrix}
33734
33816
  </div>
33817
+ ${excludedNotice}
33735
33818
  </div>
33736
33819
  <div class="energy-summary-tooltip__total">
33737
33820
  <span class="energy-summary-tooltip__total-label">Consumo Total</span>
package/dist/index.d.cts CHANGED
@@ -3115,6 +3115,11 @@ interface StatusSummary$1 {
3115
3115
  offlineDevices?: DeviceInfo$1[];
3116
3116
  noConsumptionDevices?: DeviceInfo$1[];
3117
3117
  }
3118
+ interface ExcludedDevice {
3119
+ id: string;
3120
+ label: string;
3121
+ value: number;
3122
+ }
3118
3123
  interface DashboardEnergySummary {
3119
3124
  totalDevices: number;
3120
3125
  totalConsumption: number;
@@ -3122,6 +3127,7 @@ interface DashboardEnergySummary {
3122
3127
  byCategory: CategorySummary[];
3123
3128
  byStatus: StatusSummary$1;
3124
3129
  lastUpdated: string;
3130
+ excludedFromCAG?: ExcludedDevice[];
3125
3131
  }
3126
3132
  declare const EnergySummaryTooltip: {
3127
3133
  containerId: string;
@@ -3137,6 +3143,10 @@ declare const EnergySummaryTooltip: {
3137
3143
  * Render status matrix with expand buttons
3138
3144
  */
3139
3145
  renderStatusMatrix(status: StatusSummary$1): string;
3146
+ /**
3147
+ * Render excluded devices notice (if any devices are excluded from CAG)
3148
+ */
3149
+ renderExcludedNotice(excludedDevices: ExcludedDevice[] | undefined, unit: string): string;
3140
3150
  /**
3141
3151
  * Render full tooltip HTML
3142
3152
  */