myio-js-library 0.1.177 → 0.1.179

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
@@ -5620,6 +5620,16 @@ function formatValueByDomain(value, domain) {
5620
5620
  }
5621
5621
  return formatEnergy(value);
5622
5622
  }
5623
+ function formatRelativeTime2(timestamp) {
5624
+ if (!timestamp || isNaN(timestamp)) return "\u2014";
5625
+ const date = new Date(timestamp);
5626
+ const hours = String(date.getHours()).padStart(2, "0");
5627
+ const minutes = String(date.getMinutes()).padStart(2, "0");
5628
+ const day = String(date.getDate()).padStart(2, "0");
5629
+ const month = String(date.getMonth() + 1).padStart(2, "0");
5630
+ const year = date.getFullYear();
5631
+ return `${hours}:${minutes} ${day}/${month}/${year}`;
5632
+ }
5623
5633
  function calculateConsumptionPercentage(target, consumption) {
5624
5634
  const numericTarget = Number(target);
5625
5635
  const numericConsumption = Number(consumption);
@@ -5872,6 +5882,8 @@ function buildDOM(state) {
5872
5882
  powerLabel.className = "label";
5873
5883
  if (entityObject.domain === "water") {
5874
5884
  powerLabel.textContent = "Leitura";
5885
+ } else if (entityObject.domain === "temperature") {
5886
+ powerLabel.textContent = "\xDAlt. Telemetria";
5875
5887
  } else {
5876
5888
  powerLabel.textContent = i18n.instantaneous_power || "Pot\xEAncia";
5877
5889
  }
@@ -6125,14 +6137,24 @@ function paint(root, state) {
6125
6137
  effContainer.style.display = "none";
6126
6138
  }
6127
6139
  const opTimeVal = root.querySelector(".myio-ho-card__footer .metric:nth-child(1) .val");
6140
+ const opTimeLabel = root.querySelector(".myio-ho-card__footer .metric:nth-child(1) .label");
6128
6141
  if (opTimeVal) {
6129
- opTimeVal.textContent = entityObject.operationHours ?? "-";
6142
+ if (entityObject.domain === "temperature") {
6143
+ if (opTimeLabel) opTimeLabel.textContent = "Temp. Atual";
6144
+ const currentTemp = entityObject.currentTemperature ?? entityObject.temperature ?? entityObject.val ?? null;
6145
+ opTimeVal.textContent = currentTemp !== null ? `${Number(currentTemp).toFixed(1)}\xB0C` : "-";
6146
+ } else {
6147
+ if (opTimeLabel) opTimeLabel.textContent = i18n.operation_time;
6148
+ opTimeVal.textContent = entityObject.operationHours ?? "-";
6149
+ }
6130
6150
  }
6131
6151
  const powerVal = root.querySelector(".myio-ho-card__footer .metric:nth-child(2) .val");
6132
6152
  if (powerVal) {
6133
6153
  if (entityObject.domain === "water") {
6134
6154
  const pulses = entityObject.pulses ?? 0;
6135
6155
  powerVal.textContent = `${pulses} L`;
6156
+ } else if (entityObject.domain === "temperature") {
6157
+ powerVal.textContent = entityObject.lastActivityTime ? formatRelativeTime2(entityObject.lastActivityTime) : "-";
6136
6158
  } else {
6137
6159
  const instantPower = entityObject.instantaneousPower ?? entityObject.consumption_power ?? null;
6138
6160
  const powerFormatted = formatPower(instantPower);
package/dist/index.js CHANGED
@@ -5475,6 +5475,16 @@ function formatValueByDomain(value, domain) {
5475
5475
  }
5476
5476
  return formatEnergy(value);
5477
5477
  }
5478
+ function formatRelativeTime2(timestamp) {
5479
+ if (!timestamp || isNaN(timestamp)) return "\u2014";
5480
+ const date = new Date(timestamp);
5481
+ const hours = String(date.getHours()).padStart(2, "0");
5482
+ const minutes = String(date.getMinutes()).padStart(2, "0");
5483
+ const day = String(date.getDate()).padStart(2, "0");
5484
+ const month = String(date.getMonth() + 1).padStart(2, "0");
5485
+ const year = date.getFullYear();
5486
+ return `${hours}:${minutes} ${day}/${month}/${year}`;
5487
+ }
5478
5488
  function calculateConsumptionPercentage(target, consumption) {
5479
5489
  const numericTarget = Number(target);
5480
5490
  const numericConsumption = Number(consumption);
@@ -5727,6 +5737,8 @@ function buildDOM(state) {
5727
5737
  powerLabel.className = "label";
5728
5738
  if (entityObject.domain === "water") {
5729
5739
  powerLabel.textContent = "Leitura";
5740
+ } else if (entityObject.domain === "temperature") {
5741
+ powerLabel.textContent = "\xDAlt. Telemetria";
5730
5742
  } else {
5731
5743
  powerLabel.textContent = i18n.instantaneous_power || "Pot\xEAncia";
5732
5744
  }
@@ -5980,14 +5992,24 @@ function paint(root, state) {
5980
5992
  effContainer.style.display = "none";
5981
5993
  }
5982
5994
  const opTimeVal = root.querySelector(".myio-ho-card__footer .metric:nth-child(1) .val");
5995
+ const opTimeLabel = root.querySelector(".myio-ho-card__footer .metric:nth-child(1) .label");
5983
5996
  if (opTimeVal) {
5984
- opTimeVal.textContent = entityObject.operationHours ?? "-";
5997
+ if (entityObject.domain === "temperature") {
5998
+ if (opTimeLabel) opTimeLabel.textContent = "Temp. Atual";
5999
+ const currentTemp = entityObject.currentTemperature ?? entityObject.temperature ?? entityObject.val ?? null;
6000
+ opTimeVal.textContent = currentTemp !== null ? `${Number(currentTemp).toFixed(1)}\xB0C` : "-";
6001
+ } else {
6002
+ if (opTimeLabel) opTimeLabel.textContent = i18n.operation_time;
6003
+ opTimeVal.textContent = entityObject.operationHours ?? "-";
6004
+ }
5985
6005
  }
5986
6006
  const powerVal = root.querySelector(".myio-ho-card__footer .metric:nth-child(2) .val");
5987
6007
  if (powerVal) {
5988
6008
  if (entityObject.domain === "water") {
5989
6009
  const pulses = entityObject.pulses ?? 0;
5990
6010
  powerVal.textContent = `${pulses} L`;
6011
+ } else if (entityObject.domain === "temperature") {
6012
+ powerVal.textContent = entityObject.lastActivityTime ? formatRelativeTime2(entityObject.lastActivityTime) : "-";
5991
6013
  } else {
5992
6014
  const instantPower = entityObject.instantaneousPower ?? entityObject.consumption_power ?? null;
5993
6015
  const powerFormatted = formatPower(instantPower);
@@ -5466,6 +5466,16 @@
5466
5466
  }
5467
5467
  return formatEnergy(value);
5468
5468
  }
5469
+ function formatRelativeTime2(timestamp) {
5470
+ if (!timestamp || isNaN(timestamp)) return "\u2014";
5471
+ const date = new Date(timestamp);
5472
+ const hours = String(date.getHours()).padStart(2, "0");
5473
+ const minutes = String(date.getMinutes()).padStart(2, "0");
5474
+ const day = String(date.getDate()).padStart(2, "0");
5475
+ const month = String(date.getMonth() + 1).padStart(2, "0");
5476
+ const year = date.getFullYear();
5477
+ return `${hours}:${minutes} ${day}/${month}/${year}`;
5478
+ }
5469
5479
  function calculateConsumptionPercentage(target, consumption) {
5470
5480
  const numericTarget = Number(target);
5471
5481
  const numericConsumption = Number(consumption);
@@ -5718,6 +5728,8 @@
5718
5728
  powerLabel.className = "label";
5719
5729
  if (entityObject.domain === "water") {
5720
5730
  powerLabel.textContent = "Leitura";
5731
+ } else if (entityObject.domain === "temperature") {
5732
+ powerLabel.textContent = "\xDAlt. Telemetria";
5721
5733
  } else {
5722
5734
  powerLabel.textContent = i18n.instantaneous_power || "Pot\xEAncia";
5723
5735
  }
@@ -5971,14 +5983,24 @@
5971
5983
  effContainer.style.display = "none";
5972
5984
  }
5973
5985
  const opTimeVal = root.querySelector(".myio-ho-card__footer .metric:nth-child(1) .val");
5986
+ const opTimeLabel = root.querySelector(".myio-ho-card__footer .metric:nth-child(1) .label");
5974
5987
  if (opTimeVal) {
5975
- opTimeVal.textContent = entityObject.operationHours ?? "-";
5988
+ if (entityObject.domain === "temperature") {
5989
+ if (opTimeLabel) opTimeLabel.textContent = "Temp. Atual";
5990
+ const currentTemp = entityObject.currentTemperature ?? entityObject.temperature ?? entityObject.val ?? null;
5991
+ opTimeVal.textContent = currentTemp !== null ? `${Number(currentTemp).toFixed(1)}\xB0C` : "-";
5992
+ } else {
5993
+ if (opTimeLabel) opTimeLabel.textContent = i18n.operation_time;
5994
+ opTimeVal.textContent = entityObject.operationHours ?? "-";
5995
+ }
5976
5996
  }
5977
5997
  const powerVal = root.querySelector(".myio-ho-card__footer .metric:nth-child(2) .val");
5978
5998
  if (powerVal) {
5979
5999
  if (entityObject.domain === "water") {
5980
6000
  const pulses = entityObject.pulses ?? 0;
5981
6001
  powerVal.textContent = `${pulses} L`;
6002
+ } else if (entityObject.domain === "temperature") {
6003
+ powerVal.textContent = entityObject.lastActivityTime ? formatRelativeTime2(entityObject.lastActivityTime) : "-";
5982
6004
  } else {
5983
6005
  const instantPower = entityObject.instantaneousPower ?? entityObject.consumption_power ?? null;
5984
6006
  const powerFormatted = formatPower(instantPower);