File tree Expand file tree Collapse file tree 1 file changed +7
-3
lines changed
Expand file tree Collapse file tree 1 file changed +7
-3
lines changed Original file line number Diff line number Diff line change @@ -99,10 +99,14 @@ export interface EnergyCollection extends Collection<EnergyData> {
9999
100100export const getEnergyDataCollection = (
101101 hass : HomeAssistant ,
102- key = '_energy'
103102) : EnergyCollection | null => {
104- if ( ( hass . connection as any ) [ key ] ) {
105- return ( hass . connection as any ) [ key ] ;
103+ if ( ( hass . connection as any ) [ '_energy' ] ) {
104+ return ( hass . connection as any ) [ '_energy' ] ;
105+ }
106+ for ( const key of Object . keys ( hass . connection ) ) {
107+ if ( key . startsWith ( '_energy' ) && typeof ( hass . connection as any ) [ key ] ?. subscribe === 'function' ) {
108+ return ( hass . connection as any ) [ key ] ;
109+ }
106110 }
107111 // HA has not initialized the collection yet and we don't want to interfere with that if energy_date_selection is enabled
108112 return null ;
You can’t perform that action at this time.
0 commit comments