@@ -430,7 +430,8 @@ class PredbatTableCard extends HTMLElement {
430430
431431 const entityId = this . config . entity ;
432432 const switchEntityId = this . config . car_charge_switch ; // optional
433- const predbatActiveEntityId = 'switch.predbat_active' ;
433+ const prefix = this . config . entity . match ( / ^ [ ^ . ] + / ) [ 0 ] ;
434+ const predbatActiveEntityId = `switch.${ prefix } _active` ;
434435
435436 if ( oldHass === undefined ) {
436437 // Render html on the first load
@@ -526,8 +527,9 @@ class PredbatTableCard extends HTMLElement {
526527 }
527528
528529 async processAndRender ( hass ) {
529-
530- const predbatActiveEntityId = 'switch.predbat_active' ;
530+
531+ const prefix = this . config . entity . match ( / ^ [ ^ . ] + / ) [ 0 ] ;
532+ const predbatActiveEntityId = `switch.${ prefix } _active` ;
531533
532534 if ( this . _lastOnText === null ) {
533535
@@ -652,9 +654,6 @@ class PredbatTableCard extends HTMLElement {
652654 }
653655 } ) ;
654656
655- console . log ( "overallTotalDay:" , dayTotal ) ;
656- console . log ( "overallTotalPlan:" , overallTotal ) ;
657-
658657 newTableBody . appendChild ( newRow ) ;
659658
660659 if ( isMidnight ) {
@@ -833,9 +832,10 @@ class PredbatTableCard extends HTMLElement {
833832 }
834833
835834 this . content . appendChild ( theTable ) ; // Add actual DOM node (preserves listeners)
836-
835+
836+
837837 if ( this . config . show_predbat_version === true )
838- this . content . appendChild ( this . createVersionLabelsForFooter ( " update.predbat_version" , "Predbat Version" , this ) ) ;
838+ this . content . appendChild ( this . createVersionLabelsForFooter ( ` update.${ prefix } _version` , "Predbat Version" , this ) ) ;
839839
840840 if ( this . config . show_tablecard_version === true )
841841 this . content . appendChild ( this . createVersionLabelsForFooter ( "update.predbat_table_card_update" , "Predbat Table Card Version" , this ) ) ;
@@ -949,8 +949,11 @@ isVersionGreater(a, b) {
949949}
950950
951951getTimeframeForOverride ( timeString ) {
952+
953+ const prefix = this . config . entity . match ( / ^ [ ^ . ] + / ) [ 0 ] ;
954+
952955 const predBatVersion =
953- this . _hass . states [ " update.predbat_version" ] . attributes . installed_version ;
956+ this . _hass . states [ ` update.${ prefix } _version` ] . attributes . installed_version ;
954957
955958 // Match either "Wed 08:05" or "08:05"
956959 const match = timeString . match ( / ^ (?: ( \w { 3 } ) \s ) ? ( \d { 2 } ) : ( \d { 2 } ) $ / ) ;
@@ -981,8 +984,10 @@ getTimeframeForOverride(timeString) {
981984 }
982985
983986 createButtonForOverrides ( entityObject , timeForSelectOverride , iconSize , textColor , hideLabel , isAllowed , fromPopup = false ) {
984- const key = entityObject . entityName . replace ( 'select.predbat_manual_' , '' ) ;
985-
987+
988+ const prefix = this . config . entity . match ( / ^ [ ^ . ] + / ) [ 0 ] ;
989+ const key = entityObject . entityName . replace ( `select.${ prefix } _manual_` , '' ) ;
990+
986991 const iconOpacityOff = 1.00 ;
987992 const iconOpacityOn = 1.00 ;
988993 const iconColorOff = "rgb(75, 80, 87)" ;
@@ -1134,12 +1139,15 @@ getTimeframeForOverride(timeString) {
11341139 }
11351140
11361141 getOverrideEntities ( ) {
1142+
1143+ const prefix = this . config . entity . match ( / ^ [ ^ . ] + / ) [ 0 ] ;
1144+
11371145 const forceEntityArray = [
1138- " select.predbat_manual_demand" ,
1139- " select.predbat_manual_charge" ,
1140- " select.predbat_manual_export" ,
1141- " select.predbat_manual_freeze_charge" ,
1142- " select.predbat_manual_freeze_export"
1146+ ` select.${ prefix } _manual_demand` ,
1147+ ` select.${ prefix } _manual_charge` ,
1148+ ` select.${ prefix } _manual_export` ,
1149+ ` select.${ prefix } _manual_freeze_charge` ,
1150+ ` select.${ prefix } _manual_freeze_export`
11431151 ] ;
11441152
11451153 const titleMap = {
@@ -1159,7 +1167,7 @@ getTimeframeForOverride(timeString) {
11591167 } ;
11601168
11611169 const forceEntityObjects = forceEntityArray . map ( entityName => {
1162- const key = entityName . replace ( ' select.predbat_manual_' , '' ) ; // e.g., "freeze_export"
1170+ const key = entityName . replace ( ` select.${ prefix } _manual_` , '' ) ; // e.g., "freeze_export"
11631171 return {
11641172 entityName,
11651173 entityIcon : iconMap [ key ] ,
0 commit comments