@@ -144,67 +144,80 @@ export class HomeMainViewStrategy extends ReactiveElement {
144144 column_span : maxColumns ,
145145 } as LovelaceStrategySectionConfig ;
146146
147+ // Check if there are any media player entities
148+ const mediaPlayerFilter = generateEntityFilter ( hass , {
149+ domain : "media_player" ,
150+ entity_category : "none" ,
151+ } ) ;
152+ const hasMediaPlayers = Object . keys ( hass . states ) . some ( mediaPlayerFilter ) ;
153+
154+ const summaryCards : LovelaceCardConfig [ ] = [
155+ {
156+ type : "heading" ,
157+ heading : hass . localize ( "ui.panel.lovelace.strategy.home.summaries" ) ,
158+ } ,
159+ {
160+ type : "home-summary" ,
161+ summary : "light" ,
162+ vertical : true ,
163+ tap_action : {
164+ action : "navigate" ,
165+ navigation_path : "/light?historyBack=1" ,
166+ } ,
167+ grid_options : {
168+ rows : 2 ,
169+ columns : 4 ,
170+ } ,
171+ } satisfies HomeSummaryCard ,
172+ {
173+ type : "home-summary" ,
174+ summary : "climate" ,
175+ vertical : true ,
176+ tap_action : {
177+ action : "navigate" ,
178+ navigation_path : "/climate?historyBack=1" ,
179+ } ,
180+ grid_options : {
181+ rows : 2 ,
182+ columns : 4 ,
183+ } ,
184+ } satisfies HomeSummaryCard ,
185+ {
186+ type : "home-summary" ,
187+ summary : "safety" ,
188+ vertical : true ,
189+ tap_action : {
190+ action : "navigate" ,
191+ navigation_path : "/safety?historyBack=1" ,
192+ } ,
193+ grid_options : {
194+ rows : 2 ,
195+ columns : 4 ,
196+ } ,
197+ } satisfies HomeSummaryCard ,
198+ ] ;
199+
200+ // Only add media players summary if there are media player entities
201+ if ( hasMediaPlayers ) {
202+ summaryCards . push ( {
203+ type : "home-summary" ,
204+ summary : "media_players" ,
205+ vertical : true ,
206+ tap_action : {
207+ action : "navigate" ,
208+ navigation_path : "media-players" ,
209+ } ,
210+ grid_options : {
211+ rows : 2 ,
212+ columns : 4 ,
213+ } ,
214+ } satisfies HomeSummaryCard ) ;
215+ }
216+
147217 const summarySection : LovelaceSectionConfig = {
148218 type : "grid" ,
149219 column_span : maxColumns ,
150- cards : [
151- {
152- type : "heading" ,
153- heading : hass . localize ( "ui.panel.lovelace.strategy.home.summaries" ) ,
154- } ,
155- {
156- type : "home-summary" ,
157- summary : "light" ,
158- vertical : true ,
159- tap_action : {
160- action : "navigate" ,
161- navigation_path : "/light?historyBack=1" ,
162- } ,
163- grid_options : {
164- rows : 2 ,
165- columns : 4 ,
166- } ,
167- } satisfies HomeSummaryCard ,
168- {
169- type : "home-summary" ,
170- summary : "climate" ,
171- vertical : true ,
172- tap_action : {
173- action : "navigate" ,
174- navigation_path : "/climate?historyBack=1" ,
175- } ,
176- grid_options : {
177- rows : 2 ,
178- columns : 4 ,
179- } ,
180- } satisfies HomeSummaryCard ,
181- {
182- type : "home-summary" ,
183- summary : "safety" ,
184- vertical : true ,
185- tap_action : {
186- action : "navigate" ,
187- navigation_path : "/safety?historyBack=1" ,
188- } ,
189- grid_options : {
190- rows : 2 ,
191- columns : 4 ,
192- } ,
193- } satisfies HomeSummaryCard ,
194- {
195- type : "home-summary" ,
196- summary : "media_players" ,
197- vertical : true ,
198- tap_action : {
199- action : "navigate" ,
200- navigation_path : "media-players" ,
201- } ,
202- grid_options : {
203- rows : 2 ,
204- columns : 4 ,
205- } ,
206- } satisfies HomeSummaryCard ,
207- ] ,
220+ cards : summaryCards ,
208221 } ;
209222
210223 const weatherFilter = generateEntityFilter ( hass , {
0 commit comments