Skip to content

Commit a2d8711

Browse files
authored
Update predbat-table-card.js
Added support for lower power mode
1 parent 67f7266 commit a2d8711

File tree

1 file changed

+23
-11
lines changed

1 file changed

+23
-11
lines changed

predbat-table-card.js

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,7 @@ class PredbatTableCard extends HTMLElement {
360360
}
361361

362362

363-
if((theItem.value === "Both" || theItem.value === "Both-Idle" || theItem.value === "Both-Chg" || theItem.value === "Both-Dis") && column === "state-column"){
363+
if((theItem.value === "Both" || theItem.value === "Both-Idle" || theItem.value === "Both-Chg" || theItem.value === "Both-Dis" || theItem.value === "Both-Dis-Snail") && column === "state-column"){
364364

365365
newCell.style.minWidth = "186px";
366366
if(this.config.use_friendly_states === true)
@@ -369,7 +369,7 @@ class PredbatTableCard extends HTMLElement {
369369
newCell.style.paddingRight = "0px";
370370

371371
let chargeString = "Charge";
372-
if(theItem.value === "Both-Chg" || theItem.value === "Both-Dis" || theItem.value === "Both-Idle")
372+
if(theItem.value === "Both-Chg" || theItem.value === "Both-Dis" || theItem.value === "Both-Idle" || theItem.value === "Both-Dis-Snail")
373373
chargeString = "";
374374

375375
let dischargeString = "Export";
@@ -383,7 +383,7 @@ class PredbatTableCard extends HTMLElement {
383383
dischargeString = "Exp";
384384
}
385385

386-
if(theItem.value === "Both-Chg" || theItem.value === "Both-Dis" || theItem.value === "Both-Idle") {
386+
if(theItem.value === "Both-Chg" || theItem.value === "Both-Dis" || theItem.value === "Both-Idle" || theItem.value === "Both-Dis-Snail") {
387387
dischargeString = "Exp";
388388
}
389389

@@ -407,7 +407,7 @@ class PredbatTableCard extends HTMLElement {
407407
chargeString = "Plnd Chg";
408408
else if(theItem.value === "Both-Chg")
409409
chargeString = "Chg";
410-
else if(theItem.value === "Both-Dis")
410+
else if(theItem.value === "Both-Dis" || theItem.value === "Both-Dis-Snail")
411411
chargeString = "Dis";
412412

413413
dischargeString = "Plnd Dis";
@@ -418,7 +418,7 @@ class PredbatTableCard extends HTMLElement {
418418

419419
let chargeBackgroundColor = "background-color:#3AEE85;";
420420
let chargeTextColor = "color: #000000;";
421-
if(theItem.value === "Both-Idle" || theItem.value === "Both-Dis" || theItem.value === "Both-Chg"){
421+
if(theItem.value === "Both-Idle" || theItem.value === "Both-Dis" || theItem.value === "Both-Chg" || theItem.value === "Both-Dis-Snail"){
422422
chargeBackgroundColor = "";
423423
chargeTextColor = "";
424424
}
@@ -427,12 +427,17 @@ class PredbatTableCard extends HTMLElement {
427427
chargeIcon = '<ha-icon icon="mdi:arrow-up-thin" style="margin: 0 0 0 -5px"></ha-icon>';
428428
else if(theItem.value === "Both-Idle")
429429
chargeIcon = '<ha-icon icon="mdi:arrow-right-thin" style="margin: 0 0 0 -3px"></ha-icon>';
430-
else if(theItem.value === "Both-Dis")
430+
else if(theItem.value === "Both-Dis" || theItem.value === "Both-Dis-Snail")
431431
chargeIcon = '<ha-icon icon="mdi:arrow-down-thin" style="margin: 0 0 0 -5px"></ha-icon>';
432+
433+
let snail = ``;
434+
if(theItem.value === "Both-Dis-Snail")
435+
snail = `<ha-icon icon="mdi:snail" title="Low Power Mode" style="--mdc-icon-size: 14px;"></ha-icon>`;
436+
432437

433438
newCell.innerHTML = `<div style="width: 100%; height: 100%;" id="${theItem.value}">
434439
<div style='${chargeBackgroundColor} width: 50%; height: 100%; float: left; display: flex; align-items: center; justify-content: center; ${chargeTextColor}'>${chargeString}${chargeIcon}</div>
435-
<div style='background-color:#FFFF00; width: 50%; height: 100%; float: left; display: flex; align-items: center; justify-content: center; color: #000000;'>${dischargeString}<ha-icon icon="mdi:arrow-down-thin" style="margin: 0 0 0 -5px"></ha-icon></div>
440+
<div style='background-color:#FFFF00; width: 50%; height: 100%; float: left; display: flex; align-items: center; justify-content: center; color: #000000;'>${dischargeString}<ha-icon icon="mdi:arrow-down-thin" style="margin: 0 0 0 -5px"></ha-icon>${snail}</div>
436441
</div>`;
437442

438443
} else if(column === "import-export-column"){
@@ -641,6 +646,7 @@ class PredbatTableCard extends HTMLElement {
641646

642647
// alert ⚠
643648
//theItem.value = "⚠Chrg↗";
649+
// Exp↘🐌
644650

645651
newContent = theItem.value.replace(/[]/g, '').trim();
646652

@@ -693,15 +699,17 @@ class PredbatTableCard extends HTMLElement {
693699
newCell.setAttribute('style', 'color: var(--energy-battery-in-color)');
694700
} else if(newContent === "Both"){
695701
additionalArrow = '<ha-icon icon="mdi:battery-charging-100" style="color: var(--energy-battery-in-color); --mdc-icon-size: 22px;" title="Planned Charge" class="icons"></ha-icon><ha-icon icon="mdi:battery-minus" style="color: var(--energy-battery-out-color);" title="Planned Export" class="icons"></ha-icon>';
696-
} else if(newContent === "Both-Idle" || newContent === "Both-Chg" || newContent === "Both-Dis"){
702+
} else if(newContent === "Both-Idle" || newContent === "Both-Chg" || newContent === "Both-Dis" || newContent === "Both-Dis-Snail"){
697703
let houseColor = "#000000";
698704
if(this.getLightMode(darkMode))
699705
houseColor = "#FFFFFF";
700706

701707
this.getLightMode(darkMode)
702708
additionalArrow = `<ha-icon icon="mdi:home-lightning-bolt" style="color: ${houseColor}" title="Idle" style="--mdc-icon-size: 22px;"></ha-icon><ha-icon icon="mdi:battery-minus" style="color: var(--energy-battery-out-color);" title="Planned Export" class="icons"></ha-icon>`;
709+
if(newContent === "Both-Dis-Snail")
710+
additionalArrow += `<ha-icon icon="mdi:snail" title="Low Power Mode" style="--mdc-icon-size: 18px;"></ha-icon>`;
703711
}
704-
712+
705713
newCell.innerHTML = `<div class="iconContainer">${additionalArrow}</div>`;
706714

707715
} else if(column === "limit-column"){
@@ -712,7 +720,8 @@ class PredbatTableCard extends HTMLElement {
712720
let debugString = theItem.value;
713721

714722
if (theItem.value.includes("(") || theItem.value.includes(")")) {
715-
const match = theItem.value.match(/(\d+)\s*\((\d+)\)/);
723+
const match = theItem.value.match(/(\d+)\s*\((\d+(?:\.\d+)?)\)/);
724+
console.log("match: " + match);
716725
// match[1]
717726
if(match[1] != match[2]){
718727
debugSVG = `<svg version="1.1" width="26" height="26" id="limitSVG">
@@ -1276,7 +1285,10 @@ class PredbatTableCard extends HTMLElement {
12761285
newTRObject[headerClassesArray[3]] = {"value": "Both-Chg", "color": "green"};
12771286
else if(tdElement.innerHTML.trim() === "→")
12781287
newTRObject[headerClassesArray[3]] = {"value": "Both-Idle", "color": "green"};
1279-
1288+
}
1289+
if(tdIndex === 4){
1290+
if(tdElement.innerHTML.includes("🐌"))
1291+
newTRObject[headerClassesArray[3]] = {"value": "Both-Dis-Snail", "color": "green"};
12801292
}
12811293
});
12821294
}

0 commit comments

Comments
 (0)