myio-js-library 0.1.182 → 0.1.184

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.
@@ -1544,11 +1544,11 @@
1544
1544
  const dsArray = Array.isArray(datasources) ? datasources : [];
1545
1545
  const map = /* @__PURE__ */ new Map();
1546
1546
  dsArray.forEach((ds) => {
1547
- const entityId = ds?.entityId;
1547
+ const entityId = ds?.entity?.id?.id || ds?.entity?.id || ds?.entityId || null;
1548
1548
  if (!entityId) return;
1549
1549
  if (!map.has(entityId)) {
1550
1550
  const entity = ds?.entity;
1551
- const draftLabel = entity?.label || entity?.name || ds?.name || null;
1551
+ const draftLabel = entity?.label || entity?.name || ds?.entityLabel || ds?.name || null;
1552
1552
  map.set(entityId, {
1553
1553
  id: entityId,
1554
1554
  identifier: null,
@@ -1570,7 +1570,7 @@
1570
1570
  function hydrateEntityMapWithCtxData(data, map) {
1571
1571
  const rows = Array.isArray(data) ? data : [];
1572
1572
  rows.forEach((row) => {
1573
- const entityId = row?.datasource?.entityId || null;
1573
+ const entityId = row?.datasource?.entity?.id?.id || row?.datasource?.entity?.id || row?.datasource?.entityId || null;
1574
1574
  if (!entityId || !map.has(entityId)) return;
1575
1575
  const rawKey = row?.dataKey?.name || "";
1576
1576
  if (!rawKey) return;
@@ -7706,6 +7706,100 @@
7706
7706
 
7707
7707
  // src/thingsboard/main-dashboard-shopping/v-5.2.0/card/template-card-v5.js
7708
7708
  var LABEL_CHAR_LIMIT2 = 18;
7709
+ var DEVICE_TYPE_CONFIG = {
7710
+ // Energy devices
7711
+ COMPRESSOR: { category: "energy", image: null },
7712
+ VENTILADOR: { category: "energy", image: null },
7713
+ ESCADA_ROLANTE: {
7714
+ category: "energy",
7715
+ image: "https://dashboard.myio-bas.com/api/images/public/EJ997iB2HD1AYYUHwIloyQOOszeqb2jp"
7716
+ },
7717
+ ELEVADOR: {
7718
+ category: "energy",
7719
+ image: "https://dashboard.myio-bas.com/api/images/public/rAjOvdsYJLGah6w6BABPJSD9znIyrkJX"
7720
+ },
7721
+ MOTOR: {
7722
+ category: "energy",
7723
+ image: "https://dashboard.myio-bas.com/api/images/public/Rge8Q3t0CP5PW8XyTn9bBK9aVP6uzSTT"
7724
+ },
7725
+ BOMBA_HIDRAULICA: {
7726
+ category: "energy",
7727
+ image: "https://dashboard.myio-bas.com/api/images/public/rbO2wQb6iKBtX0Ec04DFDcO3Qg04EOoD"
7728
+ },
7729
+ BOMBA_INCENDIO: {
7730
+ category: "energy",
7731
+ image: "https://dashboard.myio-bas.com/api/images/public/YJkELCk9kluQSM6QXaFINX6byQWI7vbB"
7732
+ },
7733
+ BOMBA: {
7734
+ category: "energy",
7735
+ image: "https://dashboard.myio-bas.com/api/images/public/Rge8Q3t0CP5PW8XyTn9bBK9aVP6uzSTT"
7736
+ },
7737
+ "3F_MEDIDOR": {
7738
+ category: "energy",
7739
+ image: "https://dashboard.myio-bas.com/api/images/public/f9Ce4meybsdaAhAkUlAfy5ei3I4kcN4k"
7740
+ },
7741
+ RELOGIO: {
7742
+ category: "energy",
7743
+ image: "https://dashboard.myio-bas.com/api/images/public/ljHZostWg0G5AfKiyM8oZixWRIIGRASB"
7744
+ },
7745
+ ENTRADA: {
7746
+ category: "energy",
7747
+ image: "https://dashboard.myio-bas.com/api/images/public/TQHPFqiejMW6lOSVsb8Pi85WtC0QKOLU"
7748
+ },
7749
+ SUBESTACAO: {
7750
+ category: "energy",
7751
+ image: "https://dashboard.myio-bas.com/api/images/public/TQHPFqiejMW6lOSVsb8Pi85WtC0QKOLU"
7752
+ },
7753
+ FANCOIL: {
7754
+ category: "energy",
7755
+ image: "https://dashboard.myio-bas.com/api/images/public/4BWMuVIFHnsfqatiV86DmTrOB7IF0X8Y"
7756
+ },
7757
+ CHILLER: {
7758
+ category: "energy",
7759
+ image: "https://dashboard.myio-bas.com/api/images/public/27Rvy9HbNoPz8KKWPa0SBDwu4kQ827VU"
7760
+ },
7761
+ AR_CONDICIONADO: { category: "energy", image: null },
7762
+ HVAC: { category: "energy", image: null },
7763
+ // Water devices
7764
+ HIDROMETRO: {
7765
+ category: "water",
7766
+ image: "https://dashboard.myio-bas.com/api/images/public/aMQYFJbGHs9gQbQkMn6XseAlUZHanBR4"
7767
+ },
7768
+ CAIXA_DAGUA: {
7769
+ category: "water",
7770
+ image: "https://dashboard.myio-bas.com/api/images/public/3t6WVhMQJFsrKA8bSZmrngDsNPkZV7fq"
7771
+ },
7772
+ // Tank devices (dynamic images based on level)
7773
+ TANK: { category: "tank", image: null },
7774
+ // Temperature devices (dynamic images based on status)
7775
+ TERMOSTATO: { category: "temperature", image: null }
7776
+ };
7777
+ var ENERGY_DEVICE_TYPES = new Set(
7778
+ Object.entries(DEVICE_TYPE_CONFIG).filter(([_, cfg]) => cfg.category === "energy").map(([type]) => type)
7779
+ );
7780
+ new Set(
7781
+ Object.entries(DEVICE_TYPE_CONFIG).filter(([_, cfg]) => cfg.category === "water").map(([type]) => type)
7782
+ );
7783
+ var TEMPERATURE_DEVICE_TYPES = new Set(
7784
+ Object.entries(DEVICE_TYPE_CONFIG).filter(([_, cfg]) => cfg.category === "temperature").map(([type]) => type)
7785
+ );
7786
+ var DEFAULT_DEVICE_IMAGE = "https://cdn-icons-png.flaticon.com/512/1178/1178428.png";
7787
+ var getDeviceCategory = (deviceType) => {
7788
+ const normalizedType = String(deviceType || "").toUpperCase();
7789
+ return DEVICE_TYPE_CONFIG[normalizedType]?.category || "energy";
7790
+ };
7791
+ var isEnergyDeviceType = (deviceType) => {
7792
+ const normalizedType = String(deviceType || "").toUpperCase();
7793
+ return ENERGY_DEVICE_TYPES.has(normalizedType);
7794
+ };
7795
+ var isTemperatureDeviceType = (deviceType) => {
7796
+ const normalizedType = String(deviceType || "").toUpperCase();
7797
+ return TEMPERATURE_DEVICE_TYPES.has(normalizedType);
7798
+ };
7799
+ var getStaticDeviceImage = (deviceType) => {
7800
+ const normalizedType = String(deviceType || "").toUpperCase();
7801
+ return DEVICE_TYPE_CONFIG[normalizedType]?.image || DEFAULT_DEVICE_IMAGE;
7802
+ };
7709
7803
  function renderCardComponentV5({
7710
7804
  entityObject,
7711
7805
  handleActionDashboard,
@@ -7828,10 +7922,14 @@
7828
7922
  };
7829
7923
  })();
7830
7924
  if (handInfo) {
7831
- console.warn("[template-card-v5] handInfo parameter is deprecated. Info functionality has been moved to settings modal.");
7925
+ console.warn(
7926
+ "[template-card-v5] handInfo parameter is deprecated. Info functionality has been moved to settings modal."
7927
+ );
7832
7928
  }
7833
7929
  if (!useNewComponents) {
7834
- console.warn("[template-card-v5] useNewComponents=false is not recommended. Consider using template-card-v2 directly.");
7930
+ console.warn(
7931
+ "[template-card-v5] useNewComponents=false is not recommended. Consider using template-card-v2 directly."
7932
+ );
7835
7933
  }
7836
7934
  const connectionStatus = mapDeviceToConnectionStatus(deviceStatus);
7837
7935
  const isOffline = isDeviceOffline(deviceStatus);
@@ -7839,53 +7937,19 @@
7839
7937
  const icon = getDeviceStatusIcon(deviceStatus, deviceType);
7840
7938
  getConnectionStatusIcon(connectionStatus);
7841
7939
  const mapDeviceTypeToIcon = (deviceType2) => {
7842
- const typeMap = {
7843
- "COMPRESSOR": "energy",
7844
- "VENTILADOR": "energy",
7845
- "ESCADA_ROLANTE": "energy",
7846
- "ELEVADOR": "energy",
7847
- "MOTOR": "energy",
7848
- "3F_MEDIDOR": "energy",
7849
- "RELOGIO": "energy",
7850
- "ENTRADA": "energy",
7851
- "SUBESTACAO": "energy",
7852
- "HIDROMETRO": "water",
7853
- "CAIXA_DAGUA": "water",
7854
- "TANK": "water",
7855
- "TERMOSTATO": "temperature"
7856
- };
7857
- const normalizedType = deviceType2?.toUpperCase() || "";
7858
- return typeMap[normalizedType] || "generic";
7940
+ const category = getDeviceCategory(deviceType2);
7941
+ if (category === "water" || category === "tank") return "water";
7942
+ if (category === "temperature") return "temperature";
7943
+ if (category === "energy") return "energy";
7944
+ return "generic";
7859
7945
  };
7860
7946
  const getValueTypeFromDeviceType = (deviceType2) => {
7861
- const typeMap = {
7862
- "COMPRESSOR": "ENERGY",
7863
- "VENTILADOR": "ENERGY",
7864
- "ESCADA_ROLANTE": "ENERGY",
7865
- "ELEVADOR": "ENERGY",
7866
- "MOTOR": "ENERGY",
7867
- "3F_MEDIDOR": "ENERGY",
7868
- "RELOGIO": "ENERGY",
7869
- "ENTRADA": "ENERGY",
7870
- "SUBESTACAO": "ENERGY",
7871
- "HIDROMETRO": "WATER",
7872
- "CAIXA_DAGUA": "WATER",
7873
- "TANK": "TANK",
7874
- "TERMOSTATO": "TEMPERATURE"
7875
- };
7876
- const normalizedType = deviceType2?.toUpperCase() || "";
7877
- return typeMap[normalizedType] || "ENERGY";
7878
- };
7879
- const isEnergyDevice = (deviceType2) => {
7880
- const energyDeviceTypes = ["COMPRESSOR", "VENTILADOR", "ESCADA_ROLANTE", "ELEVADOR", "MOTOR", "3F_MEDIDOR", "RELOGIO", "ENTRADA", "SUBESTACAO"];
7881
- const normalizedType = deviceType2?.toUpperCase() || "";
7882
- return energyDeviceTypes.includes(normalizedType);
7883
- };
7884
- const isTemperatureDevice = (deviceType2) => {
7885
- const temperatureDeviceTypes = ["TERMOSTATO"];
7886
- const normalizedType = deviceType2?.toUpperCase() || "";
7887
- return temperatureDeviceTypes.includes(normalizedType);
7947
+ const category = getDeviceCategory(deviceType2);
7948
+ if (category === "tank") return "TANK";
7949
+ return category.toUpperCase();
7888
7950
  };
7951
+ const isEnergyDevice = (deviceType2) => isEnergyDeviceType(deviceType2);
7952
+ const isTemperatureDevice = (deviceType2) => isTemperatureDeviceType(deviceType2);
7889
7953
  const formatCardValue = (value, deviceType2) => {
7890
7954
  const numValue = Number(value) || 0;
7891
7955
  if (isEnergyDevice(deviceType2)) {
@@ -8118,13 +8182,7 @@
8118
8182
  }
8119
8183
  const getDeviceImageUrl = (deviceType2, percentage = 0, options = {}) => {
8120
8184
  const { tempStatus: tempStatus2, isOffline: isOffline2 } = options;
8121
- function normalizeString(str) {
8122
- if (typeof str !== "string") {
8123
- str = "";
8124
- }
8125
- return str.normalize("NFD").replace(/[\u0300-\u036f]/g, "").toUpperCase();
8126
- }
8127
- const nameType = normalizeString(deviceType2);
8185
+ const nameType = String(deviceType2 || "").toUpperCase();
8128
8186
  if (nameType === "TERMOSTATO") {
8129
8187
  if (isOffline2) {
8130
8188
  return "https://dashboard.myio-bas.com/api/images/public/Q4bE6zWz4pL3u5M3rjmMt2uSis6Xe52F";
@@ -8148,18 +8206,7 @@
8148
8206
  return "https://dashboard.myio-bas.com/api/images/public/qLdwhV4qw295poSCa7HinpnmXoN7dAPO";
8149
8207
  }
8150
8208
  }
8151
- const deviceImages = {
8152
- MOTOR: "https://dashboard.myio-bas.com/api/images/public/Rge8Q3t0CP5PW8XyTn9bBK9aVP6uzSTT",
8153
- "3F_MEDIDOR": "https://dashboard.myio-bas.com/api/images/public/f9Ce4meybsdaAhAkUlAfy5ei3I4kcN4k",
8154
- RELOGIO: "https://dashboard.myio-bas.com/api/images/public/ljHZostWg0G5AfKiyM8oZixWRIIGRASB",
8155
- HIDROMETRO: "https://dashboard.myio-bas.com/api/images/public/aMQYFJbGHs9gQbQkMn6XseAlUZHanBR4",
8156
- ENTRADA: "https://dashboard.myio-bas.com/api/images/public/TQHPFqiejMW6lOSVsb8Pi85WtC0QKOLU",
8157
- CAIXA_DAGUA: "https://dashboard.myio-bas.com/api/images/public/3t6WVhMQJFsrKA8bSZmrngDsNPkZV7fq",
8158
- ELEVADOR: "https://dashboard.myio-bas.com/api/images/public/rAjOvdsYJLGah6w6BABPJSD9znIyrkJX",
8159
- ESCADA_ROLANTE: "https://dashboard.myio-bas.com/api/images/public/EJ997iB2HD1AYYUHwIloyQOOszeqb2jp"
8160
- };
8161
- const defaultImage = "https://cdn-icons-png.flaticon.com/512/1178/1178428.png";
8162
- return deviceImages[nameType] || defaultImage;
8209
+ return getStaticDeviceImage(nameType);
8163
8210
  };
8164
8211
  const isTankDevice = deviceType === "TANK" || deviceType === "CAIXA_DAGUA";
8165
8212
  const isTermostatoDevice = deviceType?.toUpperCase() === "TERMOSTATO";
@@ -18018,10 +18065,10 @@
18018
18065
  { value: "ELEVADOR", label: "Elevador" },
18019
18066
  { value: "ESCADA_ROLANTE", label: "Escada Rolante" },
18020
18067
  { value: "MOTOR", label: "Motor" },
18021
- { value: "BOMBA", label: "Bomba" },
18068
+ { value: "BOMBA_HIDRAULICA", label: "Bomba Hidr\xE1ulica" },
18069
+ { value: "BOMBA_INCENDIO", label: "Bomba Inc\xEAndio" },
18022
18070
  { value: "CHILLER", label: "Chiller" },
18023
18071
  { value: "AR_CONDICIONADO", label: "Ar Condicionado" },
18024
- { value: "HVAC", label: "HVAC" },
18025
18072
  { value: "FANCOIL", label: "Fancoil" },
18026
18073
  { value: "3F_MEDIDOR", label: "Medidor Trif\xE1sico" }
18027
18074
  ];