@@ -91,6 +91,13 @@ class PredbatTableCard extends HTMLElement {
9191 throw new Error ( "Predbat HTML entity is not currently available" ) ;
9292 }
9393
94+
95+
96+ // Predbat Version entity
97+ const versionEntity = this . config . version_entity ;
98+ if ( versionEntity !== undefined )
99+ console . log ( hass . states [ this . config . version_entity ] ) ;
100+
94101 let columnsToReturn = this . config . columns ;
95102 let rawHTML = hass . states [ entityId ] . attributes . html ;
96103 const dataArray = this . getArrayDataFromHTML ( rawHTML , hass . themes . darkMode ) ;
@@ -119,7 +126,6 @@ class PredbatTableCard extends HTMLElement {
119126 lastUpdateHeaderRow . appendChild ( lastUpdateCell ) ;
120127 newTableHead . appendChild ( lastUpdateHeaderRow ) ;
121128 }
122-
123129 }
124130
125131 /*
@@ -380,6 +386,36 @@ class PredbatTableCard extends HTMLElement {
380386 newTableBody . appendChild ( totalsRow ) ;
381387 }
382388
389+ if ( versionEntity !== undefined ) {
390+ const predbatVersion = hass . states [ versionEntity ] . attributes . installed_version ;
391+ const latestPredbatVersion = hass . states [ versionEntity ] . attributes . latest_version ;
392+ let lastUpdateHeaderRow = document . createElement ( 'tr' ) ;
393+ let lastUpdateCell = document . createElement ( 'td' ) ;
394+ lastUpdateCell . classList . add ( 'versionRow' ) ;
395+ lastUpdateCell . colSpan = columnsToReturn . length ;
396+ let updateIcon = `` ;
397+ if ( predbatVersion !== latestPredbatVersion )
398+ updateIcon = `<ha-icon icon="mdi:download-circle-outline" style="--mdc-icon-size: 18px; margin-left: 4px;" title="Predbat version ${ latestPredbatVersion } available"></ha-icon>` ;
399+ lastUpdateCell . innerHTML = `Predbat Version: ${ predbatVersion } ${ updateIcon } ` ;
400+ lastUpdateHeaderRow . appendChild ( lastUpdateCell ) ;
401+ newTableBody . appendChild ( lastUpdateHeaderRow ) ;
402+ }
403+
404+ if ( this . config . show_tablecard_version === true ) {
405+ const version = hass . states [ "update.predbat_table_card_update" ] . attributes . installed_version ;
406+ const latestVersion = hass . states [ "update.predbat_table_card_update" ] . attributes . latest_version ;
407+ let lastUpdateHeaderRow = document . createElement ( 'tr' ) ;
408+ let lastUpdateCell = document . createElement ( 'td' ) ;
409+ lastUpdateCell . classList . add ( 'versionRow' ) ;
410+ lastUpdateCell . colSpan = columnsToReturn . length ;
411+ let updateIcon = `` ;
412+ if ( version !== latestVersion )
413+ updateIcon = `<ha-icon icon="mdi:download-circle-outline" style="--mdc-icon-size: 18px; margin-left: 4px;" title="Predbat Table Card version ${ latestVersion } available"></ha-icon>` ;
414+ lastUpdateCell . innerHTML = `Predbat Table Card Version: ${ version } ${ updateIcon } ` ;
415+ lastUpdateHeaderRow . appendChild ( lastUpdateCell ) ;
416+ newTableBody . appendChild ( lastUpdateHeaderRow ) ;
417+ }
418+
383419 // This section of code is hiding the car and iboost columns if they have no value (and the user has set them as a column to return)
384420
385421 if ( this . config . hide_empty_columns === true ) {
@@ -1040,6 +1076,7 @@ class PredbatTableCard extends HTMLElement {
10401076 additionalArrow = '<ha-icon icon="mdi:minus" style="margin: 0 0 0 -5px; opacity: 0.25;"></ha-icon>' ;
10411077 }
10421078 let battery ;
1079+
10431080 if ( column === "soc-column" ) {
10441081 newContent += "%" ;
10451082 const roundedPercent = Math . round ( parseInt ( batteryPercent , 10 ) / 10 ) * 10 ;
@@ -1061,11 +1098,7 @@ class PredbatTableCard extends HTMLElement {
10611098 newCell . style . minWidth = "70px" ;
10621099
10631100 newCell . style . alignItems = "center" ;
1064- }
1065-
1066-
1067-
1068- if ( column === "soc-column" ) {
1101+
10691102 newCell . innerHTML = `<div style="width: 70px; align-items: center; display: flex; justify-content: center; margin: 0 auto;"><div class="iconContainerSOC">${ battery } </div><div style="margin-left: 5px; margin-top: 2px;">${ newContent } </div></div>` ;
10701103 } else {
10711104 newCell . innerHTML = `<div class="iconContainer"><div style="margin: 0 1px;">${ newContent } </div>${ additionalArrow } </div>` ;
@@ -1993,6 +2026,13 @@ class PredbatTableCard extends HTMLElement {
19932026 background-color: ${ tableHeaderBackgroundColour } ;
19942027 }
19952028
2029+ .versionRow {
2030+ height: 24px;
2031+ font-weight: normal;
2032+ background-color: ${ tableHeaderBackgroundColour } ;
2033+ color: ${ tableHeaderFontColour } ;
2034+ }
2035+
19962036
19972037 .card-content table thead tr .topHeader {
19982038 background-color: ${ tableHeaderColumnsBackgroundColour } ;
0 commit comments