myio-js-library 0.1.151 → 0.1.153

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
@@ -3950,14 +3950,30 @@ var CSS_STRING = `
3950
3950
  --myio-card-bg: #fff;
3951
3951
  --myio-card-border: #e9eef5;
3952
3952
 
3953
- --myio-chip-ok-bg: #e8f7ff;
3954
- --myio-chip-ok-fg: #007ecc;
3955
- --myio-chip-alert-bg: #fff4e5;
3956
- --myio-chip-alert-fg: #b96b00;
3957
- --myio-chip-failure-bg: #ffeaea;
3958
- --myio-chip-failure-fg: #b71c1c;
3953
+ /* Status colors - Normal/Power On (blue) */
3954
+ --myio-chip-ok-bg: #dbeafe;
3955
+ --myio-chip-ok-fg: #1d4ed8;
3956
+ --myio-border-ok: rgba(59, 130, 246, 0.4);
3957
+
3958
+ /* Status colors - Standby (green) */
3959
+ --myio-chip-standby-bg: #dcfce7;
3960
+ --myio-chip-standby-fg: #15803d;
3961
+ --myio-border-standby: rgba(34, 197, 94, 0.4);
3962
+
3963
+ /* Status colors - Alert/Warning (yellow) */
3964
+ --myio-chip-alert-bg: #fef3c7;
3965
+ --myio-chip-alert-fg: #b45309;
3966
+ --myio-border-alert: rgba(245, 158, 11, 0.5);
3967
+
3968
+ /* Status colors - Failure (red) */
3969
+ --myio-chip-failure-bg: #fee2e2;
3970
+ --myio-chip-failure-fg: #b91c1c;
3971
+ --myio-border-failure: rgba(239, 68, 68, 0.5);
3972
+
3973
+ /* Status colors - Offline (gray) */
3959
3974
  --myio-chip-offline-bg: #f1f5f9;
3960
3975
  --myio-chip-offline-fg: #64748b;
3976
+ --myio-border-offline: rgba(100, 116, 139, 0.4);
3961
3977
 
3962
3978
  --myio-text-1: #0f172a;
3963
3979
  --myio-text-2: #4b5563;
@@ -4012,15 +4028,25 @@ var CSS_STRING = `
4012
4028
  box-shadow: 0 16px 48px rgba(0, 224, 158, 0.3), 0 8px 16px rgba(0, 224, 158, 0.2);
4013
4029
  }
4014
4030
 
4015
- /* Alert and failure states */
4031
+ /* Card border states based on device status */
4032
+ .myio-ho-card.is-ok {
4033
+ border-color: var(--myio-border-ok);
4034
+ box-shadow: 0 0 0 2px var(--myio-border-ok), var(--myio-card-shadow);
4035
+ }
4036
+
4037
+ .myio-ho-card.is-standby {
4038
+ border-color: var(--myio-border-standby);
4039
+ box-shadow: 0 0 0 2px var(--myio-border-standby), var(--myio-card-shadow);
4040
+ }
4041
+
4016
4042
  .myio-ho-card.is-alert {
4017
- border-color: var(--myio-badge-border);
4018
- box-shadow: 0 0 0 1px var(--myio-badge-border), var(--myio-card-shadow);
4043
+ border-color: var(--myio-border-alert);
4044
+ box-shadow: 0 0 0 2px var(--myio-border-alert), var(--myio-card-shadow);
4019
4045
  }
4020
4046
 
4021
4047
  .myio-ho-card.is-failure {
4022
- border-color: var(--myio-badge-border-failure);
4023
- box-shadow: 0 0 0 1px var(--myio-badge-border-failure), var(--myio-card-shadow);
4048
+ border-color: var(--myio-border-failure);
4049
+ box-shadow: 0 0 0 2px var(--myio-border-failure), var(--myio-card-shadow);
4024
4050
  }
4025
4051
 
4026
4052
  /* Header section */
