myio-js-library 0.1.142 → 0.1.144
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 +81 -64
- package/dist/index.js +81 -64
- package/dist/myio-js-library.umd.js +81 -64
- package/dist/myio-js-library.umd.min.js +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -4811,6 +4811,12 @@ function normalizeParams(params) {
|
|
|
4811
4811
|
function getIconSvg(deviceType) {
|
|
4812
4812
|
return ICON_MAP[deviceType] || ICON_MAP.DEFAULT;
|
|
4813
4813
|
}
|
|
4814
|
+
function formatValueByDomain(value, domain) {
|
|
4815
|
+
if (domain === "water") {
|
|
4816
|
+
return formatWaterVolumeM3(value);
|
|
4817
|
+
}
|
|
4818
|
+
return formatEnergy(value);
|
|
4819
|
+
}
|
|
4814
4820
|
function formatUpdateDate(timeVal) {
|
|
4815
4821
|
let telemetryTimeFormatted = "N/A";
|
|
4816
4822
|
let timeSinceLastTelemetry = "";
|
|
@@ -5059,7 +5065,7 @@ function paint(root, state) {
|
|
|
5059
5065
|
const chip = root.querySelector(".chip");
|
|
5060
5066
|
chip.className = `chip ${statusInfo.chipClass}`;
|
|
5061
5067
|
chip.textContent = statusInfo.label;
|
|
5062
|
-
const primaryValue =
|
|
5068
|
+
const primaryValue = formatValueByDomain(entityObject.val, entityObject.domain);
|
|
5063
5069
|
const numSpan = root.querySelector(".myio-ho-card__value .num");
|
|
5064
5070
|
const unitSpan = root.querySelector(".myio-ho-card__value .unit");
|
|
5065
5071
|
numSpan.textContent = primaryValue;
|
|
@@ -7536,7 +7542,10 @@ async function openRealTimeTelemetryModal(params) {
|
|
|
7536
7542
|
if (!telemetryData || telemetryData.length === 0) continue;
|
|
7537
7543
|
const latest = telemetryData[0];
|
|
7538
7544
|
const config = TELEMETRY_CONFIG[key] || { label: key, unit: "", icon: "\u{1F4CA}", decimals: 2 };
|
|
7539
|
-
|
|
7545
|
+
let numValue = Number(latest.value) || 0;
|
|
7546
|
+
if (key === "total_current" || key === "current") {
|
|
7547
|
+
numValue = numValue / 1e3;
|
|
7548
|
+
}
|
|
7540
7549
|
const formatted = numValue.toFixed(config.decimals);
|
|
7541
7550
|
values.push({
|
|
7542
7551
|
key,
|
|
@@ -17182,13 +17191,30 @@ var DefaultSettingsPersister = class {
|
|
|
17182
17191
|
jwtToken;
|
|
17183
17192
|
tbBaseUrl;
|
|
17184
17193
|
deviceType;
|
|
17194
|
+
deviceProfile;
|
|
17185
17195
|
existingMapInstantaneousPower;
|
|
17186
17196
|
constructor(jwtToken, apiConfig) {
|
|
17187
17197
|
this.jwtToken = jwtToken;
|
|
17188
17198
|
this.tbBaseUrl = apiConfig?.tbBaseUrl || window.location.origin;
|
|
17189
17199
|
this.deviceType = apiConfig?.deviceType || "ELEVADOR";
|
|
17200
|
+
this.deviceProfile = apiConfig?.deviceProfile || null;
|
|
17190
17201
|
this.existingMapInstantaneousPower = apiConfig?.mapInstantaneousPower || null;
|
|
17191
17202
|
}
|
|
17203
|
+
/**
|
|
17204
|
+
* RFC-0086: Resolve effective device type
|
|
17205
|
+
* When deviceType is 3F_MEDIDOR, use deviceProfile as the actual type
|
|
17206
|
+
*/
|
|
17207
|
+
getEffectiveDeviceType() {
|
|
17208
|
+
const normalizedType = (this.deviceType || "").toUpperCase();
|
|
17209
|
+
if (normalizedType === "3F_MEDIDOR") {
|
|
17210
|
+
const profile = (this.deviceProfile || "").toUpperCase();
|
|
17211
|
+
if (profile && profile !== "N/D" && profile.trim() !== "") {
|
|
17212
|
+
console.log(`[SettingsPersister] RFC-0086: Resolved 3F_MEDIDOR \u2192 ${profile}`);
|
|
17213
|
+
return profile;
|
|
17214
|
+
}
|
|
17215
|
+
}
|
|
17216
|
+
return normalizedType || "ELEVADOR";
|
|
17217
|
+
}
|
|
17192
17218
|
async saveEntityLabel(deviceId, label) {
|
|
17193
17219
|
try {
|
|
17194
17220
|
const getRes = await fetch(`${this.tbBaseUrl}/api/device/${deviceId}`, {
|
|
@@ -17246,72 +17272,59 @@ var DefaultSettingsPersister = class {
|
|
|
17246
17272
|
}
|
|
17247
17273
|
}
|
|
17248
17274
|
/**
|
|
17249
|
-
* RFC-
|
|
17250
|
-
*
|
|
17275
|
+
* RFC-0086: Build mapInstantaneousPower JSON structure from form data
|
|
17276
|
+
* IMPORTANT: When saving to a DEVICE, only include entries for the specific deviceType
|
|
17277
|
+
* Uses getEffectiveDeviceType() to resolve 3F_MEDIDOR → deviceProfile
|
|
17251
17278
|
*/
|
|
17252
17279
|
buildMapInstantaneousPower(formData) {
|
|
17253
|
-
const
|
|
17254
|
-
version: "1.0.0",
|
|
17255
|
-
limitsByInstantaneoustPowerType: []
|
|
17256
|
-
};
|
|
17280
|
+
const effectiveDeviceType = this.getEffectiveDeviceType();
|
|
17257
17281
|
const telemetryType = String(formData.telemetryType || "consumption");
|
|
17258
|
-
|
|
17259
|
-
|
|
17260
|
-
|
|
17261
|
-
|
|
17262
|
-
|
|
17263
|
-
|
|
17264
|
-
|
|
17265
|
-
|
|
17266
|
-
|
|
17267
|
-
|
|
17268
|
-
|
|
17269
|
-
|
|
17270
|
-
|
|
17271
|
-
|
|
17272
|
-
|
|
17273
|
-
|
|
17274
|
-
|
|
17275
|
-
|
|
17276
|
-
|
|
17277
|
-
|
|
17278
|
-
|
|
17279
|
-
|
|
17280
|
-
|
|
17281
|
-
|
|
17282
|
-
|
|
17283
|
-
|
|
17284
|
-
|
|
17285
|
-
|
|
17286
|
-
|
|
17287
|
-
|
|
17288
|
-
|
|
17289
|
-
|
|
17290
|
-
|
|
17291
|
-
|
|
17292
|
-
|
|
17293
|
-
|
|
17294
|
-
|
|
17295
|
-
|
|
17296
|
-
|
|
17297
|
-
|
|
17298
|
-
|
|
17299
|
-
|
|
17300
|
-
topValue: Number(formData.alertLimitUpConsumption) || 0
|
|
17301
|
-
}
|
|
17302
|
-
},
|
|
17303
|
-
{
|
|
17304
|
-
deviceStatusName: "failure",
|
|
17305
|
-
limitsValues: {
|
|
17306
|
-
baseValue: Number(formData.failureLimitDownConsumption) || 0,
|
|
17307
|
-
topValue: Number(formData.failureLimitUpConsumption) || 0
|
|
17282
|
+
const result = {
|
|
17283
|
+
version: "1.0.0",
|
|
17284
|
+
limitsByInstantaneoustPowerType: [
|
|
17285
|
+
{
|
|
17286
|
+
telemetryType,
|
|
17287
|
+
itemsByDeviceType: [
|
|
17288
|
+
{
|
|
17289
|
+
deviceType: effectiveDeviceType,
|
|
17290
|
+
name: `mapInstantaneousPower${this.formatDeviceTypeName(effectiveDeviceType)}`,
|
|
17291
|
+
description: formData.identifier ? `Limites customizados para ${formData.identifier}` : `Limites de pot\xEAncia customizados para ${effectiveDeviceType}`,
|
|
17292
|
+
limitsByDeviceStatus: [
|
|
17293
|
+
{
|
|
17294
|
+
deviceStatusName: "standBy",
|
|
17295
|
+
limitsValues: {
|
|
17296
|
+
baseValue: Number(formData.standbyLimitDownConsumption) || 0,
|
|
17297
|
+
topValue: Number(formData.standbyLimitUpConsumption) || 0
|
|
17298
|
+
}
|
|
17299
|
+
},
|
|
17300
|
+
{
|
|
17301
|
+
deviceStatusName: "normal",
|
|
17302
|
+
limitsValues: {
|
|
17303
|
+
baseValue: Number(formData.normalLimitDownConsumption) || 0,
|
|
17304
|
+
topValue: Number(formData.normalLimitUpConsumption) || 0
|
|
17305
|
+
}
|
|
17306
|
+
},
|
|
17307
|
+
{
|
|
17308
|
+
deviceStatusName: "alert",
|
|
17309
|
+
limitsValues: {
|
|
17310
|
+
baseValue: Number(formData.alertLimitDownConsumption) || 0,
|
|
17311
|
+
topValue: Number(formData.alertLimitUpConsumption) || 0
|
|
17312
|
+
}
|
|
17313
|
+
},
|
|
17314
|
+
{
|
|
17315
|
+
deviceStatusName: "failure",
|
|
17316
|
+
limitsValues: {
|
|
17317
|
+
baseValue: Number(formData.failureLimitDownConsumption) || 0,
|
|
17318
|
+
topValue: Number(formData.failureLimitUpConsumption) || 0
|
|
17319
|
+
}
|
|
17320
|
+
}
|
|
17321
|
+
]
|
|
17322
|
+
}
|
|
17323
|
+
]
|
|
17308
17324
|
}
|
|
17309
|
-
|
|
17310
|
-
|
|
17311
|
-
|
|
17312
|
-
deviceConfig.description = `Limites customizados para ${formData.identifier}`;
|
|
17313
|
-
}
|
|
17314
|
-
console.log("[SettingsPersister] RFC-0080: Built mapInstantaneousPower:", result);
|
|
17325
|
+
]
|
|
17326
|
+
};
|
|
17327
|
+
console.log(`[SettingsPersister] RFC-0086: Built mapInstantaneousPower for deviceType=${effectiveDeviceType}:`, result);
|
|
17315
17328
|
return result;
|
|
17316
17329
|
}
|
|
17317
17330
|
/**
|
|
@@ -17550,6 +17563,8 @@ var SettingsController = class {
|
|
|
17550
17563
|
const apiConfigWithDeviceInfo = {
|
|
17551
17564
|
...params.api,
|
|
17552
17565
|
deviceType: params.deviceType,
|
|
17566
|
+
deviceProfile: params.deviceProfile,
|
|
17567
|
+
// RFC-0086: For 3F_MEDIDOR → deviceProfile resolution
|
|
17553
17568
|
mapInstantaneousPower: params.mapInstantaneousPower
|
|
17554
17569
|
};
|
|
17555
17570
|
this.persister = params.persister || new DefaultSettingsPersister(params.jwtToken, apiConfigWithDeviceInfo);
|
|
@@ -17601,6 +17616,8 @@ var SettingsController = class {
|
|
|
17601
17616
|
this.persister = new DefaultSettingsPersister(this.params.jwtToken, {
|
|
17602
17617
|
...this.params.api,
|
|
17603
17618
|
deviceType: this.params.deviceType,
|
|
17619
|
+
deviceProfile: this.params.deviceProfile,
|
|
17620
|
+
// RFC-0086: For 3F_MEDIDOR → deviceProfile resolution
|
|
17604
17621
|
mapInstantaneousPower: globalMap
|
|
17605
17622
|
});
|
|
17606
17623
|
this.view.updateMapInstantaneousPower(globalMap);
|
package/dist/index.js
CHANGED
|
@@ -4703,6 +4703,12 @@ function normalizeParams(params) {
|
|
|
4703
4703
|
function getIconSvg(deviceType) {
|
|
4704
4704
|
return ICON_MAP[deviceType] || ICON_MAP.DEFAULT;
|
|
4705
4705
|
}
|
|
4706
|
+
function formatValueByDomain(value, domain) {
|
|
4707
|
+
if (domain === "water") {
|
|
4708
|
+
return formatWaterVolumeM3(value);
|
|
4709
|
+
}
|
|
4710
|
+
return formatEnergy(value);
|
|
4711
|
+
}
|
|
4706
4712
|
function formatUpdateDate(timeVal) {
|
|
4707
4713
|
let telemetryTimeFormatted = "N/A";
|
|
4708
4714
|
let timeSinceLastTelemetry = "";
|
|
@@ -4951,7 +4957,7 @@ function paint(root, state) {
|
|
|
4951
4957
|
const chip = root.querySelector(".chip");
|
|
4952
4958
|
chip.className = `chip ${statusInfo.chipClass}`;
|
|
4953
4959
|
chip.textContent = statusInfo.label;
|
|
4954
|
-
const primaryValue =
|
|
4960
|
+
const primaryValue = formatValueByDomain(entityObject.val, entityObject.domain);
|
|
4955
4961
|
const numSpan = root.querySelector(".myio-ho-card__value .num");
|
|
4956
4962
|
const unitSpan = root.querySelector(".myio-ho-card__value .unit");
|
|
4957
4963
|
numSpan.textContent = primaryValue;
|
|
@@ -7428,7 +7434,10 @@ async function openRealTimeTelemetryModal(params) {
|
|
|
7428
7434
|
if (!telemetryData || telemetryData.length === 0) continue;
|
|
7429
7435
|
const latest = telemetryData[0];
|
|
7430
7436
|
const config = TELEMETRY_CONFIG[key] || { label: key, unit: "", icon: "\u{1F4CA}", decimals: 2 };
|
|
7431
|
-
|
|
7437
|
+
let numValue = Number(latest.value) || 0;
|
|
7438
|
+
if (key === "total_current" || key === "current") {
|
|
7439
|
+
numValue = numValue / 1e3;
|
|
7440
|
+
}
|
|
7432
7441
|
const formatted = numValue.toFixed(config.decimals);
|
|
7433
7442
|
values.push({
|
|
7434
7443
|
key,
|
|
@@ -17074,13 +17083,30 @@ var DefaultSettingsPersister = class {
|
|
|
17074
17083
|
jwtToken;
|
|
17075
17084
|
tbBaseUrl;
|
|
17076
17085
|
deviceType;
|
|
17086
|
+
deviceProfile;
|
|
17077
17087
|
existingMapInstantaneousPower;
|
|
17078
17088
|
constructor(jwtToken, apiConfig) {
|
|
17079
17089
|
this.jwtToken = jwtToken;
|
|
17080
17090
|
this.tbBaseUrl = apiConfig?.tbBaseUrl || window.location.origin;
|
|
17081
17091
|
this.deviceType = apiConfig?.deviceType || "ELEVADOR";
|
|
17092
|
+
this.deviceProfile = apiConfig?.deviceProfile || null;
|
|
17082
17093
|
this.existingMapInstantaneousPower = apiConfig?.mapInstantaneousPower || null;
|
|
17083
17094
|
}
|
|
17095
|
+
/**
|
|
17096
|
+
* RFC-0086: Resolve effective device type
|
|
17097
|
+
* When deviceType is 3F_MEDIDOR, use deviceProfile as the actual type
|
|
17098
|
+
*/
|
|
17099
|
+
getEffectiveDeviceType() {
|
|
17100
|
+
const normalizedType = (this.deviceType || "").toUpperCase();
|
|
17101
|
+
if (normalizedType === "3F_MEDIDOR") {
|
|
17102
|
+
const profile = (this.deviceProfile || "").toUpperCase();
|
|
17103
|
+
if (profile && profile !== "N/D" && profile.trim() !== "") {
|
|
17104
|
+
console.log(`[SettingsPersister] RFC-0086: Resolved 3F_MEDIDOR \u2192 ${profile}`);
|
|
17105
|
+
return profile;
|
|
17106
|
+
}
|
|
17107
|
+
}
|
|
17108
|
+
return normalizedType || "ELEVADOR";
|
|
17109
|
+
}
|
|
17084
17110
|
async saveEntityLabel(deviceId, label) {
|
|
17085
17111
|
try {
|
|
17086
17112
|
const getRes = await fetch(`${this.tbBaseUrl}/api/device/${deviceId}`, {
|
|
@@ -17138,72 +17164,59 @@ var DefaultSettingsPersister = class {
|
|
|
17138
17164
|
}
|
|
17139
17165
|
}
|
|
17140
17166
|
/**
|
|
17141
|
-
* RFC-
|
|
17142
|
-
*
|
|
17167
|
+
* RFC-0086: Build mapInstantaneousPower JSON structure from form data
|
|
17168
|
+
* IMPORTANT: When saving to a DEVICE, only include entries for the specific deviceType
|
|
17169
|
+
* Uses getEffectiveDeviceType() to resolve 3F_MEDIDOR → deviceProfile
|
|
17143
17170
|
*/
|
|
17144
17171
|
buildMapInstantaneousPower(formData) {
|
|
17145
|
-
const
|
|
17146
|
-
version: "1.0.0",
|
|
17147
|
-
limitsByInstantaneoustPowerType: []
|
|
17148
|
-
};
|
|
17172
|
+
const effectiveDeviceType = this.getEffectiveDeviceType();
|
|
17149
17173
|
const telemetryType = String(formData.telemetryType || "consumption");
|
|
17150
|
-
|
|
17151
|
-
|
|
17152
|
-
|
|
17153
|
-
|
|
17154
|
-
|
|
17155
|
-
|
|
17156
|
-
|
|
17157
|
-
|
|
17158
|
-
|
|
17159
|
-
|
|
17160
|
-
|
|
17161
|
-
|
|
17162
|
-
|
|
17163
|
-
|
|
17164
|
-
|
|
17165
|
-
|
|
17166
|
-
|
|
17167
|
-
|
|
17168
|
-
|
|
17169
|
-
|
|
17170
|
-
|
|
17171
|
-
|
|
17172
|
-
|
|
17173
|
-
|
|
17174
|
-
|
|
17175
|
-
|
|
17176
|
-
|
|
17177
|
-
|
|
17178
|
-
|
|
17179
|
-
|
|
17180
|
-
|
|
17181
|
-
|
|
17182
|
-
|
|
17183
|
-
|
|
17184
|
-
|
|
17185
|
-
|
|
17186
|
-
|
|
17187
|
-
|
|
17188
|
-
|
|
17189
|
-
|
|
17190
|
-
|
|
17191
|
-
|
|
17192
|
-
topValue: Number(formData.alertLimitUpConsumption) || 0
|
|
17193
|
-
}
|
|
17194
|
-
},
|
|
17195
|
-
{
|
|
17196
|
-
deviceStatusName: "failure",
|
|
17197
|
-
limitsValues: {
|
|
17198
|
-
baseValue: Number(formData.failureLimitDownConsumption) || 0,
|
|
17199
|
-
topValue: Number(formData.failureLimitUpConsumption) || 0
|
|
17174
|
+
const result = {
|
|
17175
|
+
version: "1.0.0",
|
|
17176
|
+
limitsByInstantaneoustPowerType: [
|
|
17177
|
+
{
|
|
17178
|
+
telemetryType,
|
|
17179
|
+
itemsByDeviceType: [
|
|
17180
|
+
{
|
|
17181
|
+
deviceType: effectiveDeviceType,
|
|
17182
|
+
name: `mapInstantaneousPower${this.formatDeviceTypeName(effectiveDeviceType)}`,
|
|
17183
|
+
description: formData.identifier ? `Limites customizados para ${formData.identifier}` : `Limites de pot\xEAncia customizados para ${effectiveDeviceType}`,
|
|
17184
|
+
limitsByDeviceStatus: [
|
|
17185
|
+
{
|
|
17186
|
+
deviceStatusName: "standBy",
|
|
17187
|
+
limitsValues: {
|
|
17188
|
+
baseValue: Number(formData.standbyLimitDownConsumption) || 0,
|
|
17189
|
+
topValue: Number(formData.standbyLimitUpConsumption) || 0
|
|
17190
|
+
}
|
|
17191
|
+
},
|
|
17192
|
+
{
|
|
17193
|
+
deviceStatusName: "normal",
|
|
17194
|
+
limitsValues: {
|
|
17195
|
+
baseValue: Number(formData.normalLimitDownConsumption) || 0,
|
|
17196
|
+
topValue: Number(formData.normalLimitUpConsumption) || 0
|
|
17197
|
+
}
|
|
17198
|
+
},
|
|
17199
|
+
{
|
|
17200
|
+
deviceStatusName: "alert",
|
|
17201
|
+
limitsValues: {
|
|
17202
|
+
baseValue: Number(formData.alertLimitDownConsumption) || 0,
|
|
17203
|
+
topValue: Number(formData.alertLimitUpConsumption) || 0
|
|
17204
|
+
}
|
|
17205
|
+
},
|
|
17206
|
+
{
|
|
17207
|
+
deviceStatusName: "failure",
|
|
17208
|
+
limitsValues: {
|
|
17209
|
+
baseValue: Number(formData.failureLimitDownConsumption) || 0,
|
|
17210
|
+
topValue: Number(formData.failureLimitUpConsumption) || 0
|
|
17211
|
+
}
|
|
17212
|
+
}
|
|
17213
|
+
]
|
|
17214
|
+
}
|
|
17215
|
+
]
|
|
17200
17216
|
}
|
|
17201
|
-
|
|
17202
|
-
|
|
17203
|
-
|
|
17204
|
-
deviceConfig.description = `Limites customizados para ${formData.identifier}`;
|
|
17205
|
-
}
|
|
17206
|
-
console.log("[SettingsPersister] RFC-0080: Built mapInstantaneousPower:", result);
|
|
17217
|
+
]
|
|
17218
|
+
};
|
|
17219
|
+
console.log(`[SettingsPersister] RFC-0086: Built mapInstantaneousPower for deviceType=${effectiveDeviceType}:`, result);
|
|
17207
17220
|
return result;
|
|
17208
17221
|
}
|
|
17209
17222
|
/**
|
|
@@ -17442,6 +17455,8 @@ var SettingsController = class {
|
|
|
17442
17455
|
const apiConfigWithDeviceInfo = {
|
|
17443
17456
|
...params.api,
|
|
17444
17457
|
deviceType: params.deviceType,
|
|
17458
|
+
deviceProfile: params.deviceProfile,
|
|
17459
|
+
// RFC-0086: For 3F_MEDIDOR → deviceProfile resolution
|
|
17445
17460
|
mapInstantaneousPower: params.mapInstantaneousPower
|
|
17446
17461
|
};
|
|
17447
17462
|
this.persister = params.persister || new DefaultSettingsPersister(params.jwtToken, apiConfigWithDeviceInfo);
|
|
@@ -17493,6 +17508,8 @@ var SettingsController = class {
|
|
|
17493
17508
|
this.persister = new DefaultSettingsPersister(this.params.jwtToken, {
|
|
17494
17509
|
...this.params.api,
|
|
17495
17510
|
deviceType: this.params.deviceType,
|
|
17511
|
+
deviceProfile: this.params.deviceProfile,
|
|
17512
|
+
// RFC-0086: For 3F_MEDIDOR → deviceProfile resolution
|
|
17496
17513
|
mapInstantaneousPower: globalMap
|
|
17497
17514
|
});
|
|
17498
17515
|
this.view.updateMapInstantaneousPower(globalMap);
|
|
@@ -4701,6 +4701,12 @@
|
|
|
4701
4701
|
function getIconSvg(deviceType) {
|
|
4702
4702
|
return ICON_MAP[deviceType] || ICON_MAP.DEFAULT;
|
|
4703
4703
|
}
|
|
4704
|
+
function formatValueByDomain(value, domain) {
|
|
4705
|
+
if (domain === "water") {
|
|
4706
|
+
return formatWaterVolumeM3(value);
|
|
4707
|
+
}
|
|
4708
|
+
return formatEnergy(value);
|
|
4709
|
+
}
|
|
4704
4710
|
function formatUpdateDate(timeVal) {
|
|
4705
4711
|
let telemetryTimeFormatted = "N/A";
|
|
4706
4712
|
let timeSinceLastTelemetry = "";
|
|
@@ -4949,7 +4955,7 @@
|
|
|
4949
4955
|
const chip = root.querySelector(".chip");
|
|
4950
4956
|
chip.className = `chip ${statusInfo.chipClass}`;
|
|
4951
4957
|
chip.textContent = statusInfo.label;
|
|
4952
|
-
const primaryValue =
|
|
4958
|
+
const primaryValue = formatValueByDomain(entityObject.val, entityObject.domain);
|
|
4953
4959
|
const numSpan = root.querySelector(".myio-ho-card__value .num");
|
|
4954
4960
|
root.querySelector(".myio-ho-card__value .unit");
|
|
4955
4961
|
numSpan.textContent = primaryValue;
|
|
@@ -7426,7 +7432,10 @@ ${rangeText}`;
|
|
|
7426
7432
|
if (!telemetryData || telemetryData.length === 0) continue;
|
|
7427
7433
|
const latest = telemetryData[0];
|
|
7428
7434
|
const config = TELEMETRY_CONFIG[key] || { label: key, unit: "", icon: "\u{1F4CA}", decimals: 2 };
|
|
7429
|
-
|
|
7435
|
+
let numValue = Number(latest.value) || 0;
|
|
7436
|
+
if (key === "total_current" || key === "current") {
|
|
7437
|
+
numValue = numValue / 1e3;
|
|
7438
|
+
}
|
|
7430
7439
|
const formatted = numValue.toFixed(config.decimals);
|
|
7431
7440
|
values.push({
|
|
7432
7441
|
key,
|
|
@@ -16898,13 +16907,30 @@ ${rangeText}`;
|
|
|
16898
16907
|
jwtToken;
|
|
16899
16908
|
tbBaseUrl;
|
|
16900
16909
|
deviceType;
|
|
16910
|
+
deviceProfile;
|
|
16901
16911
|
existingMapInstantaneousPower;
|
|
16902
16912
|
constructor(jwtToken, apiConfig) {
|
|
16903
16913
|
this.jwtToken = jwtToken;
|
|
16904
16914
|
this.tbBaseUrl = apiConfig?.tbBaseUrl || window.location.origin;
|
|
16905
16915
|
this.deviceType = apiConfig?.deviceType || "ELEVADOR";
|
|
16916
|
+
this.deviceProfile = apiConfig?.deviceProfile || null;
|
|
16906
16917
|
this.existingMapInstantaneousPower = apiConfig?.mapInstantaneousPower || null;
|
|
16907
16918
|
}
|
|
16919
|
+
/**
|
|
16920
|
+
* RFC-0086: Resolve effective device type
|
|
16921
|
+
* When deviceType is 3F_MEDIDOR, use deviceProfile as the actual type
|
|
16922
|
+
*/
|
|
16923
|
+
getEffectiveDeviceType() {
|
|
16924
|
+
const normalizedType = (this.deviceType || "").toUpperCase();
|
|
16925
|
+
if (normalizedType === "3F_MEDIDOR") {
|
|
16926
|
+
const profile = (this.deviceProfile || "").toUpperCase();
|
|
16927
|
+
if (profile && profile !== "N/D" && profile.trim() !== "") {
|
|
16928
|
+
console.log(`[SettingsPersister] RFC-0086: Resolved 3F_MEDIDOR \u2192 ${profile}`);
|
|
16929
|
+
return profile;
|
|
16930
|
+
}
|
|
16931
|
+
}
|
|
16932
|
+
return normalizedType || "ELEVADOR";
|
|
16933
|
+
}
|
|
16908
16934
|
async saveEntityLabel(deviceId, label) {
|
|
16909
16935
|
try {
|
|
16910
16936
|
const getRes = await fetch(`${this.tbBaseUrl}/api/device/${deviceId}`, {
|
|
@@ -16962,72 +16988,59 @@ ${rangeText}`;
|
|
|
16962
16988
|
}
|
|
16963
16989
|
}
|
|
16964
16990
|
/**
|
|
16965
|
-
* RFC-
|
|
16966
|
-
*
|
|
16991
|
+
* RFC-0086: Build mapInstantaneousPower JSON structure from form data
|
|
16992
|
+
* IMPORTANT: When saving to a DEVICE, only include entries for the specific deviceType
|
|
16993
|
+
* Uses getEffectiveDeviceType() to resolve 3F_MEDIDOR → deviceProfile
|
|
16967
16994
|
*/
|
|
16968
16995
|
buildMapInstantaneousPower(formData) {
|
|
16969
|
-
const
|
|
16970
|
-
version: "1.0.0",
|
|
16971
|
-
limitsByInstantaneoustPowerType: []
|
|
16972
|
-
};
|
|
16996
|
+
const effectiveDeviceType = this.getEffectiveDeviceType();
|
|
16973
16997
|
const telemetryType = String(formData.telemetryType || "consumption");
|
|
16974
|
-
|
|
16975
|
-
|
|
16976
|
-
|
|
16977
|
-
|
|
16978
|
-
|
|
16979
|
-
|
|
16980
|
-
|
|
16981
|
-
|
|
16982
|
-
|
|
16983
|
-
|
|
16984
|
-
|
|
16985
|
-
|
|
16986
|
-
|
|
16987
|
-
|
|
16988
|
-
|
|
16989
|
-
|
|
16990
|
-
|
|
16991
|
-
|
|
16992
|
-
|
|
16993
|
-
|
|
16994
|
-
|
|
16995
|
-
|
|
16996
|
-
|
|
16997
|
-
|
|
16998
|
-
|
|
16999
|
-
|
|
17000
|
-
|
|
17001
|
-
|
|
17002
|
-
|
|
17003
|
-
|
|
17004
|
-
|
|
17005
|
-
|
|
17006
|
-
|
|
17007
|
-
|
|
17008
|
-
|
|
17009
|
-
|
|
17010
|
-
|
|
17011
|
-
|
|
17012
|
-
|
|
17013
|
-
|
|
17014
|
-
|
|
17015
|
-
|
|
17016
|
-
topValue: Number(formData.alertLimitUpConsumption) || 0
|
|
17017
|
-
}
|
|
17018
|
-
},
|
|
17019
|
-
{
|
|
17020
|
-
deviceStatusName: "failure",
|
|
17021
|
-
limitsValues: {
|
|
17022
|
-
baseValue: Number(formData.failureLimitDownConsumption) || 0,
|
|
17023
|
-
topValue: Number(formData.failureLimitUpConsumption) || 0
|
|
16998
|
+
const result = {
|
|
16999
|
+
version: "1.0.0",
|
|
17000
|
+
limitsByInstantaneoustPowerType: [
|
|
17001
|
+
{
|
|
17002
|
+
telemetryType,
|
|
17003
|
+
itemsByDeviceType: [
|
|
17004
|
+
{
|
|
17005
|
+
deviceType: effectiveDeviceType,
|
|
17006
|
+
name: `mapInstantaneousPower${this.formatDeviceTypeName(effectiveDeviceType)}`,
|
|
17007
|
+
description: formData.identifier ? `Limites customizados para ${formData.identifier}` : `Limites de pot\xEAncia customizados para ${effectiveDeviceType}`,
|
|
17008
|
+
limitsByDeviceStatus: [
|
|
17009
|
+
{
|
|
17010
|
+
deviceStatusName: "standBy",
|
|
17011
|
+
limitsValues: {
|
|
17012
|
+
baseValue: Number(formData.standbyLimitDownConsumption) || 0,
|
|
17013
|
+
topValue: Number(formData.standbyLimitUpConsumption) || 0
|
|
17014
|
+
}
|
|
17015
|
+
},
|
|
17016
|
+
{
|
|
17017
|
+
deviceStatusName: "normal",
|
|
17018
|
+
limitsValues: {
|
|
17019
|
+
baseValue: Number(formData.normalLimitDownConsumption) || 0,
|
|
17020
|
+
topValue: Number(formData.normalLimitUpConsumption) || 0
|
|
17021
|
+
}
|
|
17022
|
+
},
|
|
17023
|
+
{
|
|
17024
|
+
deviceStatusName: "alert",
|
|
17025
|
+
limitsValues: {
|
|
17026
|
+
baseValue: Number(formData.alertLimitDownConsumption) || 0,
|
|
17027
|
+
topValue: Number(formData.alertLimitUpConsumption) || 0
|
|
17028
|
+
}
|
|
17029
|
+
},
|
|
17030
|
+
{
|
|
17031
|
+
deviceStatusName: "failure",
|
|
17032
|
+
limitsValues: {
|
|
17033
|
+
baseValue: Number(formData.failureLimitDownConsumption) || 0,
|
|
17034
|
+
topValue: Number(formData.failureLimitUpConsumption) || 0
|
|
17035
|
+
}
|
|
17036
|
+
}
|
|
17037
|
+
]
|
|
17038
|
+
}
|
|
17039
|
+
]
|
|
17024
17040
|
}
|
|
17025
|
-
|
|
17026
|
-
|
|
17027
|
-
|
|
17028
|
-
deviceConfig.description = `Limites customizados para ${formData.identifier}`;
|
|
17029
|
-
}
|
|
17030
|
-
console.log("[SettingsPersister] RFC-0080: Built mapInstantaneousPower:", result);
|
|
17041
|
+
]
|
|
17042
|
+
};
|
|
17043
|
+
console.log(`[SettingsPersister] RFC-0086: Built mapInstantaneousPower for deviceType=${effectiveDeviceType}:`, result);
|
|
17031
17044
|
return result;
|
|
17032
17045
|
}
|
|
17033
17046
|
/**
|
|
@@ -17266,6 +17279,8 @@ ${rangeText}`;
|
|
|
17266
17279
|
const apiConfigWithDeviceInfo = {
|
|
17267
17280
|
...params.api,
|
|
17268
17281
|
deviceType: params.deviceType,
|
|
17282
|
+
deviceProfile: params.deviceProfile,
|
|
17283
|
+
// RFC-0086: For 3F_MEDIDOR → deviceProfile resolution
|
|
17269
17284
|
mapInstantaneousPower: params.mapInstantaneousPower
|
|
17270
17285
|
};
|
|
17271
17286
|
this.persister = params.persister || new DefaultSettingsPersister(params.jwtToken, apiConfigWithDeviceInfo);
|
|
@@ -17317,6 +17332,8 @@ ${rangeText}`;
|
|
|
17317
17332
|
this.persister = new DefaultSettingsPersister(this.params.jwtToken, {
|
|
17318
17333
|
...this.params.api,
|
|
17319
17334
|
deviceType: this.params.deviceType,
|
|
17335
|
+
deviceProfile: this.params.deviceProfile,
|
|
17336
|
+
// RFC-0086: For 3F_MEDIDOR → deviceProfile resolution
|
|
17320
17337
|
mapInstantaneousPower: globalMap
|
|
17321
17338
|
});
|
|
17322
17339
|
this.view.updateMapInstantaneousPower(globalMap);
|