@@ -24,6 +24,7 @@ import { resolveShortcutItems } from "../../../../data/home_shortcuts";
2424import type { HomeAssistant } from "../../../../types" ;
2525import type {
2626 AreaCardConfig ,
27+ ConditionalCardConfig ,
2728 DiscoveredDevicesCardConfig ,
2829 EmptyStateCardConfig ,
2930 HeadingCardConfig ,
@@ -35,6 +36,8 @@ import type {
3536 TileCardConfig ,
3637 UpdatesCardConfig ,
3738} from "../../cards/types" ;
39+ import { computeDefaultSecurityAlertVisibility } from "../../cards/security-alerts/helpers" ;
40+ import { computeSecurityAlertCardEntityConfig } from "../../../security/strategies/security-alerts" ;
3841import {
3942 LARGE_SCREEN_CONDITION ,
4043 SMALL_SCREEN_CONDITION ,
@@ -469,6 +472,10 @@ export class HomeOverviewViewStrategy extends ReactiveElement {
469472 }
470473 }
471474
475+ const hasVisibleSummaryCards = summaryCards . some (
476+ ( card ) => ! ( "hide_empty" in card && card . hide_empty )
477+ ) ;
478+
472479 // Build summary cards for sidebar (full width: columns 12)
473480 const sidebarSummaryCards = summaryCards . map ( ( card ) => ( {
474481 ...card ,
@@ -515,77 +522,116 @@ export class HomeOverviewViewStrategy extends ReactiveElement {
515522 }
516523 : undefined ;
517524
518- const alertsSection : LovelaceSectionConfig | undefined = config
519- . alert_entities ?. length
520- ? {
521- type : "grid" ,
522- column_span : maxColumns ,
523- cards : [
524- {
525- type : "security-alerts" ,
526- alert_entities : config . alert_entities ,
527- horizontal : true ,
528- grid_options : { columns : "full" } ,
529- } satisfies SecurityAlertsCardConfig ,
530- ] ,
531- }
532- : undefined ;
525+ const alertEntities = config . alert_entities ?. map ( ( alertEntity ) =>
526+ computeSecurityAlertCardEntityConfig (
527+ hass . states [ alertEntity . entity ] ,
528+ alertEntity
529+ )
530+ ) ;
531+
532+ const alertsSection : LovelaceSectionConfig | undefined =
533+ alertEntities ?. length
534+ ? {
535+ type : "grid" ,
536+ column_span : maxColumns ,
537+ cards : [
538+ {
539+ type : "security-alerts" ,
540+ alert_entities : alertEntities ,
541+ horizontal : true ,
542+ grid_options : { columns : "full" } ,
543+ } satisfies SecurityAlertsCardConfig ,
544+ ] ,
545+ }
546+ : undefined ;
547+
548+ const emptyStateCard = {
549+ type : "empty-state" ,
550+ icon : "mdi:home-assistant" ,
551+ content_only : true ,
552+ title : hass . localize ( "ui.panel.lovelace.strategy.home.welcome_title" ) ,
553+ content : hass . localize ( "ui.panel.lovelace.strategy.home.welcome_content" ) ,
554+ ...( config . home_panel && hass . user ?. is_admin
555+ ? {
556+ buttons : [
557+ {
558+ icon : "mdi:plus" ,
559+ text : hass . localize (
560+ "ui.panel.lovelace.strategy.home.welcome_add_device"
561+ ) ,
562+ appearance : "filled" as const ,
563+ variant : "brand" as const ,
564+ tap_action : {
565+ action : "fire-dom-event" as const ,
566+ home_panel : {
567+ type : "add_integration" ,
568+ } ,
569+ } ,
570+ } ,
571+ {
572+ icon : "mdi:home-edit" ,
573+ text : hass . localize (
574+ "ui.panel.lovelace.strategy.home.welcome_edit_areas"
575+ ) ,
576+ appearance : "plain" as const ,
577+ variant : "brand" as const ,
578+ tap_action : {
579+ action : "navigate" as const ,
580+ navigation_path : "/config/areas/dashboard" ,
581+ } ,
582+ } ,
583+ ] ,
584+ }
585+ : { } ) ,
586+ } as EmptyStateCardConfig ;
533587
534588 // No sections, show empty state
535589 if ( floorsSections . length === 0 && ! alertsSection ) {
536590 return {
537591 type : "panel" ,
538- cards : [
539- {
540- type : "empty-state" ,
541- icon : "mdi:home-assistant" ,
542- content_only : true ,
543- title : hass . localize (
544- "ui.panel.lovelace.strategy.home.welcome_title"
545- ) ,
546- content : hass . localize (
547- "ui.panel.lovelace.strategy.home.welcome_content"
548- ) ,
549- ...( config . home_panel && hass . user ?. is_admin
550- ? {
551- buttons : [
552- {
553- icon : "mdi:plus" ,
554- text : hass . localize (
555- "ui.panel.lovelace.strategy.home.welcome_add_device"
556- ) ,
557- appearance : "filled" ,
558- variant : "brand" ,
559- tap_action : {
560- action : "fire-dom-event" ,
561- home_panel : {
562- type : "add_integration" ,
563- } ,
564- } ,
565- } ,
566- {
567- icon : "mdi:home-edit" ,
568- text : hass . localize (
569- "ui.panel.lovelace.strategy.home.welcome_edit_areas"
570- ) ,
571- appearance : "plain" ,
572- variant : "brand" ,
573- tap_action : {
574- action : "navigate" ,
575- navigation_path : "/config/areas/dashboard" ,
576- } ,
577- } ,
578- ] ,
579- }
580- : { } ) ,
581- } as EmptyStateCardConfig ,
582- ] ,
592+ cards : [ emptyStateCard ] ,
583593 } ;
584594 }
585595
596+ const emptyStateSection : LovelaceSectionConfig | undefined =
597+ floorsSections . length === 0 &&
598+ ! favoritesSection &&
599+ ! hasVisibleSummaryCards &&
600+ alertEntities ?. length
601+ ? {
602+ type : "grid" ,
603+ column_span : maxColumns ,
604+ cards : [
605+ {
606+ type : "conditional" ,
607+ conditions : [
608+ {
609+ condition : "not" ,
610+ conditions : [
611+ {
612+ condition : "or" ,
613+ conditions : alertEntities . map ( ( alertEntity ) => ( {
614+ condition : "and" ,
615+ conditions :
616+ alertEntity . visibility ??
617+ computeDefaultSecurityAlertVisibility (
618+ alertEntity . entity
619+ ) ,
620+ } ) ) ,
621+ } ,
622+ ] ,
623+ } ,
624+ ] ,
625+ card : emptyStateCard ,
626+ } satisfies ConditionalCardConfig ,
627+ ] ,
628+ }
629+ : undefined ;
630+
586631 const sections = (
587632 [
588633 alertsSection ,
634+ emptyStateSection ,
589635 favoritesSection ,
590636 mobileSummarySection ,
591637 ...floorsSections ,
0 commit comments