From c8be25dfc2c4c86b98ccab2fc413cfc456c5592c Mon Sep 17 00:00:00 2001 From: Paul Bottein Date: Wed, 27 Aug 2025 12:35:43 +0200 Subject: [PATCH] Rename overview to home and add widget section (#26715) --- ...efault.svg => icon-dashboard-overview.svg} | 0 ...efault.svg => icon-dashboard-overview.svg} | 0 .../config/dashboard/dialog-new-dashboard.ts | 18 ++-- .../lovelace/strategies/get-strategy.ts | 18 ++-- .../hui-home-dashboard-strategy-editor.ts} | 14 +-- .../helpers/home-structure.ts} | 0 .../helpers/home-summaries.ts} | 11 +-- .../home-area-view-strategy.ts} | 40 ++++----- .../home-climate-view-strategy.ts} | 21 ++--- .../home-dashboard-strategy.ts} | 46 +++++----- .../home-lights-view-strategy.ts} | 21 ++--- .../home-main-view-strategy.ts} | 89 +++++++++++++------ .../home-media-players-view-strategy.ts} | 23 +++-- .../home-security-view-strategy.ts} | 21 ++--- src/translations/en.json | 6 +- 15 files changed, 175 insertions(+), 153 deletions(-) rename public/static/images/dashboard-options/dark/{icon-dashboard-default.svg => icon-dashboard-overview.svg} (100%) rename public/static/images/dashboard-options/light/{icon-dashboard-default.svg => icon-dashboard-overview.svg} (100%) rename src/panels/lovelace/strategies/{overview/editor/hui-overview-dashboard-strategy-editor.ts => home/editor/hui-home-dashboard-strategy-editor.ts} (76%) rename src/panels/lovelace/strategies/{overview/helpers/overview-home-structure.ts => home/helpers/home-structure.ts} (100%) rename src/panels/lovelace/strategies/{overview/helpers/overview-summaries.ts => home/helpers/home-summaries.ts} (87%) rename src/panels/lovelace/strategies/{overview/overview-area-view-strategy.ts => home/home-area-view-strategy.ts} (89%) rename src/panels/lovelace/strategies/{overview/overview-climate-view-strategy.ts => home/home-climate-view-strategy.ts} (87%) rename src/panels/lovelace/strategies/{overview/overview-dashboard-strategy.ts => home/home-dashboard-strategy.ts} (67%) rename src/panels/lovelace/strategies/{overview/overview-lights-view-strategy.ts => home/home-lights-view-strategy.ts} (87%) rename src/panels/lovelace/strategies/{overview/overview-home-view-strategy.ts => home/home-main-view-strategy.ts} (67%) rename src/panels/lovelace/strategies/{overview/overview-media-players-view-strategy.ts => home/home-media-players-view-strategy.ts} (85%) rename src/panels/lovelace/strategies/{overview/overview-security-view-strategy.ts => home/home-security-view-strategy.ts} (87%) diff --git a/public/static/images/dashboard-options/dark/icon-dashboard-default.svg b/public/static/images/dashboard-options/dark/icon-dashboard-overview.svg similarity index 100% rename from public/static/images/dashboard-options/dark/icon-dashboard-default.svg rename to public/static/images/dashboard-options/dark/icon-dashboard-overview.svg diff --git a/public/static/images/dashboard-options/light/icon-dashboard-default.svg b/public/static/images/dashboard-options/light/icon-dashboard-overview.svg similarity index 100% rename from public/static/images/dashboard-options/light/icon-dashboard-default.svg rename to public/static/images/dashboard-options/light/icon-dashboard-overview.svg diff --git a/src/panels/config/dashboard/dialog-new-dashboard.ts b/src/panels/config/dashboard/dialog-new-dashboard.ts index a0518e70b2..bdd2e067a1 100644 --- a/src/panels/config/dashboard/dialog-new-dashboard.ts +++ b/src/panels/config/dashboard/dialog-new-dashboard.ts @@ -26,15 +26,15 @@ interface Strategy { const STRATEGIES = [ { - type: "default", + type: "overview", images: { light: - "/static/images/dashboard-options/light/icon-dashboard-default.svg", - dark: "/static/images/dashboard-options/dark/icon-dashboard-default.svg", + "/static/images/dashboard-options/light/icon-dashboard-overview.svg", + dark: "/static/images/dashboard-options/dark/icon-dashboard-overview.svg", }, - name: "ui.panel.config.lovelace.dashboards.dialog_new.strategy.default.title", + name: "ui.panel.config.lovelace.dashboards.dialog_new.strategy.overview.title", description: - "ui.panel.config.lovelace.dashboards.dialog_new.strategy.default.description", + "ui.panel.config.lovelace.dashboards.dialog_new.strategy.overview.description", }, { type: "areas", @@ -47,14 +47,14 @@ const STRATEGIES = [ "ui.panel.config.lovelace.dashboards.dialog_new.strategy.areas.description", }, { - type: "overview", + type: "home", images: { light: "/static/images/dashboard-options/light/icon-dashboard-areas.svg", dark: "/static/images/dashboard-options/dark/icon-dashboard-areas.svg", }, - name: "ui.panel.config.lovelace.dashboards.dialog_new.strategy.overview.title", + name: "ui.panel.config.lovelace.dashboards.dialog_new.strategy.home.title", description: - "ui.panel.config.lovelace.dashboards.dialog_new.strategy.overview.description", + "ui.panel.config.lovelace.dashboards.dialog_new.strategy.home.description", }, { type: "map", @@ -254,7 +254,7 @@ class DialogNewDashboard extends LitElement implements HassDialog { if (target.config) { config = target.config; } else if (target.strategy) { - if (target.strategy === "default") { + if (target.strategy === "overview") { config = null; } else { config = this._generateStrategyConfig(target.strategy); diff --git a/src/panels/lovelace/strategies/get-strategy.ts b/src/panels/lovelace/strategies/get-strategy.ts index f71a37e812..96e18c510e 100644 --- a/src/panels/lovelace/strategies/get-strategy.ts +++ b/src/panels/lovelace/strategies/get-strategy.ts @@ -33,7 +33,7 @@ const STRATEGIES: Record> = { map: () => import("./map/map-dashboard-strategy"), iframe: () => import("./iframe/iframe-dashboard-strategy"), areas: () => import("./areas/areas-dashboard-strategy"), - overview: () => import("./overview/overview-dashboard-strategy"), + home: () => import("./home/home-dashboard-strategy"), }, view: { "original-states": () => @@ -43,15 +43,13 @@ const STRATEGIES: Record> = { iframe: () => import("./iframe/iframe-view-strategy"), area: () => import("./areas/area-view-strategy"), "areas-overview": () => import("./areas/areas-overview-view-strategy"), - "overview-home": () => import("./overview/overview-home-view-strategy"), - "overview-lights": () => import("./overview/overview-lights-view-strategy"), - "overview-climate": () => - import("./overview/overview-climate-view-strategy"), - "overview-security": () => - import("./overview/overview-security-view-strategy"), - "overview-media-players": () => - import("./overview/overview-media-players-view-strategy"), - "overview-area": () => import("./overview/overview-area-view-strategy"), + "home-main": () => import("./home/home-main-view-strategy"), + "home-lights": () => import("./home/home-lights-view-strategy"), + "home-climate": () => import("./home/home-climate-view-strategy"), + "home-security": () => import("./home/home-security-view-strategy"), + "home-media-players": () => + import("./home/home-media-players-view-strategy"), + "home-area": () => import("./home/home-area-view-strategy"), }, section: {}, }; diff --git a/src/panels/lovelace/strategies/overview/editor/hui-overview-dashboard-strategy-editor.ts b/src/panels/lovelace/strategies/home/editor/hui-home-dashboard-strategy-editor.ts similarity index 76% rename from src/panels/lovelace/strategies/overview/editor/hui-overview-dashboard-strategy-editor.ts rename to src/panels/lovelace/strategies/home/editor/hui-home-dashboard-strategy-editor.ts index 74b5b657a2..fd5c1c8f75 100644 --- a/src/panels/lovelace/strategies/overview/editor/hui-overview-dashboard-strategy-editor.ts +++ b/src/panels/lovelace/strategies/home/editor/hui-home-dashboard-strategy-editor.ts @@ -4,19 +4,19 @@ import { fireEvent } from "../../../../../common/dom/fire_event"; import "../../../../../components/entity/ha-entities-picker"; import type { HomeAssistant } from "../../../../../types"; import type { LovelaceStrategyEditor } from "../../types"; -import type { OverviewDashboardStrategyConfig } from "../overview-dashboard-strategy"; +import type { HomeDashboardStrategyConfig } from "../home-dashboard-strategy"; -@customElement("hui-overview-dashboard-strategy-editor") -export class HuiOverviewDashboardStrategyEditor +@customElement("hui-home-dashboard-strategy-editor") +export class HuiHomeDashboardStrategyEditor extends LitElement implements LovelaceStrategyEditor { @property({ attribute: false }) public hass?: HomeAssistant; @state() - private _config?: OverviewDashboardStrategyConfig; + private _config?: HomeDashboardStrategyConfig; - public setConfig(config: OverviewDashboardStrategyConfig): void { + public setConfig(config: HomeDashboardStrategyConfig): void { this._config = config; } @@ -47,7 +47,7 @@ export class HuiOverviewDashboardStrategyEditor const favoriteEntities = ev.detail.value as string[]; - const config: OverviewDashboardStrategyConfig = { + const config: HomeDashboardStrategyConfig = { ...this._config, favorite_entities: favoriteEntities, }; @@ -62,6 +62,6 @@ export class HuiOverviewDashboardStrategyEditor declare global { interface HTMLElementTagNameMap { - "hui-overview-dashboard-strategy-editor": HuiOverviewDashboardStrategyEditor; + "hui-home-dashboard-strategy-editor": HuiHomeDashboardStrategyEditor; } } diff --git a/src/panels/lovelace/strategies/overview/helpers/overview-home-structure.ts b/src/panels/lovelace/strategies/home/helpers/home-structure.ts similarity index 100% rename from src/panels/lovelace/strategies/overview/helpers/overview-home-structure.ts rename to src/panels/lovelace/strategies/home/helpers/home-structure.ts diff --git a/src/panels/lovelace/strategies/overview/helpers/overview-summaries.ts b/src/panels/lovelace/strategies/home/helpers/home-summaries.ts similarity index 87% rename from src/panels/lovelace/strategies/overview/helpers/overview-summaries.ts rename to src/panels/lovelace/strategies/home/helpers/home-summaries.ts index 9d158d0eb3..7916402cd3 100644 --- a/src/panels/lovelace/strategies/overview/helpers/overview-summaries.ts +++ b/src/panels/lovelace/strategies/home/helpers/home-summaries.ts @@ -3,26 +3,23 @@ import type { EntityFilterFunc, } from "../../../../../common/entity/entity_filter"; -export const OVERVIEW_SUMMARIES = [ +export const HOME_SUMMARIES = [ "lights", "climate", "security", "media_players", ] as const; -export type OverviewSummaries = (typeof OVERVIEW_SUMMARIES)[number]; +export type HomeSummaries = (typeof HOME_SUMMARIES)[number]; -export const OVERVIEW_SUMMARIES_ICONS: Record = { +export const HOME_SUMMARIES_ICONS: Record = { lights: "mdi:lamps", climate: "mdi:home-thermometer", security: "mdi:security", media_players: "mdi:multimedia", }; -export const OVERVIEW_SUMMARIES_FILTERS: Record< - OverviewSummaries, - EntityFilter[] -> = { +export const HOME_SUMMARIES_FILTERS: Record = { lights: [{ domain: "light", entity_category: "none" }], climate: [ { domain: "climate", entity_category: "none" }, diff --git a/src/panels/lovelace/strategies/overview/overview-area-view-strategy.ts b/src/panels/lovelace/strategies/home/home-area-view-strategy.ts similarity index 89% rename from src/panels/lovelace/strategies/overview/overview-area-view-strategy.ts rename to src/panels/lovelace/strategies/home/home-area-view-strategy.ts index b9da6974e3..24ca6a4f96 100644 --- a/src/panels/lovelace/strategies/overview/overview-area-view-strategy.ts +++ b/src/panels/lovelace/strategies/home/home-area-view-strategy.ts @@ -14,14 +14,14 @@ import type { HeadingCardConfig } from "../../cards/types"; import { computeAreaTileCardConfig } from "../areas/helpers/areas-strategy-helper"; import { findEntities, - OVERVIEW_SUMMARIES, - OVERVIEW_SUMMARIES_FILTERS, - OVERVIEW_SUMMARIES_ICONS, - type OverviewSummaries, -} from "./helpers/overview-summaries"; + HOME_SUMMARIES, + HOME_SUMMARIES_FILTERS, + HOME_SUMMARIES_ICONS, + type HomeSummaries, +} from "./helpers/home-summaries"; -export interface OverviewAreaViewStrategyConfig { - type: "overview-area"; +export interface HomeAreaViewStrategyConfig { + type: "home-area"; area?: string; } @@ -42,10 +42,10 @@ const computeHeadingCard = ( : undefined, }) satisfies HeadingCardConfig; -@customElement("overview-area-view-strategy") -export class OverviewAreaViewStrategy extends ReactiveElement { +@customElement("home-area-view-strategy") +export class HomeAreaViewStrategy extends ReactiveElement { static async generate( - config: OverviewAreaViewStrategyConfig, + config: HomeAreaViewStrategyConfig, hass: HomeAssistant ): Promise { if (!config.area) { @@ -87,16 +87,16 @@ export class OverviewAreaViewStrategy extends ReactiveElement { const allEntities = Object.keys(hass.states); const areaEntities = allEntities.filter(areaFilter); - const entitiesBySummary = OVERVIEW_SUMMARIES.reduce( + const entitiesBySummary = HOME_SUMMARIES.reduce( (acc, summary) => { - const summariesFilters = OVERVIEW_SUMMARIES_FILTERS[summary]; + const summariesFilters = HOME_SUMMARIES_FILTERS[summary]; const filterFunctions = summariesFilters.map((filter) => generateEntityFilter(hass, filter) ); acc[summary] = findEntities(areaEntities, filterFunctions); return acc; }, - {} as Record + {} as Record ); const { @@ -110,11 +110,7 @@ export class OverviewAreaViewStrategy extends ReactiveElement { sections.push({ type: "grid", cards: [ - computeHeadingCard( - "Lights", - OVERVIEW_SUMMARIES_ICONS.lights, - "lights" - ), + computeHeadingCard("Lights", HOME_SUMMARIES_ICONS.lights, "lights"), ...lights.map(computeTileCard), ], }); @@ -126,7 +122,7 @@ export class OverviewAreaViewStrategy extends ReactiveElement { cards: [ computeHeadingCard( "Climate", - OVERVIEW_SUMMARIES_ICONS.climate, + HOME_SUMMARIES_ICONS.climate, "climate" ), ...climate.map(computeTileCard), @@ -140,7 +136,7 @@ export class OverviewAreaViewStrategy extends ReactiveElement { cards: [ computeHeadingCard( "Security", - OVERVIEW_SUMMARIES_ICONS.security, + HOME_SUMMARIES_ICONS.security, "security" ), ...security.map(computeTileCard), @@ -154,7 +150,7 @@ export class OverviewAreaViewStrategy extends ReactiveElement { cards: [ computeHeadingCard( "Media players", - OVERVIEW_SUMMARIES_ICONS.media_players, + HOME_SUMMARIES_ICONS.media_players, "media-players" ), ...mediaPlayers.map(computeTileCard), @@ -310,6 +306,6 @@ export class OverviewAreaViewStrategy extends ReactiveElement { declare global { interface HTMLElementTagNameMap { - "overview-area-view-strategy": OverviewAreaViewStrategy; + "home-area-view-strategy": HomeAreaViewStrategy; } } diff --git a/src/panels/lovelace/strategies/overview/overview-climate-view-strategy.ts b/src/panels/lovelace/strategies/home/home-climate-view-strategy.ts similarity index 87% rename from src/panels/lovelace/strategies/overview/overview-climate-view-strategy.ts rename to src/panels/lovelace/strategies/home/home-climate-view-strategy.ts index 94ea35caa8..4bca069ffd 100644 --- a/src/panels/lovelace/strategies/overview/overview-climate-view-strategy.ts +++ b/src/panels/lovelace/strategies/home/home-climate-view-strategy.ts @@ -12,14 +12,11 @@ import { getAreas, getFloors, } from "../areas/helpers/areas-strategy-helper"; -import { getHomeStructure } from "./helpers/overview-home-structure"; -import { - findEntities, - OVERVIEW_SUMMARIES_FILTERS, -} from "./helpers/overview-summaries"; +import { getHomeStructure } from "./helpers/home-structure"; +import { findEntities, HOME_SUMMARIES_FILTERS } from "./helpers/home-summaries"; -export interface OverviewClimateViewStrategyConfig { - type: "overview-climate"; +export interface HomeClimateViewStrategyConfig { + type: "home-climate"; } const processAreasForClimate = ( @@ -61,10 +58,10 @@ const processAreasForClimate = ( return cards; }; -@customElement("overview-climate-view-strategy") -export class OverviewClimateViewStrategy extends ReactiveElement { +@customElement("home-climate-view-strategy") +export class HomeClimateViewStrategy extends ReactiveElement { static async generate( - _config: OverviewClimateViewStrategyConfig, + _config: HomeClimateViewStrategyConfig, hass: HomeAssistant ): Promise { const areas = getAreas(hass.areas); @@ -75,7 +72,7 @@ export class OverviewClimateViewStrategy extends ReactiveElement { const allEntities = Object.keys(hass.states); - const filterFunctions = OVERVIEW_SUMMARIES_FILTERS.climate.map((filter) => + const filterFunctions = HOME_SUMMARIES_FILTERS.climate.map((filter) => generateEntityFilter(hass, filter) ); @@ -147,6 +144,6 @@ export class OverviewClimateViewStrategy extends ReactiveElement { declare global { interface HTMLElementTagNameMap { - "overview-climate-view-strategy": OverviewClimateViewStrategy; + "home-climate-view-strategy": HomeClimateViewStrategy; } } diff --git a/src/panels/lovelace/strategies/overview/overview-dashboard-strategy.ts b/src/panels/lovelace/strategies/home/home-dashboard-strategy.ts similarity index 67% rename from src/panels/lovelace/strategies/overview/overview-dashboard-strategy.ts rename to src/panels/lovelace/strategies/home/home-dashboard-strategy.ts index c2a6cb0d90..35e9da886c 100644 --- a/src/panels/lovelace/strategies/overview/overview-dashboard-strategy.ts +++ b/src/panels/lovelace/strategies/home/home-dashboard-strategy.ts @@ -6,19 +6,19 @@ import type { LovelaceViewRawConfig } from "../../../../data/lovelace/config/vie import type { HomeAssistant } from "../../../../types"; import { getAreas } from "../areas/helpers/areas-strategy-helper"; import type { LovelaceStrategyEditor } from "../types"; -import { OVERVIEW_SUMMARIES_ICONS } from "./helpers/overview-summaries"; -import type { OverviewAreaViewStrategyConfig } from "./overview-area-view-strategy"; -import type { OverviewHomeViewStrategyConfig } from "./overview-home-view-strategy"; +import { HOME_SUMMARIES_ICONS } from "./helpers/home-summaries"; +import type { HomeAreaViewStrategyConfig } from "./home-area-view-strategy"; +import type { HomeMainViewStrategyConfig } from "./home-main-view-strategy"; -export interface OverviewDashboardStrategyConfig { - type: "overview"; +export interface HomeDashboardStrategyConfig { + type: "home"; favorite_entities?: string[]; } -@customElement("overview-dashboard-strategy") -export class OverviewDashboardStrategy extends ReactiveElement { +@customElement("home-dashboard-strategy") +export class HomeDashboardStrategy extends ReactiveElement { static async generate( - config: OverviewDashboardStrategyConfig, + config: HomeDashboardStrategyConfig, hass: HomeAssistant ): Promise { if (hass.config.state === STATE_NOT_RUNNING) { @@ -53,9 +53,9 @@ export class OverviewDashboardStrategy extends ReactiveElement { path: path, subview: true, strategy: { - type: "overview-area", + type: "home-area", area: area.area_id, - } satisfies OverviewAreaViewStrategyConfig, + } satisfies HomeAreaViewStrategyConfig, }; }); @@ -64,9 +64,9 @@ export class OverviewDashboardStrategy extends ReactiveElement { path: "lights", subview: true, strategy: { - type: "overview-lights", + type: "home-lights", }, - icon: OVERVIEW_SUMMARIES_ICONS.lights, + icon: HOME_SUMMARIES_ICONS.lights, } satisfies LovelaceViewRawConfig; const climateView = { @@ -74,9 +74,9 @@ export class OverviewDashboardStrategy extends ReactiveElement { path: "climate", subview: true, strategy: { - type: "overview-climate", + type: "home-climate", }, - icon: OVERVIEW_SUMMARIES_ICONS.climate, + icon: HOME_SUMMARIES_ICONS.climate, } satisfies LovelaceViewRawConfig; const securityView = { @@ -84,9 +84,9 @@ export class OverviewDashboardStrategy extends ReactiveElement { path: "security", subview: true, strategy: { - type: "overview-security", + type: "home-security", }, - icon: OVERVIEW_SUMMARIES_ICONS.security, + icon: HOME_SUMMARIES_ICONS.security, } satisfies LovelaceViewRawConfig; const mediaPlayersView = { @@ -94,9 +94,9 @@ export class OverviewDashboardStrategy extends ReactiveElement { path: "media-players", subview: true, strategy: { - type: "overview-media-players", + type: "home-media-players", }, - icon: OVERVIEW_SUMMARIES_ICONS.media_players, + icon: HOME_SUMMARIES_ICONS.media_players, } satisfies LovelaceViewRawConfig; return { @@ -105,9 +105,9 @@ export class OverviewDashboardStrategy extends ReactiveElement { icon: "mdi:home", path: "home", strategy: { - type: "overview-home", + type: "home-main", favorite_entities: config.favorite_entities, - } satisfies OverviewHomeViewStrategyConfig, + } satisfies HomeMainViewStrategyConfig, }, ...areaViews, lightView, @@ -119,13 +119,13 @@ export class OverviewDashboardStrategy extends ReactiveElement { } public static async getConfigElement(): Promise { - await import("./editor/hui-overview-dashboard-strategy-editor"); - return document.createElement("hui-overview-dashboard-strategy-editor"); + await import("./editor/hui-home-dashboard-strategy-editor"); + return document.createElement("hui-home-dashboard-strategy-editor"); } } declare global { interface HTMLElementTagNameMap { - "overview-dashboard-strategy": OverviewDashboardStrategy; + "home-dashboard-strategy": HomeDashboardStrategy; } } diff --git a/src/panels/lovelace/strategies/overview/overview-lights-view-strategy.ts b/src/panels/lovelace/strategies/home/home-lights-view-strategy.ts similarity index 87% rename from src/panels/lovelace/strategies/overview/overview-lights-view-strategy.ts rename to src/panels/lovelace/strategies/home/home-lights-view-strategy.ts index b0bd9a2b41..1a5212bdc0 100644 --- a/src/panels/lovelace/strategies/overview/overview-lights-view-strategy.ts +++ b/src/panels/lovelace/strategies/home/home-lights-view-strategy.ts @@ -12,14 +12,11 @@ import { getAreas, getFloors, } from "../areas/helpers/areas-strategy-helper"; -import { getHomeStructure } from "./helpers/overview-home-structure"; -import { - findEntities, - OVERVIEW_SUMMARIES_FILTERS, -} from "./helpers/overview-summaries"; +import { getHomeStructure } from "./helpers/home-structure"; +import { findEntities, HOME_SUMMARIES_FILTERS } from "./helpers/home-summaries"; -export interface OverviewLightsViewStrategyConfig { - type: "overview-lights"; +export interface HomeLightsViewStrategyConfig { + type: "home-lights"; } const processAreasForLights = ( @@ -61,10 +58,10 @@ const processAreasForLights = ( return cards; }; -@customElement("overview-lights-view-strategy") -export class OverviewLightsViewStrategy extends ReactiveElement { +@customElement("home-lights-view-strategy") +export class HomeLightsViewStrategy extends ReactiveElement { static async generate( - _config: OverviewLightsViewStrategyConfig, + _config: HomeLightsViewStrategyConfig, hass: HomeAssistant ): Promise { const areas = getAreas(hass.areas); @@ -75,7 +72,7 @@ export class OverviewLightsViewStrategy extends ReactiveElement { const allEntities = Object.keys(hass.states); - const lightsFilters = OVERVIEW_SUMMARIES_FILTERS.lights.map((filter) => + const lightsFilters = HOME_SUMMARIES_FILTERS.lights.map((filter) => generateEntityFilter(hass, filter) ); @@ -147,6 +144,6 @@ export class OverviewLightsViewStrategy extends ReactiveElement { declare global { interface HTMLElementTagNameMap { - "overview-lights-view-strategy": OverviewLightsViewStrategy; + "home-lights-view-strategy": HomeLightsViewStrategy; } } diff --git a/src/panels/lovelace/strategies/overview/overview-home-view-strategy.ts b/src/panels/lovelace/strategies/home/home-main-view-strategy.ts similarity index 67% rename from src/panels/lovelace/strategies/overview/overview-home-view-strategy.ts rename to src/panels/lovelace/strategies/home/home-main-view-strategy.ts index e32da5674c..93a4520703 100644 --- a/src/panels/lovelace/strategies/overview/overview-home-view-strategy.ts +++ b/src/panels/lovelace/strategies/home/home-main-view-strategy.ts @@ -1,6 +1,9 @@ import { ReactiveElement } from "lit"; import { customElement } from "lit/decorators"; +import { isComponentLoaded } from "../../../../common/config/is_component_loaded"; +import { generateEntityFilter } from "../../../../common/entity/entity_filter"; import type { AreaRegistryEntry } from "../../../../data/area_registry"; +import { getEnergyPreferences } from "../../../../data/energy"; import type { LovelaceSectionConfig } from "../../../../data/lovelace/config/section"; import type { LovelaceViewConfig } from "../../../../data/lovelace/config/view"; import type { HomeAssistant } from "../../../../types"; @@ -9,12 +12,13 @@ import type { ButtonCardConfig, MarkdownCardConfig, TileCardConfig, + WeatherForecastCardConfig, } from "../../cards/types"; import { getAreas } from "../areas/helpers/areas-strategy-helper"; -import { OVERVIEW_SUMMARIES_ICONS } from "./helpers/overview-summaries"; +import { HOME_SUMMARIES_ICONS } from "./helpers/home-summaries"; -export interface OverviewHomeViewStrategyConfig { - type: "overview-home"; +export interface HomeMainViewStrategyConfig { + type: "home-main"; favorite_entities?: string[]; } @@ -44,10 +48,10 @@ const computeAreaCard = ( }; }; -@customElement("overview-home-view-strategy") -export class OverviewHomeViewStrategy extends ReactiveElement { +@customElement("home-main-view-strategy") +export class HomeMainViewStrategy extends ReactiveElement { static async generate( - config: OverviewHomeViewStrategyConfig, + config: HomeMainViewStrategyConfig, hass: HomeAssistant ): Promise { const areas = getAreas(hass.areas); @@ -107,7 +111,7 @@ export class OverviewHomeViewStrategy extends ReactiveElement { }, { type: "button", - icon: OVERVIEW_SUMMARIES_ICONS.lights, + icon: HOME_SUMMARIES_ICONS.lights, name: "Lights", icon_height: "24px", grid_options: { @@ -121,7 +125,7 @@ export class OverviewHomeViewStrategy extends ReactiveElement { } satisfies ButtonCardConfig, { type: "button", - icon: OVERVIEW_SUMMARIES_ICONS.climate, + icon: HOME_SUMMARIES_ICONS.climate, name: "Climate", icon_height: "30px", grid_options: { @@ -135,7 +139,7 @@ export class OverviewHomeViewStrategy extends ReactiveElement { } satisfies ButtonCardConfig, { type: "button", - icon: OVERVIEW_SUMMARIES_ICONS.security, + icon: HOME_SUMMARIES_ICONS.security, name: "Security", icon_height: "30px", grid_options: { @@ -149,7 +153,7 @@ export class OverviewHomeViewStrategy extends ReactiveElement { } satisfies ButtonCardConfig, { type: "button", - icon: OVERVIEW_SUMMARIES_ICONS.media_players, + icon: HOME_SUMMARIES_ICONS.media_players, name: "Media Players", icon_height: "30px", grid_options: { @@ -161,27 +165,62 @@ export class OverviewHomeViewStrategy extends ReactiveElement { navigation_path: "media-players", }, } satisfies ButtonCardConfig, - { - type: "button", - icon: "mdi:lightning-bolt", - name: "Energy", - icon_height: "30px", - grid_options: { - rows: 2, - columns: 4, - }, - tap_action: { - action: "navigate", - navigation_path: "/energy?historyBack=1", - }, - } satisfies ButtonCardConfig, ], }; + const weatherFilter = generateEntityFilter(hass, { + domain: "weather", + entity_category: "none", + }); + + const widgetSection: LovelaceSectionConfig = { + type: "grid", + column_span: maxColumns, + cards: [], + }; + const weatherEntity = Object.keys(hass.states).find(weatherFilter); + + if (weatherEntity) { + widgetSection.cards!.push( + { + type: "heading", + heading: "", + heading_style: "subtitle", + }, + { + type: "weather-forecast", + entity: weatherEntity, + forecast_type: "daily", + } as WeatherForecastCardConfig + ); + } + + const energyPrefs = isComponentLoaded(hass, "energy") + ? // It raises if not configured, just swallow that. + await getEnergyPreferences(hass).catch(() => undefined) + : undefined; + + if (energyPrefs) { + const grid = energyPrefs.energy_sources.find( + (source) => source.type === "grid" + ); + + if (grid && grid.flow_from.length > 0) { + widgetSection.cards!.push({ + title: hass.localize( + "ui.panel.lovelace.cards.energy.energy_distribution.title_today" + ), + type: "energy-distribution", + link_dashboard: true, + }); + } + } + const sections = [ ...(favoriteSection.cards ? [favoriteSection] : []), summarySection, areasSection, + ...(widgetSection.cards ? [widgetSection] : []), ]; return { type: "sections", @@ -201,6 +240,6 @@ export class OverviewHomeViewStrategy extends ReactiveElement { declare global { interface HTMLElementTagNameMap { - "overview-home-view-strategy": OverviewHomeViewStrategy; + "home-main-view-strategy": HomeMainViewStrategy; } } diff --git a/src/panels/lovelace/strategies/overview/overview-media-players-view-strategy.ts b/src/panels/lovelace/strategies/home/home-media-players-view-strategy.ts similarity index 85% rename from src/panels/lovelace/strategies/overview/overview-media-players-view-strategy.ts rename to src/panels/lovelace/strategies/home/home-media-players-view-strategy.ts index d268f2bad6..b3184fb7ab 100644 --- a/src/panels/lovelace/strategies/overview/overview-media-players-view-strategy.ts +++ b/src/panels/lovelace/strategies/home/home-media-players-view-strategy.ts @@ -9,14 +9,11 @@ import type { LovelaceViewConfig } from "../../../../data/lovelace/config/view"; import type { HomeAssistant } from "../../../../types"; import type { MediaControlCardConfig } from "../../cards/types"; import { getAreas, getFloors } from "../areas/helpers/areas-strategy-helper"; -import { getHomeStructure } from "./helpers/overview-home-structure"; -import { - findEntities, - OVERVIEW_SUMMARIES_FILTERS, -} from "./helpers/overview-summaries"; +import { getHomeStructure } from "./helpers/home-structure"; +import { findEntities, HOME_SUMMARIES_FILTERS } from "./helpers/home-summaries"; -export interface OvervieMediaPlayersViewStrategyConfig { - type: "overview-media-players"; +export interface HomeMediaPlayersViewStrategyConfig { + type: "home-media-players"; } const processAreasForMediaPlayers = ( @@ -59,10 +56,10 @@ const processAreasForMediaPlayers = ( return cards; }; -@customElement("overview-media-players-view-strategy") -export class OverviewMediaPlayersViewStrategy extends ReactiveElement { +@customElement("home-media-players-view-strategy") +export class HomeMMediaPlayersViewStrategy extends ReactiveElement { static async generate( - _config: OvervieMediaPlayersViewStrategyConfig, + _config: HomeMediaPlayersViewStrategyConfig, hass: HomeAssistant ): Promise { const areas = getAreas(hass.areas); @@ -73,8 +70,8 @@ export class OverviewMediaPlayersViewStrategy extends ReactiveElement { const allEntities = Object.keys(hass.states); - const filterFunctions = OVERVIEW_SUMMARIES_FILTERS.media_players.map( - (filter) => generateEntityFilter(hass, filter) + const filterFunctions = HOME_SUMMARIES_FILTERS.media_players.map((filter) => + generateEntityFilter(hass, filter) ); const entities = findEntities(allEntities, filterFunctions); @@ -145,6 +142,6 @@ export class OverviewMediaPlayersViewStrategy extends ReactiveElement { declare global { interface HTMLElementTagNameMap { - "overview-media-players-view-strategy": OverviewMediaPlayersViewStrategy; + "home-media-players-view-strategy": HomeMMediaPlayersViewStrategy; } } diff --git a/src/panels/lovelace/strategies/overview/overview-security-view-strategy.ts b/src/panels/lovelace/strategies/home/home-security-view-strategy.ts similarity index 87% rename from src/panels/lovelace/strategies/overview/overview-security-view-strategy.ts rename to src/panels/lovelace/strategies/home/home-security-view-strategy.ts index f68e95e462..699ee1400f 100644 --- a/src/panels/lovelace/strategies/overview/overview-security-view-strategy.ts +++ b/src/panels/lovelace/strategies/home/home-security-view-strategy.ts @@ -11,15 +11,12 @@ import { getAreas, getFloors, } from "../areas/helpers/areas-strategy-helper"; -import { - findEntities, - OVERVIEW_SUMMARIES_FILTERS, -} from "./helpers/overview-summaries"; -import { getHomeStructure } from "./helpers/overview-home-structure"; +import { findEntities, HOME_SUMMARIES_FILTERS } from "./helpers/home-summaries"; +import { getHomeStructure } from "./helpers/home-structure"; import type { LovelaceCardConfig } from "../../../../data/lovelace/config/card"; -export interface OverviewSecurityViewStrategyConfig { - type: "overview-security"; +export interface HomeSecurityViewStrategyConfig { + type: "home-security"; } const processAreasForSecurity = ( @@ -61,10 +58,10 @@ const processAreasForSecurity = ( return cards; }; -@customElement("overview-security-view-strategy") -export class OverviewSecurityViewStrategy extends ReactiveElement { +@customElement("home-security-view-strategy") +export class HomeSecurityViewStrategy extends ReactiveElement { static async generate( - _config: OverviewSecurityViewStrategyConfig, + _config: HomeSecurityViewStrategyConfig, hass: HomeAssistant ): Promise { const areas = getAreas(hass.areas); @@ -75,7 +72,7 @@ export class OverviewSecurityViewStrategy extends ReactiveElement { const allEntities = Object.keys(hass.states); - const filterFunctions = OVERVIEW_SUMMARIES_FILTERS.security.map((filter) => + const filterFunctions = HOME_SUMMARIES_FILTERS.security.map((filter) => generateEntityFilter(hass, filter) ); @@ -147,6 +144,6 @@ export class OverviewSecurityViewStrategy extends ReactiveElement { declare global { interface HTMLElementTagNameMap { - "overview-security-view-strategy": OverviewSecurityViewStrategy; + "home-security-view-strategy": HomeSecurityViewStrategy; } } diff --git a/src/translations/en.json b/src/translations/en.json index 84a3c086ab..cdc1a1f3de 100644 --- a/src/translations/en.json +++ b/src/translations/en.json @@ -3361,7 +3361,11 @@ "description": "Display your devices grouped by area" }, "overview": { - "title": "Overview (experimental)", + "title": "Overview", + "description": "Gives an overview of all your entities and areas they are in" + }, + "home": { + "title": "Home (experimental)", "description": "Global overview of your home" } },