myio-js-library 0.1.150 → 0.1.152
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 +21 -38
- package/dist/index.js +21 -38
- package/dist/myio-js-library.umd.js +21 -38
- package/dist/myio-js-library.umd.min.js +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -4818,45 +4818,25 @@ function normalizeParams(params) {
|
|
|
4818
4818
|
function getIconSvg(deviceType) {
|
|
4819
4819
|
return ICON_MAP[deviceType] || ICON_MAP.DEFAULT;
|
|
4820
4820
|
}
|
|
4821
|
+
function formatPower(valueInWatts) {
|
|
4822
|
+
if (valueInWatts === null || valueInWatts === void 0 || isNaN(valueInWatts)) {
|
|
4823
|
+
return { num: "-", unit: "" };
|
|
4824
|
+
}
|
|
4825
|
+
const val = Number(valueInWatts);
|
|
4826
|
+
if (val >= 1e3) {
|
|
4827
|
+
const kw = Math.ceil(val / 1e3 * 100) / 100;
|
|
4828
|
+
return { num: kw.toFixed(2), unit: "kW" };
|
|
4829
|
+
} else {
|
|
4830
|
+
const w = Math.ceil(val);
|
|
4831
|
+
return { num: w.toString(), unit: "W" };
|
|
4832
|
+
}
|
|
4833
|
+
}
|
|
4821
4834
|
function formatValueByDomain(value, domain) {
|
|
4822
4835
|
if (domain === "water") {
|
|
4823
4836
|
return formatWaterVolumeM3(value);
|
|
4824
4837
|
}
|
|
4825
4838
|
return formatEnergy(value);
|
|
4826
4839
|
}
|
|
4827
|
-
function formatUpdateDate(timeVal) {
|
|
4828
|
-
let telemetryTimeFormatted = "N/A";
|
|
4829
|
-
let timeSinceLastTelemetry = "";
|
|
4830
|
-
if (timeVal) {
|
|
4831
|
-
try {
|
|
4832
|
-
const telemetryDate = new Date(timeVal);
|
|
4833
|
-
telemetryTimeFormatted = telemetryDate.toLocaleString("pt-BR", {
|
|
4834
|
-
day: "2-digit",
|
|
4835
|
-
month: "2-digit",
|
|
4836
|
-
year: "numeric",
|
|
4837
|
-
hour: "2-digit",
|
|
4838
|
-
minute: "2-digit"
|
|
4839
|
-
});
|
|
4840
|
-
const now = /* @__PURE__ */ new Date();
|
|
4841
|
-
const diffMs = now.getTime() - telemetryDate.getTime();
|
|
4842
|
-
const diffMinutes = Math.floor(diffMs / (1e3 * 60));
|
|
4843
|
-
const diffHours = Math.floor(diffMinutes / 60);
|
|
4844
|
-
const diffDays = Math.floor(diffHours / 24);
|
|
4845
|
-
if (diffDays > 0) {
|
|
4846
|
-
timeSinceLastTelemetry = `(${diffDays}d atr\xE1s)`;
|
|
4847
|
-
} else if (diffHours > 0) {
|
|
4848
|
-
timeSinceLastTelemetry = `(${diffHours}h atr\xE1s)`;
|
|
4849
|
-
} else if (diffMinutes > 0) {
|
|
4850
|
-
timeSinceLastTelemetry = `(${diffMinutes}min atr\xE1s)`;
|
|
4851
|
-
} else {
|
|
4852
|
-
timeSinceLastTelemetry = "(agora)";
|
|
4853
|
-
}
|
|
4854
|
-
return timeSinceLastTelemetry;
|
|
4855
|
-
} catch (e) {
|
|
4856
|
-
telemetryTimeFormatted = "Formato inv\xE1lido";
|
|
4857
|
-
}
|
|
4858
|
-
}
|
|
4859
|
-
}
|
|
4860
4840
|
function calculateConsumptionPercentage(target, consumption) {
|
|
4861
4841
|
const numericTarget = Number(target);
|
|
4862
4842
|
const numericConsumption = Number(consumption);
|
|
@@ -5098,12 +5078,15 @@ function paint(root, state) {
|
|
|
5098
5078
|
effContainer.style.display = "none";
|
|
5099
5079
|
}
|
|
5100
5080
|
const opTimeVal = root.querySelector(".myio-ho-card__footer .metric:nth-child(1) .val");
|
|
5101
|
-
opTimeVal
|
|
5081
|
+
if (opTimeVal) {
|
|
5082
|
+
opTimeVal.textContent = entityObject.operationHours ?? "-";
|
|
5083
|
+
}
|
|
5102
5084
|
const powerVal = root.querySelector(".myio-ho-card__footer .metric:nth-child(2) .val");
|
|
5103
|
-
|
|
5104
|
-
|
|
5105
|
-
|
|
5106
|
-
|
|
5085
|
+
if (powerVal) {
|
|
5086
|
+
const instantPower = entityObject.instantaneousPower ?? entityObject.consumption_power ?? null;
|
|
5087
|
+
const powerFormatted = formatPower(instantPower);
|
|
5088
|
+
powerVal.textContent = instantPower !== null ? `${powerFormatted.num} ${powerFormatted.unit}` : "-";
|
|
5089
|
+
}
|
|
5107
5090
|
}
|
|
5108
5091
|
function bindEvents(root, state, callbacks) {
|
|
5109
5092
|
const { entityObject } = state;
|
package/dist/index.js
CHANGED
|
@@ -4710,45 +4710,25 @@ function normalizeParams(params) {
|
|
|
4710
4710
|
function getIconSvg(deviceType) {
|
|
4711
4711
|
return ICON_MAP[deviceType] || ICON_MAP.DEFAULT;
|
|
4712
4712
|
}
|
|
4713
|
+
function formatPower(valueInWatts) {
|
|
4714
|
+
if (valueInWatts === null || valueInWatts === void 0 || isNaN(valueInWatts)) {
|
|
4715
|
+
return { num: "-", unit: "" };
|
|
4716
|
+
}
|
|
4717
|
+
const val = Number(valueInWatts);
|
|
4718
|
+
if (val >= 1e3) {
|
|
4719
|
+
const kw = Math.ceil(val / 1e3 * 100) / 100;
|
|
4720
|
+
return { num: kw.toFixed(2), unit: "kW" };
|
|
4721
|
+
} else {
|
|
4722
|
+
const w = Math.ceil(val);
|
|
4723
|
+
return { num: w.toString(), unit: "W" };
|
|
4724
|
+
}
|
|
4725
|
+
}
|
|
4713
4726
|
function formatValueByDomain(value, domain) {
|
|
4714
4727
|
if (domain === "water") {
|
|
4715
4728
|
return formatWaterVolumeM3(value);
|
|
4716
4729
|
}
|
|
4717
4730
|
return formatEnergy(value);
|
|
4718
4731
|
}
|
|
4719
|
-
function formatUpdateDate(timeVal) {
|
|
4720
|
-
let telemetryTimeFormatted = "N/A";
|
|
4721
|
-
let timeSinceLastTelemetry = "";
|
|
4722
|
-
if (timeVal) {
|
|
4723
|
-
try {
|
|
4724
|
-
const telemetryDate = new Date(timeVal);
|
|
4725
|
-
telemetryTimeFormatted = telemetryDate.toLocaleString("pt-BR", {
|
|
4726
|
-
day: "2-digit",
|
|
4727
|
-
month: "2-digit",
|
|
4728
|
-
year: "numeric",
|
|
4729
|
-
hour: "2-digit",
|
|
4730
|
-
minute: "2-digit"
|
|
4731
|
-
});
|
|
4732
|
-
const now = /* @__PURE__ */ new Date();
|
|
4733
|
-
const diffMs = now.getTime() - telemetryDate.getTime();
|
|
4734
|
-
const diffMinutes = Math.floor(diffMs / (1e3 * 60));
|
|
4735
|
-
const diffHours = Math.floor(diffMinutes / 60);
|
|
4736
|
-
const diffDays = Math.floor(diffHours / 24);
|
|
4737
|
-
if (diffDays > 0) {
|
|
4738
|
-
timeSinceLastTelemetry = `(${diffDays}d atr\xE1s)`;
|
|
4739
|
-
} else if (diffHours > 0) {
|
|
4740
|
-
timeSinceLastTelemetry = `(${diffHours}h atr\xE1s)`;
|
|
4741
|
-
} else if (diffMinutes > 0) {
|
|
4742
|
-
timeSinceLastTelemetry = `(${diffMinutes}min atr\xE1s)`;
|
|
4743
|
-
} else {
|
|
4744
|
-
timeSinceLastTelemetry = "(agora)";
|
|
4745
|
-
}
|
|
4746
|
-
return timeSinceLastTelemetry;
|
|
4747
|
-
} catch (e) {
|
|
4748
|
-
telemetryTimeFormatted = "Formato inv\xE1lido";
|
|
4749
|
-
}
|
|
4750
|
-
}
|
|
4751
|
-
}
|
|
4752
4732
|
function calculateConsumptionPercentage(target, consumption) {
|
|
4753
4733
|
const numericTarget = Number(target);
|
|
4754
4734
|
const numericConsumption = Number(consumption);
|
|
@@ -4990,12 +4970,15 @@ function paint(root, state) {
|
|
|
4990
4970
|
effContainer.style.display = "none";
|
|
4991
4971
|
}
|
|
4992
4972
|
const opTimeVal = root.querySelector(".myio-ho-card__footer .metric:nth-child(1) .val");
|
|
4993
|
-
opTimeVal
|
|
4973
|
+
if (opTimeVal) {
|
|
4974
|
+
opTimeVal.textContent = entityObject.operationHours ?? "-";
|
|
4975
|
+
}
|
|
4994
4976
|
const powerVal = root.querySelector(".myio-ho-card__footer .metric:nth-child(2) .val");
|
|
4995
|
-
|
|
4996
|
-
|
|
4997
|
-
|
|
4998
|
-
|
|
4977
|
+
if (powerVal) {
|
|
4978
|
+
const instantPower = entityObject.instantaneousPower ?? entityObject.consumption_power ?? null;
|
|
4979
|
+
const powerFormatted = formatPower(instantPower);
|
|
4980
|
+
powerVal.textContent = instantPower !== null ? `${powerFormatted.num} ${powerFormatted.unit}` : "-";
|
|
4981
|
+
}
|
|
4999
4982
|
}
|
|
5000
4983
|
function bindEvents(root, state, callbacks) {
|
|
5001
4984
|
const { entityObject } = state;
|
|
@@ -4708,45 +4708,25 @@
|
|
|
4708
4708
|
function getIconSvg(deviceType) {
|
|
4709
4709
|
return ICON_MAP[deviceType] || ICON_MAP.DEFAULT;
|
|
4710
4710
|
}
|
|
4711
|
+
function formatPower(valueInWatts) {
|
|
4712
|
+
if (valueInWatts === null || valueInWatts === void 0 || isNaN(valueInWatts)) {
|
|
4713
|
+
return { num: "-", unit: "" };
|
|
4714
|
+
}
|
|
4715
|
+
const val = Number(valueInWatts);
|
|
4716
|
+
if (val >= 1e3) {
|
|
4717
|
+
const kw = Math.ceil(val / 1e3 * 100) / 100;
|
|
4718
|
+
return { num: kw.toFixed(2), unit: "kW" };
|
|
4719
|
+
} else {
|
|
4720
|
+
const w = Math.ceil(val);
|
|
4721
|
+
return { num: w.toString(), unit: "W" };
|
|
4722
|
+
}
|
|
4723
|
+
}
|
|
4711
4724
|
function formatValueByDomain(value, domain) {
|
|
4712
4725
|
if (domain === "water") {
|
|
4713
4726
|
return formatWaterVolumeM3(value);
|
|
4714
4727
|
}
|
|
4715
4728
|
return formatEnergy(value);
|
|
4716
4729
|
}
|
|
4717
|
-
function formatUpdateDate(timeVal) {
|
|
4718
|
-
let telemetryTimeFormatted = "N/A";
|
|
4719
|
-
let timeSinceLastTelemetry = "";
|
|
4720
|
-
if (timeVal) {
|
|
4721
|
-
try {
|
|
4722
|
-
const telemetryDate = new Date(timeVal);
|
|
4723
|
-
telemetryTimeFormatted = telemetryDate.toLocaleString("pt-BR", {
|
|
4724
|
-
day: "2-digit",
|
|
4725
|
-
month: "2-digit",
|
|
4726
|
-
year: "numeric",
|
|
4727
|
-
hour: "2-digit",
|
|
4728
|
-
minute: "2-digit"
|
|
4729
|
-
});
|
|
4730
|
-
const now = /* @__PURE__ */ new Date();
|
|
4731
|
-
const diffMs = now.getTime() - telemetryDate.getTime();
|
|
4732
|
-
const diffMinutes = Math.floor(diffMs / (1e3 * 60));
|
|
4733
|
-
const diffHours = Math.floor(diffMinutes / 60);
|
|
4734
|
-
const diffDays = Math.floor(diffHours / 24);
|
|
4735
|
-
if (diffDays > 0) {
|
|
4736
|
-
timeSinceLastTelemetry = `(${diffDays}d atr\xE1s)`;
|
|
4737
|
-
} else if (diffHours > 0) {
|
|
4738
|
-
timeSinceLastTelemetry = `(${diffHours}h atr\xE1s)`;
|
|
4739
|
-
} else if (diffMinutes > 0) {
|
|
4740
|
-
timeSinceLastTelemetry = `(${diffMinutes}min atr\xE1s)`;
|
|
4741
|
-
} else {
|
|
4742
|
-
timeSinceLastTelemetry = "(agora)";
|
|
4743
|
-
}
|
|
4744
|
-
return timeSinceLastTelemetry;
|
|
4745
|
-
} catch (e) {
|
|
4746
|
-
telemetryTimeFormatted = "Formato inv\xE1lido";
|
|
4747
|
-
}
|
|
4748
|
-
}
|
|
4749
|
-
}
|
|
4750
4730
|
function calculateConsumptionPercentage(target, consumption) {
|
|
4751
4731
|
const numericTarget = Number(target);
|
|
4752
4732
|
const numericConsumption = Number(consumption);
|
|
@@ -4988,12 +4968,15 @@
|
|
|
4988
4968
|
effContainer.style.display = "none";
|
|
4989
4969
|
}
|
|
4990
4970
|
const opTimeVal = root.querySelector(".myio-ho-card__footer .metric:nth-child(1) .val");
|
|
4991
|
-
opTimeVal
|
|
4971
|
+
if (opTimeVal) {
|
|
4972
|
+
opTimeVal.textContent = entityObject.operationHours ?? "-";
|
|
4973
|
+
}
|
|
4992
4974
|
const powerVal = root.querySelector(".myio-ho-card__footer .metric:nth-child(2) .val");
|
|
4993
|
-
|
|
4994
|
-
|
|
4995
|
-
|
|
4996
|
-
|
|
4975
|
+
if (powerVal) {
|
|
4976
|
+
const instantPower = entityObject.instantaneousPower ?? entityObject.consumption_power ?? null;
|
|
4977
|
+
const powerFormatted = formatPower(instantPower);
|
|
4978
|
+
powerVal.textContent = instantPower !== null ? `${powerFormatted.num} ${powerFormatted.unit}` : "-";
|
|
4979
|
+
}
|
|
4997
4980
|
}
|
|
4998
4981
|
function bindEvents(root, state, callbacks) {
|
|
4999
4982
|
const { entityObject } = state;
|