myio-js-library 0.1.208 → 0.1.210

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
@@ -12143,6 +12143,10 @@ function renderCardComponentV5({
12143
12143
  const isTemperatureDevice = (deviceType2) => isTemperatureDeviceType(deviceType2);
12144
12144
  const formatCardValue = (value, deviceType2) => {
12145
12145
  const numValue = Number(value) || 0;
12146
+ const category = getDeviceCategory(deviceType2);
12147
+ if (category !== "energy" && category !== "temperature") {
12148
+ console.log(`[template-card-v5] formatCardValue: deviceType=${deviceType2}, category=${category}, isEnergy=${isEnergyDevice(deviceType2)}`);
12149
+ }
12146
12150
  if (isEnergyDevice(deviceType2)) {
12147
12151
  return formatEnergy(numValue);
12148
12152
  } else if (isTemperatureDevice(deviceType2)) {
@@ -22127,12 +22131,13 @@ var WaterTankModal = class {
22127
22131
  * Build context object for callbacks
22128
22132
  */
22129
22133
  buildContext(options) {
22134
+ const displayLevel = options.currentLevelClamped ?? options.currentLevel ?? 0;
22130
22135
  return {
22131
22136
  device: {
22132
22137
  id: options.deviceId,
22133
22138
  label: options.label || options.deviceId,
22134
22139
  type: options.deviceType,
22135
- currentLevel: options.currentLevel
22140
+ currentLevel: displayLevel
22136
22141
  },
22137
22142
  metadata: {
22138
22143
  slaveId: options.slaveId,
@@ -22222,16 +22227,25 @@ var WaterTankModal = class {
22222
22227
  }
22223
22228
  /**
22224
22229
  * Transform raw ThingsBoard response to our data points
22230
+ * RFC-0107: Support displayKey option to choose between water_level or water_percentage
22225
22231
  */
22226
22232
  transformTelemetryData(rawData, keys) {
22227
22233
  const allPoints = [];
22228
- for (const key of keys) {
22234
+ const displayKey = this.options.displayKey || "water_percentage";
22235
+ const prioritizedKeys = displayKey && rawData[displayKey] ? [displayKey, ...keys.filter((k) => k !== displayKey)] : keys;
22236
+ for (const key of prioritizedKeys) {
22229
22237
  if (rawData[key] && Array.isArray(rawData[key])) {
22230
- const keyPoints = rawData[key].map((point) => ({
22231
- ts: point.ts,
22232
- value: typeof point.value === "string" ? parseFloat(point.value) : point.value,
22233
- key
22234
- }));
22238
+ const keyPoints = rawData[key].map((point) => {
22239
+ let value = typeof point.value === "string" ? parseFloat(point.value) : point.value;
22240
+ if (key === "water_percentage" && value <= 1.5) {
22241
+ value = value * 100;
22242
+ }
22243
+ return {
22244
+ ts: point.ts,
22245
+ value,
22246
+ key
22247
+ };
22248
+ });
22235
22249
  allPoints.push(...keyPoints);
22236
22250
  }
22237
22251
  }
@@ -22244,15 +22258,18 @@ var WaterTankModal = class {
22244
22258
  uniquePoints.push(point);
22245
22259
  }
22246
22260
  }
22261
+ console.log(`[WaterTankModal] Transformed ${uniquePoints.length} points, displayKey: ${displayKey}`);
22247
22262
  return uniquePoints;
22248
22263
  }
22249
22264
  /**
22250
22265
  * Calculate summary statistics from telemetry data
22266
+ * RFC-0107: Use clamped level for display
22251
22267
  */
22252
22268
  calculateSummary(telemetry) {
22269
+ const displayLevel = this.options.currentLevelClamped ?? this.options.currentLevel ?? 0;
22253
22270
  if (telemetry.length === 0) {
22254
22271
  return {
22255
- currentLevel: this.options.currentLevel,
22272
+ currentLevel: displayLevel,
22256
22273
  avgLevel: 0,
22257
22274
  minLevel: 0,
22258
22275
  maxLevel: 0,
package/dist/index.d.cts CHANGED
@@ -1729,10 +1729,14 @@ interface OpenDashboardPopupWaterTankOptions {
1729
1729
  deviceType?: string;
1730
1730
  label?: string;
1731
1731
  currentLevel?: number;
1732
+ currentLevelClamped?: number;
1733
+ waterLevel?: number | null;
1734
+ waterPercentage?: number | null;
1732
1735
  slaveId?: string | number;
1733
1736
  centralId?: string;
1734
1737
  ingestionId?: string;
1735
1738
  telemetryKeys?: string[];
1739
+ displayKey?: 'water_level' | 'water_percentage';
1736
1740
  aggregation?: 'NONE' | 'MIN' | 'MAX' | 'AVG' | 'SUM' | 'COUNT';
1737
1741
  limit?: number;
1738
1742
  tbApiHost?: string;
package/dist/index.js CHANGED
@@ -11971,6 +11971,10 @@ function renderCardComponentV5({
11971
11971
  const isTemperatureDevice = (deviceType2) => isTemperatureDeviceType(deviceType2);
11972
11972
  const formatCardValue = (value, deviceType2) => {
11973
11973
  const numValue = Number(value) || 0;
11974
+ const category = getDeviceCategory(deviceType2);
11975
+ if (category !== "energy" && category !== "temperature") {
11976
+ console.log(`[template-card-v5] formatCardValue: deviceType=${deviceType2}, category=${category}, isEnergy=${isEnergyDevice(deviceType2)}`);
11977
+ }
11974
11978
  if (isEnergyDevice(deviceType2)) {
11975
11979
  return formatEnergy(numValue);
11976
11980
  } else if (isTemperatureDevice(deviceType2)) {
@@ -21955,12 +21959,13 @@ var WaterTankModal = class {
21955
21959
  * Build context object for callbacks
21956
21960
  */
21957
21961
  buildContext(options) {
21962
+ const displayLevel = options.currentLevelClamped ?? options.currentLevel ?? 0;
21958
21963
  return {
21959
21964
  device: {
21960
21965
  id: options.deviceId,
21961
21966
  label: options.label || options.deviceId,
21962
21967
  type: options.deviceType,
21963
- currentLevel: options.currentLevel
21968
+ currentLevel: displayLevel
21964
21969
  },
21965
21970
  metadata: {
21966
21971
  slaveId: options.slaveId,
@@ -22050,16 +22055,25 @@ var WaterTankModal = class {
22050
22055
  }
22051
22056
  /**
22052
22057
  * Transform raw ThingsBoard response to our data points
22058
+ * RFC-0107: Support displayKey option to choose between water_level or water_percentage
22053
22059
  */
22054
22060
  transformTelemetryData(rawData, keys) {
22055
22061
  const allPoints = [];
22056
- for (const key of keys) {
22062
+ const displayKey = this.options.displayKey || "water_percentage";
22063
+ const prioritizedKeys = displayKey && rawData[displayKey] ? [displayKey, ...keys.filter((k) => k !== displayKey)] : keys;
22064
+ for (const key of prioritizedKeys) {
22057
22065
  if (rawData[key] && Array.isArray(rawData[key])) {
22058
- const keyPoints = rawData[key].map((point) => ({
22059
- ts: point.ts,
22060
- value: typeof point.value === "string" ? parseFloat(point.value) : point.value,
22061
- key
22062
- }));
22066
+ const keyPoints = rawData[key].map((point) => {
22067
+ let value = typeof point.value === "string" ? parseFloat(point.value) : point.value;
22068
+ if (key === "water_percentage" && value <= 1.5) {
22069
+ value = value * 100;
22070
+ }
22071
+ return {
22072
+ ts: point.ts,
22073
+ value,
22074
+ key
22075
+ };
22076
+ });
22063
22077
  allPoints.push(...keyPoints);
22064
22078
  }
22065
22079
  }
@@ -22072,15 +22086,18 @@ var WaterTankModal = class {
22072
22086
  uniquePoints.push(point);
22073
22087
  }
22074
22088
  }
22089
+ console.log(`[WaterTankModal] Transformed ${uniquePoints.length} points, displayKey: ${displayKey}`);
22075
22090
  return uniquePoints;
22076
22091
  }
22077
22092
  /**
22078
22093
  * Calculate summary statistics from telemetry data
22094
+ * RFC-0107: Use clamped level for display
22079
22095
  */
22080
22096
  calculateSummary(telemetry) {
22097
+ const displayLevel = this.options.currentLevelClamped ?? this.options.currentLevel ?? 0;
22081
22098
  if (telemetry.length === 0) {
22082
22099
  return {
22083
- currentLevel: this.options.currentLevel,
22100
+ currentLevel: displayLevel,
22084
22101
  avgLevel: 0,
22085
22102
  minLevel: 0,
22086
22103
  maxLevel: 0,
@@ -11959,6 +11959,10 @@
11959
11959
  const isTemperatureDevice = (deviceType2) => isTemperatureDeviceType(deviceType2);
11960
11960
  const formatCardValue = (value, deviceType2) => {
11961
11961
  const numValue = Number(value) || 0;
11962
+ const category = getDeviceCategory(deviceType2);
11963
+ if (category !== "energy" && category !== "temperature") {
11964
+ console.log(`[template-card-v5] formatCardValue: deviceType=${deviceType2}, category=${category}, isEnergy=${isEnergyDevice(deviceType2)}`);
11965
+ }
11962
11966
  if (isEnergyDevice(deviceType2)) {
11963
11967
  return formatEnergy(numValue);
11964
11968
  } else if (isTemperatureDevice(deviceType2)) {
@@ -21769,12 +21773,13 @@
21769
21773
  * Build context object for callbacks
21770
21774
  */
21771
21775
  buildContext(options) {
21776
+ const displayLevel = options.currentLevelClamped ?? options.currentLevel ?? 0;
21772
21777
  return {
21773
21778
  device: {
21774
21779
  id: options.deviceId,
21775
21780
  label: options.label || options.deviceId,
21776
21781
  type: options.deviceType,
21777
- currentLevel: options.currentLevel
21782
+ currentLevel: displayLevel
21778
21783
  },
21779
21784
  metadata: {
21780
21785
  slaveId: options.slaveId,
@@ -21864,16 +21869,25 @@
21864
21869
  }
21865
21870
  /**
21866
21871
  * Transform raw ThingsBoard response to our data points
21872
+ * RFC-0107: Support displayKey option to choose between water_level or water_percentage
21867
21873
  */
21868
21874
  transformTelemetryData(rawData, keys) {
21869
21875
  const allPoints = [];
21870
- for (const key of keys) {
21876
+ const displayKey = this.options.displayKey || "water_percentage";
21877
+ const prioritizedKeys = rawData[displayKey] ? [displayKey, ...keys.filter((k) => k !== displayKey)] : keys;
21878
+ for (const key of prioritizedKeys) {
21871
21879
  if (rawData[key] && Array.isArray(rawData[key])) {
21872
- const keyPoints = rawData[key].map((point) => ({
21873
- ts: point.ts,
21874
- value: typeof point.value === "string" ? parseFloat(point.value) : point.value,
21875
- key
21876
- }));
21880
+ const keyPoints = rawData[key].map((point) => {
21881
+ let value = typeof point.value === "string" ? parseFloat(point.value) : point.value;
21882
+ if (key === "water_percentage" && value <= 1.5) {
21883
+ value = value * 100;
21884
+ }
21885
+ return {
21886
+ ts: point.ts,
21887
+ value,
21888
+ key
21889
+ };
21890
+ });
21877
21891
  allPoints.push(...keyPoints);
21878
21892
  }
21879
21893
  }
@@ -21886,15 +21900,18 @@
21886
21900
  uniquePoints.push(point);
21887
21901
  }
21888
21902
  }
21903
+ console.log(`[WaterTankModal] Transformed ${uniquePoints.length} points, displayKey: ${displayKey}`);
21889
21904
  return uniquePoints;
21890
21905
  }
21891
21906
  /**
21892
21907
  * Calculate summary statistics from telemetry data
21908
+ * RFC-0107: Use clamped level for display
21893
21909
  */
21894
21910
  calculateSummary(telemetry) {
21911
+ const displayLevel = this.options.currentLevelClamped ?? this.options.currentLevel ?? 0;
21895
21912
  if (telemetry.length === 0) {
21896
21913
  return {
21897
- currentLevel: this.options.currentLevel,
21914
+ currentLevel: displayLevel,
21898
21915
  avgLevel: 0,
21899
21916
  minLevel: 0,
21900
21917
  maxLevel: 0,