Skip to content

Commit 8e4e16f

Browse files
authored
Update predbat-table-card.js
added support for "export" terminology
1 parent 4a36d99 commit 8e4e16f

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

predbat-table-card.js

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,8 @@ class PredbatTableCard extends HTMLElement {
8080
}
8181

8282
processAndRender(hass){
83+
84+
8385
const entityId = this.config.entity;
8486
const state = hass.states[entityId];
8587
const stateStr = state ? state.state : "unavailable";
@@ -382,7 +384,7 @@ class PredbatTableCard extends HTMLElement {
382384
else if(theItem.value === "Both-Dis")
383385
chargeString = "Discharging";
384386

385-
dischargeString = "Planned Discharge";
387+
dischargeString = "Planned Export";
386388
} else if(this.config.use_friendly_states === true && this.isSmallScreen() === true){
387389
if(theItem.value === "Both")
388390
chargeString = "Plnd Chg";
@@ -454,9 +456,13 @@ class PredbatTableCard extends HTMLElement {
454456
friendlyText = friendlyText.replace('Force Dischrg', 'Discharge');
455457
friendlyText = friendlyText.replace('Force Charge', 'Charge');
456458

459+
457460
if(theItem.value.includes("ⅎ")){
461+
friendlyText = friendlyText.replace('Exp', 'Export');
462+
458463
friendlyText = "Manually Forced " + friendlyText;
459-
if(!friendlyText.includes("Charge") && !friendlyText.includes("Discharge"))
464+
465+
if(!friendlyText.includes("Charge") && !friendlyText.includes("Discharge") && !friendlyText.includes("Export"))
460466
friendlyText = friendlyText + "Idle";
461467
friendlyText = friendlyText.replace('ⅎ', '');
462468
} else {
@@ -472,7 +478,7 @@ class PredbatTableCard extends HTMLElement {
472478
friendlyText = friendlyText.replace('FreezeChrg', 'Maintaining SOC'); //FreezeChrg
473479
friendlyText = friendlyText.replace('HoldChrg', 'Maintaining SOC'); //HoldChrg
474480
friendlyText = friendlyText.includes("NoCharge") ? friendlyText.replace('NoCharge','Charge to "limit"') : friendlyText.replace('Charge', 'Planned Charge');
475-
friendlyText = friendlyText.replace('Discharge', 'Planned Discharge'); //Discharge
481+
friendlyText = friendlyText.replace('Discharge', 'Planned Export'); //Discharge
476482

477483
}
478484

@@ -609,7 +615,7 @@ class PredbatTableCard extends HTMLElement {
609615
newCell.setAttribute('style', `color: ${theItem.color}`);
610616
} else if(newContent === "Discharge"){
611617
// use force discharge icon
612-
let tooltip = "Planned Discharge";
618+
let tooltip = "Planned Export";
613619
if(theItem.value.includes("ⅎ"))
614620
tooltip = "Manual Forced Discharge";
615621

@@ -632,14 +638,14 @@ class PredbatTableCard extends HTMLElement {
632638
additionalArrow += `<ha-icon icon="mdi:hand-back-right-outline" title="${tooltip}" style="--mdc-icon-size: 22px;"></ha-icon>`;
633639
newCell.setAttribute('style', 'color: var(--energy-battery-in-color)');
634640
} else if(newContent === "Both"){
635-
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 Discharge" class="icons"></ha-icon>';
641+
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>';
636642
} else if(newContent === "Both-Idle" || newContent === "Both-Chg" || newContent === "Both-Dis"){
637643
let houseColor = "#000000";
638644
if(this.getLightMode(darkMode))
639645
houseColor = "#FFFFFF";
640646

641647
this.getLightMode(darkMode)
642-
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 Discharge" class="icons"></ha-icon>`;
648+
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>`;
643649
}
644650

645651
newCell.innerHTML = `<div class="iconContainer">${additionalArrow}</div>`;
@@ -753,6 +759,10 @@ class PredbatTableCard extends HTMLElement {
753759
newState = "Charge";
754760
if(status === "FrzDis")
755761
newState = "FreezeDis";
762+
if(status === "FrzExp")
763+
newState = "FreezeDis";
764+
if(status === "Exp")
765+
newState = "Discharge";
756766
if(status === "Dis")
757767
newState = "Discharge";
758768
if(status === "Dis ⅎ")

0 commit comments

Comments
 (0)