1
0
mirror of https://github.com/home-assistant/frontend.git synced 2025-12-20 02:38:53 +00:00

Restore navigation header for home, light, security and climate dashboards (#28552)

This commit is contained in:
Paul Bottein
2025-12-15 15:44:51 +01:00
committed by GitHub
parent 3bcf530200
commit 3005f12ef5
4 changed files with 73 additions and 51 deletions

View File

@@ -103,6 +103,10 @@ const processAreasForClimate = (
heading_style: "subtitle",
type: "heading",
heading: area.name,
tap_action: {
action: "navigate",
navigation_path: `/home/areas-${area.area_id}`,
},
});
cards.push(...areaCards);
}

View File

@@ -49,6 +49,10 @@ const processAreasForLight = (
heading_style: "subtitle",
type: "heading",
heading: area.name,
tap_action: {
action: "navigate",
navigation_path: `/home/areas-${area.area_id}`,
},
});
cards.push(...areaCards);
}

View File

@@ -8,7 +8,6 @@ import {
} from "../../../../common/entity/entity_filter";
import { clamp } from "../../../../common/number/clamp";
import type { LovelaceBadgeConfig } from "../../../../data/lovelace/config/badge";
import type { LovelaceCardConfig } from "../../../../data/lovelace/config/card";
import type { LovelaceSectionRawConfig } from "../../../../data/lovelace/config/section";
import type { LovelaceViewConfig } from "../../../../data/lovelace/config/view";
import type { HomeAssistant } from "../../../../types";
@@ -27,25 +26,6 @@ export interface HomeAreaViewStrategyConfig {
area?: string;
}
const computeHeadingCard = (
heading: string,
icon: string,
navigation_path?: string
): LovelaceCardConfig =>
({
type: "heading",
heading: heading,
icon: icon,
tap_action: navigation_path
? {
action: "navigate",
navigation_path,
}
: {
action: "none",
},
}) satisfies HeadingCardConfig;
@customElement("home-area-view-strategy")
export class HomeAreaViewStrategy extends ReactiveElement {
static async generate(
@@ -114,11 +94,15 @@ export class HomeAreaViewStrategy extends ReactiveElement {
sections.push({
type: "grid",
cards: [
computeHeadingCard(
getSummaryLabel(hass.localize, "light"),
HOME_SUMMARIES_ICONS.light,
"/light?historyBack=1"
),
{
type: "heading",
heading: getSummaryLabel(hass.localize, "light"),
icon: HOME_SUMMARIES_ICONS.light,
tap_action: {
action: "navigate",
navigation_path: "/light?historyBack=1",
},
} satisfies HeadingCardConfig,
...light.map(computeTileCard),
],
});
@@ -128,11 +112,15 @@ export class HomeAreaViewStrategy extends ReactiveElement {
sections.push({
type: "grid",
cards: [
computeHeadingCard(
getSummaryLabel(hass.localize, "climate"),
HOME_SUMMARIES_ICONS.climate,
"/climate?historyBack=1"
),
{
type: "heading",
heading: getSummaryLabel(hass.localize, "climate"),
icon: HOME_SUMMARIES_ICONS.climate,
tap_action: {
action: "navigate",
navigation_path: "/climate?historyBack=1",
},
} satisfies HeadingCardConfig,
...climate.map(computeTileCard),
],
});
@@ -142,11 +130,15 @@ export class HomeAreaViewStrategy extends ReactiveElement {
sections.push({
type: "grid",
cards: [
computeHeadingCard(
getSummaryLabel(hass.localize, "security"),
HOME_SUMMARIES_ICONS.security,
"/security?historyBack=1"
),
{
type: "heading",
heading: getSummaryLabel(hass.localize, "security"),
icon: HOME_SUMMARIES_ICONS.security,
tap_action: {
action: "navigate",
navigation_path: "/security?historyBack=1",
},
} satisfies HeadingCardConfig,
...security.map(computeTileCard),
],
});
@@ -156,11 +148,15 @@ export class HomeAreaViewStrategy extends ReactiveElement {
sections.push({
type: "grid",
cards: [
computeHeadingCard(
getSummaryLabel(hass.localize, "media_players"),
HOME_SUMMARIES_ICONS.media_players,
"/media-players"
),
{
type: "heading",
heading: getSummaryLabel(hass.localize, "media_players"),
icon: HOME_SUMMARIES_ICONS.media_players,
tap_action: {
action: "navigate",
navigation_path: "media-players?historyBack=1",
},
} satisfies HeadingCardConfig,
...mediaPlayers.map(computeTileCard),
],
});
@@ -181,11 +177,17 @@ export class HomeAreaViewStrategy extends ReactiveElement {
sections.push({
type: "grid",
cards: [
computeHeadingCard(
hass.localize("ui.panel.lovelace.strategy.home.scenes"),
"mdi:palette",
hass.user?.is_admin ? "/config/scene/dashboard" : undefined
),
{
type: "heading",
heading: hass.localize("ui.panel.lovelace.strategy.home.scenes"),
icon: "mdi:palette",
tap_action: hass.user?.is_admin
? {
action: "navigate",
navigation_path: "/config/scene/dashboard",
}
: undefined,
} satisfies HeadingCardConfig,
...scenes.map(computeTileCard),
],
});
@@ -293,7 +295,7 @@ export class HomeAreaViewStrategy extends ReactiveElement {
action: "navigate",
navigation_path: `/config/devices/device/${device.id}`,
}
: { action: "none" },
: undefined,
badges: [
...batteryEntities.slice(0, 1).map((e) => ({
entity: e,
@@ -334,11 +336,19 @@ export class HomeAreaViewStrategy extends ReactiveElement {
sections.push({
type: "grid",
cards: [
computeHeadingCard(
hass.localize("ui.panel.lovelace.strategy.home.automations"),
"mdi:robot",
hass.user?.is_admin ? "/config/automation/dashboard" : undefined
),
{
type: "heading",
heading: hass.localize(
"ui.panel.lovelace.strategy.home.automations"
),
icon: "mdi:robot",
tap_action: hass.user?.is_admin
? {
action: "navigate",
navigation_path: "/config/automation/dashboard",
}
: undefined,
} satisfies HeadingCardConfig,
...automations.map(computeTileCard),
],
});

View File

@@ -91,6 +91,10 @@ const processAreasForSecurity = (
heading_style: "subtitle",
type: "heading",
heading: area.name,
tap_action: {
action: "navigate",
navigation_path: `/home/areas-${area.area_id}`,
},
});
cards.push(...areaCards);
}