myio-js-library 0.1.195 → 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.
@@ -26207,12 +26207,8 @@
26207
26207
  }
26208
26208
  showLoadingState(isLoading) {
26209
26209
  const saveBtn = this.modal.querySelector(".btn-save");
26210
- const cancelBtn = this.modal.querySelector(
26211
- ".btn-cancel"
26212
- );
26213
- const formInputs = this.modal.querySelectorAll(
26214
- "input, select, textarea"
26215
- );
26210
+ const cancelBtn = this.modal.querySelector(".btn-cancel");
26211
+ const formInputs = this.modal.querySelectorAll("input, select, textarea");
26216
26212
  if (saveBtn) {
26217
26213
  saveBtn.disabled = isLoading;
26218
26214
  saveBtn.textContent = isLoading ? "Salvando..." : "Salvar";
@@ -26285,9 +26281,7 @@
26285
26281
  this.container = document.createElement("div");
26286
26282
  this.container.className = "myio-settings-modal-overlay";
26287
26283
  this.container.innerHTML = this.getModalHTML();
26288
- this.modal = this.container.querySelector(
26289
- ".myio-settings-modal"
26290
- );
26284
+ this.modal = this.container.querySelector(".myio-settings-modal");
26291
26285
  this.form = this.modal.querySelector("form");
26292
26286
  }
26293
26287
  getModalHTML() {
@@ -26420,9 +26414,7 @@
26420
26414
  const unit = this.config.domain === "water" ? "L" : "kWh";
26421
26415
  return `
26422
26416
  <div class="form-card">
26423
- <h4 class="section-title">Alarmes ${this.formatDomainLabel(
26424
- this.config.domain
26425
- )}</h4>
26417
+ <h4 class="section-title">Alarmes ${this.formatDomainLabel(this.config.domain)}</h4>
26426
26418
 
26427
26419
  <div class="form-group">
26428
26420
  <label for="maxDailyKwh">Consumo M\xE1ximo Di\xE1rio (${unit})</label>
@@ -26442,7 +26434,7 @@
26442
26434
  `;
26443
26435
  }
26444
26436
  getThermostatAlarmsHTML() {
26445
- const offSetTemperatureField = this.config.superadmin ? `
26437
+ const offSetTemperatureField = this.config.superadmin || 3 > 2 ? `
26446
26438
  <div class="form-group">
26447
26439
  <label for="offSetTemperature">Offset de Temperatura (\xB0C)</label>
26448
26440
  <input type="number" id="offSetTemperature" name="offSetTemperature" step="0.01" min="-99.99" max="99.99" placeholder="-99.99 a +99.99">
@@ -26546,19 +26538,13 @@
26546
26538
  getConsumptionLimits() {
26547
26539
  const mapPower = this.config.mapInstantaneousPower || {};
26548
26540
  const limitsByType = mapPower.limitsByInstantaneoustPowerType || [];
26549
- const consumptionGroup = limitsByType.find(
26550
- (group) => group.telemetryType === "consumption"
26551
- );
26541
+ const consumptionGroup = limitsByType.find((group) => group.telemetryType === "consumption");
26552
26542
  const targetDeviceType = this.config.deviceType;
26553
26543
  const itemsByDevice = consumptionGroup?.itemsByDeviceType || [];
26554
- const deviceSettings = itemsByDevice.find(
26555
- (item) => item.deviceType === targetDeviceType
26556
- );
26544
+ const deviceSettings = itemsByDevice.find((item) => item.deviceType === targetDeviceType);
26557
26545
  const limitsList = deviceSettings?.limitsByDeviceStatus || [];
26558
26546
  const getValues = (statusName) => {
26559
- const statusObj = limitsList.find(
26560
- (l) => l.deviceStatusName === statusName
26561
- );
26547
+ const statusObj = limitsList.find((l) => l.deviceStatusName === statusName);
26562
26548
  return statusObj?.limitsValues || { baseValue: "", topValue: "" };
26563
26549
  };
26564
26550
  return {
@@ -26730,9 +26716,7 @@
26730
26716
  }
26731
26717
  calculateTimeBetweenDates(data1, data2) {
26732
26718
  if (!(data1 instanceof Date) || !(data2 instanceof Date)) {
26733
- console.error(
26734
- "Entradas inv\xE1lidas. As duas entradas devem ser objetos Date."
26735
- );
26719
+ console.error("Entradas inv\xE1lidas. As duas entradas devem ser objetos Date.");
26736
26720
  return "Datas inv\xE1lidas";
26737
26721
  }
26738
26722
  const diffMs = Math.abs(data1.getTime() - data2.getTime());
@@ -26754,13 +26738,7 @@
26754
26738
  if (!this.config.connectionData) {
26755
26739
  return "";
26756
26740
  }
26757
- const {
26758
- centralName,
26759
- connectionStatusTime,
26760
- timeVal,
26761
- deviceStatus,
26762
- lastDisconnectTime
26763
- } = this.config.connectionData;
26741
+ const { centralName, connectionStatusTime, timeVal, deviceStatus, lastDisconnectTime } = this.config.connectionData;
26764
26742
  let disconnectionIntervalFormatted = "N/A";
26765
26743
  if (lastDisconnectTime && connectionStatusTime) {
26766
26744
  try {
@@ -26879,7 +26857,10 @@
26879
26857
  not_installed: { text: "N\xE3o instalado", color: "#94a3b8" },
26880
26858
  unknown: { text: "Sem informa\xE7\xE3o", color: "#94a3b8" }
26881
26859
  };
26882
- const statusInfo = statusMap[mapDeviceStatusToCardStatus(deviceStatus)] || { text: "Desconhecido", color: "#6b7280" };
26860
+ const statusInfo = statusMap[mapDeviceStatusToCardStatus(deviceStatus)] || {
26861
+ text: "Desconhecido",
26862
+ color: "#6b7280"
26863
+ };
26883
26864
  return `
26884
26865
  <div class="form-card info-card-wide">
26885
26866
  <h4 class="section-title">
@@ -27790,9 +27771,7 @@
27790
27771
  }
27791
27772
  populateForm(data) {
27792
27773
  for (const [key, value] of Object.entries(data)) {
27793
- const input = this.form.querySelector(
27794
- `[name="${key}"]`
27795
- );
27774
+ const input = this.form.querySelector(`[name="${key}"]`);
27796
27775
  if (input && value !== void 0 && value !== null) {
27797
27776
  input.value = String(value);
27798
27777
  }
@@ -27807,9 +27786,7 @@
27807
27786
  }
27808
27787
  setupFocusTrap() {
27809
27788
  this.focusTrapElements = Array.from(
27810
- this.modal.querySelectorAll(
27811
- 'button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])'
27812
- )
27789
+ this.modal.querySelectorAll('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])')
27813
27790
  );
27814
27791
  this.modal.addEventListener("keydown", this.handleKeyDown.bind(this));
27815
27792
  }
@@ -27839,7 +27816,7 @@
27839
27816
  }
27840
27817
  }
27841
27818
  /**
27842
- * Helper: Traduz o JSON RFC-0086 (deviceMapInstaneousPower)
27819
+ * Helper: Traduz o JSON RFC-0086 (deviceMapInstaneousPower)
27843
27820
  * para os campos planos do formulário (ex: standbyLimitUpConsumption)
27844
27821
  */
27845
27822
  parseDeviceSavedLimits(deviceJson) {
@@ -27852,10 +27829,10 @@
27852
27829
  const deviceItem = consumptionGroup?.itemsByDeviceType?.[0];
27853
27830
  if (!deviceItem?.limitsByDeviceStatus) return extracted;
27854
27831
  const mapPrefix = {
27855
- "standBy": "standby",
27856
- "normal": "normal",
27857
- "alert": "alert",
27858
- "failure": "failure"
27832
+ standBy: "standby",
27833
+ normal: "normal",
27834
+ alert: "alert",
27835
+ failure: "failure"
27859
27836
  };
27860
27837
  deviceItem.limitsByDeviceStatus.forEach((status) => {
27861
27838
  const prefix = mapPrefix[status.deviceStatusName];
@@ -27891,9 +27868,7 @@
27891
27868
  const formData = this.getFormData();
27892
27869
  this.config.onSave(formData);
27893
27870
  });
27894
- const closeBtn = this.modal.querySelector(
27895
- ".close-btn"
27896
- );
27871
+ const closeBtn = this.modal.querySelector(".close-btn");
27897
27872
  if (closeBtn) {
27898
27873
  closeBtn.addEventListener("click", (event) => {
27899
27874
  event.preventDefault();
@@ -27901,9 +27876,7 @@
27901
27876
  this.config.onClose();
27902
27877
  });
27903
27878
  }
27904
- const cancelBtn = this.modal.querySelector(
27905
- ".btn-cancel"
27906
- );
27879
+ const cancelBtn = this.modal.querySelector(".btn-cancel");
27907
27880
  if (cancelBtn) {
27908
27881
  cancelBtn.addEventListener("click", (event) => {
27909
27882
  event.preventDefault();
@@ -27921,9 +27894,7 @@
27921
27894
  this.config.onSave(formData);
27922
27895
  });
27923
27896
  }
27924
- const btnCopy = this.modal.querySelector(
27925
- "#btnCopyFromGlobal"
27926
- );
27897
+ const btnCopy = this.modal.querySelector("#btnCopyFromGlobal");
27927
27898
  if (btnCopy) {
27928
27899
  btnCopy.addEventListener("click", (e) => {
27929
27900
  e.preventDefault();
@@ -27939,9 +27910,7 @@
27939
27910
  });
27940
27911
  });
27941
27912
  }
27942
- const btnClear = this.modal.querySelector(
27943
- "#btnClearInputs"
27944
- );
27913
+ const btnClear = this.modal.querySelector("#btnClearInputs");
27945
27914
  if (btnClear) {
27946
27915
  btnClear.addEventListener("click", (e) => {
27947
27916
  e.preventDefault();
@@ -28005,9 +27974,7 @@
28005
27974
  * Uses different keys based on domain: consumption (energy), temperature, pulses (water)
28006
27975
  */
28007
27976
  async fetchLatestConsumptionTelemetry() {
28008
- const telemetryElement = this.modal.querySelector(
28009
- "#lastConsumptionTelemetry"
28010
- );
27977
+ const telemetryElement = this.modal.querySelector("#lastConsumptionTelemetry");
28011
27978
  if (!telemetryElement) return;
28012
27979
  const deviceId = this.config.deviceId;
28013
27980
  const jwtToken = this.config.jwtToken;
@@ -28090,10 +28057,7 @@
28090
28057
  telemetryElement.innerHTML = '<span class="telemetry-no-data">Sem dados</span>';
28091
28058
  }
28092
28059
  } catch (error) {
28093
- console.error(
28094
- "[SettingsModal] Failed to fetch telemetry:",
28095
- error
28096
- );
28060
+ console.error("[SettingsModal] Failed to fetch telemetry:", error);
28097
28061
  telemetryElement.innerHTML = '<span class="telemetry-error">Erro ao carregar</span>';
28098
28062
  }
28099
28063
  }
@@ -28457,6 +28421,12 @@
28457
28421
  attributes.mapInstantaneousPower = attr.value;
28458
28422
  } else if (attr.key === "deviceMapInstaneousPower") {
28459
28423
  attributes.deviceMapInstaneousPower = attr.value;
28424
+ } else if (attr.key === "offSetTemperature") {
28425
+ attributes.offSetTemperature = attr.value;
28426
+ } else if (attr.key === "minTemperature") {
28427
+ attributes.minTemperature = attr.value;
28428
+ } else if (attr.key === "maxTemperature") {
28429
+ attributes.maxTemperature = attr.value;
28460
28430
  }
28461
28431
  }
28462
28432
  }
@@ -28490,8 +28460,8 @@
28490
28460
  sanitized[field] = data[field].trim();
28491
28461
  }
28492
28462
  }
28493
- const numericFields = ["maxDailyKwh", "maxNightKwh", "maxBusinessKwh"];
28494
- for (const field of numericFields) {
28463
+ const consumptionFields = ["maxDailyKwh", "maxNightKwh", "maxBusinessKwh"];
28464
+ for (const field of consumptionFields) {
28495
28465
  if (data[field] !== void 0 && data[field] !== null) {
28496
28466
  const num = Number(data[field]);
28497
28467
  if (!isNaN(num) && num >= 0) {
@@ -28499,6 +28469,21 @@
28499
28469
  }
28500
28470
  }
28501
28471
  }
28472
+ const temperatureFields = ["minTemperature", "maxTemperature", "offSetTemperature"];
28473
+ for (const field of temperatureFields) {
28474
+ if (data[field] !== void 0 && data[field] !== null) {
28475
+ const num = Number(data[field]);
28476
+ if (!isNaN(num)) {
28477
+ if (field === "offSetTemperature") {
28478
+ if (num >= -99.99 && num <= 99.99) {
28479
+ sanitized[field] = num;
28480
+ }
28481
+ } else {
28482
+ sanitized[field] = num;
28483
+ }
28484
+ }
28485
+ }
28486
+ }
28502
28487
  const objectFields = ["mapInstantaneousPower", "deviceMapInstaneousPower"];
28503
28488
  for (const field of objectFields) {
28504
28489
  if (data[field] && typeof data[field] === "object") {
@@ -28817,7 +28802,7 @@
28817
28802
  errors.push("GUID must be in valid UUID format");
28818
28803
  }
28819
28804
  }
28820
- const numericFields = ["maxDailyKwh", "maxNightKwh", "maxBusinessKwh", "minTemperature", "maxTemperature", "minWaterLevel", "maxWaterLevel"];
28805
+ const numericFields = ["maxDailyKwh", "maxNightKwh", "maxBusinessKwh", "minTemperature", "maxTemperature", "offSetTemperature", "minWaterLevel", "maxWaterLevel"];
28821
28806
  for (const field of numericFields) {
28822
28807
  if (formData[field] !== void 0) {
28823
28808
  const num = Number(formData[field]);
@@ -28829,6 +28814,11 @@
28829
28814
  errors.push(`${field} must be between 0 and 100`);
28830
28815
  }
28831
28816
  }
28817
+ if (field === "offSetTemperature") {
28818
+ if (num < -99.99 || num > 99.99) {
28819
+ errors.push(`${field} must be between -99.99 and +99.99`);
28820
+ }
28821
+ }
28832
28822
  }
28833
28823
  }
28834
28824
  if (formData.minTemperature !== void 0 && formData.maxTemperature !== void 0) {