@@ -4055,21 +4081,10 @@ var CSS_STRING = `
4055
4081
 
4056
4082
  /* Adicione estas duas novas regras ao seu CSS_STRING */
4057
4083
 
4058
- /* Estado Offline - Apenas borda do card */
4084
+ /* Estado Offline - borda cinza */
4059
4085
  .myio-ho-card.is-offline {
4060
- border-color: rgba(100, 116, 139, 0.4);
4061
- box-shadow: 0 0 0 1px rgba(100, 116, 139, 0.4), var(--myio-card-shadow);
4062
- }
4063
-
4064
- /* Regras que j\xE1 existem (mantenha-as) */
4065
- .myio-ho-card.is-alert {
4066
- border-color: var(--myio-badge-border);
4067
- box-shadow: 0 0 0 1px var(--myio-badge-border), var(--myio-card-shadow);
4068
- }
4069
-
4070
- .myio-ho-card.is-failure {
4071
- border-color: var(--myio-badge-border-failure);
4072
- box-shadow: 0 0 0 1px var(--myio-badge-border-failure), var(--myio-card-shadow);
4086
+ border-color: var(--myio-border-offline);
4087
+ box-shadow: 0 0 0 2px var(--myio-border-offline), var(--myio-card-shadow);
4073
4088
  }
4074
4089
 
4075
4090
  .myio-ho-card__name {
@@ -4441,6 +4456,11 @@ var CSS_STRING = `
4441
4456
  color: var(--myio-chip-ok-fg);
4442
4457
  }
4443
4458
 
4459
+ .chip--standby {
4460
+ background: var(--myio-chip-standby-bg);
4461
+ color: var(--myio-chip-standby-fg);
4462
+ }
4463
+
4444
4464
  .chip--alert {
4445
4465
  background: var(--myio-chip-alert-bg);
4446
4466
  color: var(--myio-chip-alert-fg);
@@ -4452,8 +4472,37 @@ var CSS_STRING = `
4452
4472
  }
4453
4473
 
4454
4474
  .chip--offline {
4455
- background: #e37171 !important;
4456
- color: #ffffff !important;
4475
+ background: var(--myio-chip-offline-bg);
4476
+ color: var(--myio-chip-offline-fg);
4477
+ }
4478
+
4479
+ /* Status indicator dot for power metric */
4480
+ .status-dot {
4481
+ width: 8px;
4482
+ height: 8px;
4483
+ border-radius: 50%;
4484
+ flex-shrink: 0;
4485
+ background: var(--myio-chip-offline-fg);
4486
+ }
4487
+
4488
+ .status-dot.dot--ok {
4489
+ background: var(--myio-chip-ok-fg);
4490
+ }
4491
+
4492
+ .status-dot.dot--standby {
4493
+ background: var(--myio-chip-standby-fg);
4494
+ }
4495
+
4496
+ .status-dot.dot--alert {
4497
+ background: var(--myio-chip-alert-fg);
4498
+ }
4499
+
4500
+ .status-dot.dot--failure {
4501
+ background: var(--myio-chip-failure-fg);
4502
+ }
4503
+
4504
+ .status-dot.dot--offline {
4505
+ background: var(--myio-chip-offline-fg);
4457
4506
  }
4458
4507
 
4459
4508
  /* Primary metric */
@@ -4818,6 +4867,19 @@ function normalizeParams(params) {
4818
4867
  function getIconSvg(deviceType) {
4819
4868
  return ICON_MAP[deviceType] || ICON_MAP.DEFAULT;
4820
4869
  }
4870
+ function formatPower(valueInWatts) {
4871
+ if (valueInWatts === null || valueInWatts === void 0 || isNaN(valueInWatts)) {
4872
+ return { num: "-", unit: "" };
4873
+ }
4874
+ const val = Number(valueInWatts);
4875
+ if (val >= 1e3) {
4876
+ const kw = Math.ceil(val / 1e3 * 100) / 100;
4877
+ return { num: kw.toFixed(2), unit: "kW" };
4878
+ } else {
4879
+ const w = Math.ceil(val);
4880
+ return { num: w.toString(), unit: "W" };
4881
+ }
4882
+ }
4821
4883
  function formatValueByDomain(value, domain) {
4822
4884
  if (domain === "water") {
4823
4885
  return formatWaterVolumeM3(value);
@@ -4856,22 +4918,43 @@ function getStatusInfo(deviceStatus, i18n) {
4856
4918
  function getCardStateClass(deviceStatus) {
4857
4919
  switch (deviceStatus) {
4858
4920
  case DeviceStatusType.POWER_ON:
4859
- return "";
4860
- case DeviceStatusType.NO_INFO:
4861
- return "is-offline";
4862
- case DeviceStatusType.WARNING:
4921
+ return "is-ok";
4922
+ // Blue border
4863
4923
  case DeviceStatusType.STANDBY:
4924
+ return "is-standby";
4925
+ // Green border
4926
+ case DeviceStatusType.WARNING:
4864
4927
  case DeviceStatusType.MAINTENANCE:
4865
4928
  return "is-alert";
4929
+ // Yellow border
4866
4930
  case DeviceStatusType.FAILURE:
4867
4931
  case DeviceStatusType.POWER_OFF:
4868
4932
  return "is-failure";
4933
+ // Red border
4934
+ case DeviceStatusType.NO_INFO:
4869
4935
  case DeviceStatusType.NOT_INSTALLED:
4870
4936
  return "is-offline";
4937
+ // Gray border
4871
4938
  default:
4872
4939
  return "";
4873
4940
  }
4874
4941
  }
4942
+ function getStatusDotClass(deviceStatus) {
4943
+ switch (deviceStatus) {
4944
+ case DeviceStatusType.POWER_ON:
4945
+ return "dot--ok";
4946
+ case DeviceStatusType.STANDBY:
4947
+ return "dot--standby";
4948
+ case DeviceStatusType.WARNING:
4949
+ case DeviceStatusType.MAINTENANCE:
4950
+ return "dot--alert";
4951
+ case DeviceStatusType.FAILURE:
4952
+ case DeviceStatusType.POWER_OFF:
4953
+ return "dot--failure";
4954
+ default:
4955
+ return "dot--offline";
4956
+ }
4957
+ }
4875
4958
  function buildDOM(state) {
4876
4959
  const { entityObject, i18n, enableSelection, enableDragDrop } = state;
4877
4960
  const root = document.createElement("div");
@@ -5003,10 +5086,9 @@ function buildDOM(state) {
5003
5086
  footer.appendChild(opTimeMetric);
5004
5087
  const powerMetric = document.createElement("div");
5005
5088
  powerMetric.className = "metric";
5006
- const powerIcon = document.createElement("i");
5007
- powerIcon.className = "ico ico-power";
5008
- powerIcon.innerHTML = Icons.dot;
5009
- powerMetric.appendChild(powerIcon);
5089
+ const statusDot = document.createElement("span");
5090
+ statusDot.className = "status-dot";
5091
+ powerMetric.appendChild(statusDot);
5010
5092
  const powerLabel = document.createElement("div");
5011
5093
  powerLabel.className = "label";
5012
5094
  powerLabel.textContent = i18n.instantaneous_power || "Pot\xEAncia";
@@ -5071,7 +5153,13 @@ function paint(root, state) {
5071
5153
  const powerVal = root.querySelector(".myio-ho-card__footer .metric:nth-child(2) .val");
5072
5154
  if (powerVal) {
5073
5155
  const instantPower = entityObject.instantaneousPower ?? entityObject.consumption_power ?? null;
5074
- powerVal.textContent = instantPower !== null ? `${Number(instantPower).toFixed(2)} kW` : "-";
5156
+ const powerFormatted = formatPower(instantPower);
5157
+ powerVal.textContent = instantPower !== null ? `${powerFormatted.num} ${powerFormatted.unit}` : "-";
5158
+ }
5159
+ const statusDot = root.querySelector(".myio-ho-card__footer .metric:nth-child(2) .status-dot");
5160
+ if (statusDot) {
5161
+ const dotClass = getStatusDotClass(entityObject.deviceStatus);
5162
+ statusDot.className = `status-dot ${dotClass}`;
5075
5163
  }
5076
5164
  }
5077
5165
  function bindEvents(root, state, callbacks) {
package/dist/index.js CHANGED
@@ -3842,14 +3842,30 @@ var CSS_STRING = `
3842
3842
  --myio-card-bg: #fff;
3843
3843
  --myio-card-border: #e9eef5;
3844
3844
 
3845
- --myio-chip-ok-bg: #e8f7ff;
3846
- --myio-chip-ok-fg: #007ecc;
3847
- --myio-chip-alert-bg: #fff4e5;
3848
- --myio-chip-alert-fg: #b96b00;
3849
- --myio-chip-failure-bg: #ffeaea;
3850
- --myio-chip-failure-fg: #b71c1c;
3845
+ /* Status colors - Normal/Power On (blue) */
3846
+ --myio-chip-ok-bg: #dbeafe;
3847
+ --myio-chip-ok-fg: #1d4ed8;
3848
+ --myio-border-ok: rgba(59, 130, 246, 0.4);
3849
+
3850
+ /* Status colors - Standby (green) */
3851
+ --myio-chip-standby-bg: #dcfce7;
3852
+ --myio-chip-standby-fg: #15803d;
3853
+ --myio-border-standby: rgba(34, 197, 94, 0.4);
3854
+
3855
+ /* Status colors - Alert/Warning (yellow) */
3856
+ --myio-chip-alert-bg: #fef3c7;
3857
+ --myio-chip-alert-fg: #b45309;
3858
+ --myio-border-alert: rgba(245, 158, 11, 0.5);
3859
+
3860
+ /* Status colors - Failure (red) */
3861
+ --myio-chip-failure-bg: #fee2e2;
3862
+ --myio-chip-failure-fg: #b91c1c;
3863
+ --myio-border-failure: rgba(239, 68, 68, 0.5);
3864
+
3865
+ /* Status colors - Offline (gray) */
3851
3866
  --myio-chip-offline-bg: #f1f5f9;
3852
3867
  --myio-chip-offline-fg: #64748b;
3868
+ --myio-border-offline: rgba(100, 116, 139, 0.4);
3853
3869
 
3854
3870
  --myio-text-1: #0f172a;
3855
3871
  --myio-text-2: #4b5563;
@@ -3904,15 +3920,25 @@ var CSS_STRING = `
3904
3920
  box-shadow: 0 16px 48px rgba(0, 224, 158, 0.3), 0 8px 16px rgba(0, 224, 158, 0.2);
3905
3921
  }
3906
3922
 
3907
- /* Alert and failure states */
3923
+ /* Card border states based on device status */
3924
+ .myio-ho-card.is-ok {
3925
+ border-color: var(--myio-border-ok);
3926
+ box-shadow: 0 0 0 2px var(--myio-border-ok), var(--myio-card-shadow);
3927
+ }
3928
+
3929
+ .myio-ho-card.is-standby {
3930
+ border-color: var(--myio-border-standby);
3931
+ box-shadow: 0 0 0 2px var(--myio-border-standby), var(--myio-card-shadow);
3932
+ }
3933
+
3908
3934
  .myio-ho-card.is-alert {
3909
- border-color: var(--myio-badge-border);
3910
- box-shadow: 0 0 0 1px var(--myio-badge-border), var(--myio-card-shadow);
3935
+ border-color: var(--myio-border-alert);
3936
+ box-shadow: 0 0 0 2px var(--myio-border-alert), var(--myio-card-shadow);
3911
3937
  }
3912
3938
 
3913
3939
  .myio-ho-card.is-failure {
3914
- border-color: var(--myio-badge-border-failure);
3915
- box-shadow: 0 0 0 1px var(--myio-badge-border-failure), var(--myio-card-shadow);
3940
+ border-color: var(--myio-border-failure);
3941
+ box-shadow: 0 0 0 2px var(--myio-border-failure), var(--myio-card-shadow);
3916
3942
  }
3917
3943
 
3918
3944
  /* Header section */
@@ -3947,21 +3973,10 @@ var CSS_STRING = `
3947
3973
 
3948
3974
  /* Adicione estas duas novas regras ao seu CSS_STRING */
3949
3975
 
3950
- /* Estado Offline - Apenas borda do card */
3976
+ /* Estado Offline - borda cinza */
3951
3977
  .myio-ho-card.is-offline {
3952
- border-color: rgba(100, 116, 139, 0.4);
3953
- box-shadow: 0 0 0 1px rgba(100, 116, 139, 0.4), var(--myio-card-shadow);
3954
- }
3955
-
3956
- /* Regras que j\xE1 existem (mantenha-as) */
3957
- .myio-ho-card.is-alert {
3958
- border-color: var(--myio-badge-border);
3959
- box-shadow: 0 0 0 1px var(--myio-badge-border), var(--myio-card-shadow);
3960
- }
3961
-
3962
- .myio-ho-card.is-failure {
3963
- border-color: var(--myio-badge-border-failure);
3964
- box-shadow: 0 0 0 1px var(--myio-badge-border-failure), var(--myio-card-shadow);
3978
+ border-color: var(--myio-border-offline);
3979
+ box-shadow: 0 0 0 2px var(--myio-border-offline), var(--myio-card-shadow);
3965
3980
  }
3966
3981
 
3967
3982
  .myio-ho-card__name {
@@ -4333,6 +4348,11 @@ var CSS_STRING = `
4333
4348
  color: var(--myio-chip-ok-fg);
4334
4349
  }
4335
4350
 
4351
+ .chip--standby {
4352
+ background: var(--myio-chip-standby-bg);
4353
+ color: var(--myio-chip-standby-fg);
4354
+ }
4355
+
4336
4356
  .chip--alert {
4337
4357
  background: var(--myio-chip-alert-bg);
4338
4358
  color: var(--myio-chip-alert-fg);
@@ -4344,8 +4364,37 @@ var CSS_STRING = `
4344
4364
  }
4345
4365
 
4346
4366
  .chip--offline {
4347
- background: #e37171 !important;
4348
- color: #ffffff !important;
4367
+ background: var(--myio-chip-offline-bg);
4368
+ color: var(--myio-chip-offline-fg);
4369
+ }
4370
+
4371
+ /* Status indicator dot for power metric */
4372
+ .status-dot {
4373
+ width: 8px;
4374
+ height: 8px;
4375
+ border-radius: 50%;
4376
+ flex-shrink: 0;
4377
+ background: var(--myio-chip-offline-fg);
4378
+ }
4379
+
4380
+ .status-dot.dot--ok {
4381
+ background: var(--myio-chip-ok-fg);
4382
+ }
4383
+
4384
+ .status-dot.dot--standby {
4385
+ background: var(--myio-chip-standby-fg);
4386
+ }
4387
+
4388
+ .status-dot.dot--alert {
4389
+ background: var(--myio-chip-alert-fg);
4390
+ }
4391
+
4392
+ .status-dot.dot--failure {
4393
+ background: var(--myio-chip-failure-fg);
4394
+ }
4395
+
4396
+ .status-dot.dot--offline {
4397
+ background: var(--myio-chip-offline-fg);
4349
4398
  }
4350
4399
 
4351
4400
  /* Primary metric */
@@ -4710,6 +4759,19 @@ function normalizeParams(params) {
4710
4759
  function getIconSvg(deviceType) {
4711
4760
  return ICON_MAP[deviceType] || ICON_MAP.DEFAULT;
4712
4761
  }
4762
+ function formatPower(valueInWatts) {
4763
+ if (valueInWatts === null || valueInWatts === void 0 || isNaN(valueInWatts)) {
4764
+ return { num: "-", unit: "" };
4765
+ }
4766
+ const val = Number(valueInWatts);
4767
+ if (val >= 1e3) {
4768
+ const kw = Math.ceil(val / 1e3 * 100) / 100;
4769
+ return { num: kw.toFixed(2), unit: "kW" };
4770
+ } else {
4771
+ const w = Math.ceil(val);
4772
+ return { num: w.toString(), unit: "W" };
4773
+ }
4774
+ }
4713
4775
  function formatValueByDomain(value, domain) {
4714
4776
  if (domain === "water") {
4715
4777
  return formatWaterVolumeM3(value);
@@ -4748,22 +4810,43 @@ function getStatusInfo(deviceStatus, i18n) {
4748
4810
  function getCardStateClass(deviceStatus) {
4749
4811
  switch (deviceStatus) {
4750
4812
  case DeviceStatusType.POWER_ON:
4751
- return "";
4752
- case DeviceStatusType.NO_INFO:
4753
- return "is-offline";
4754
- case DeviceStatusType.WARNING:
4813
+ return "is-ok";
4814
+ // Blue border
4755
4815
  case DeviceStatusType.STANDBY:
4816
+ return "is-standby";
4817
+ // Green border
4818
+ case DeviceStatusType.WARNING:
4756
4819
  case DeviceStatusType.MAINTENANCE:
4757
4820
  return "is-alert";
4821
+ // Yellow border
4758
4822
  case DeviceStatusType.FAILURE:
4759
4823
  case DeviceStatusType.POWER_OFF:
4760
4824
  return "is-failure";
4825
+ // Red border
4826
+ case DeviceStatusType.NO_INFO:
4761
4827
  case DeviceStatusType.NOT_INSTALLED:
4762
4828
  return "is-offline";
4829
+ // Gray border
4763
4830
  default:
4764
4831
  return "";
4765
4832
  }
4766
4833
  }
4834
+ function getStatusDotClass(deviceStatus) {
4835
+ switch (deviceStatus) {
4836
+ case DeviceStatusType.POWER_ON:
4837
+ return "dot--ok";
4838
+ case DeviceStatusType.STANDBY:
4839
+ return "dot--standby";
4840
+ case DeviceStatusType.WARNING:
4841
+ case DeviceStatusType.MAINTENANCE:
4842
+ return "dot--alert";
4843
+ case DeviceStatusType.FAILURE:
4844
+ case DeviceStatusType.POWER_OFF:
4845
+ return "dot--failure";
4846
+ default:
4847
+ return "dot--offline";
4848
+ }
4849
+ }
4767
4850
  function buildDOM(state) {
4768
4851
  const { entityObject, i18n, enableSelection, enableDragDrop } = state;
4769
4852
  const root = document.createElement("div");
@@ -4895,10 +4978,9 @@ function buildDOM(state) {
4895
4978
  footer.appendChild(opTimeMetric);
4896
4979
  const powerMetric = document.createElement("div");
4897
4980
  powerMetric.className = "metric";
4898
- const powerIcon = document.createElement("i");
4899
- powerIcon.className = "ico ico-power";
4900
- powerIcon.innerHTML = Icons.dot;
4901
- powerMetric.appendChild(powerIcon);
4981
+ const statusDot = document.createElement("span");
4982
+ statusDot.className = "status-dot";
4983
+ powerMetric.appendChild(statusDot);
4902
4984
  const powerLabel = document.createElement("div");
4903
4985
  powerLabel.className = "label";
4904
4986
  powerLabel.textContent = i18n.instantaneous_power || "Pot\xEAncia";
@@ -4963,7 +5045,13 @@ function paint(root, state) {
4963
5045
  const powerVal = root.querySelector(".myio-ho-card__footer .metric:nth-child(2) .val");
4964
5046
  if (powerVal) {
4965
5047
  const instantPower = entityObject.instantaneousPower ?? entityObject.consumption_power ?? null;
4966
- powerVal.textContent = instantPower !== null ? `${Number(instantPower).toFixed(2)} kW` : "-";
5048
+ const powerFormatted = formatPower(instantPower);
5049
+ powerVal.textContent = instantPower !== null ? `${powerFormatted.num} ${powerFormatted.unit}` : "-";
5050
+ }
5051
+ const statusDot = root.querySelector(".myio-ho-card__footer .metric:nth-child(2) .status-dot");
5052
+ if (statusDot) {
5053
+ const dotClass = getStatusDotClass(entityObject.deviceStatus);
5054
+ statusDot.className = `status-dot ${dotClass}`;
4967
5055
  }
4968
5056
  }
4969
5057
  function bindEvents(root, state, callbacks) {