mirror of
https://github.com/home-assistant/frontend.git
synced 2026-05-08 17:28:46 +01:00
Rename overview to home and add widget section (#26715)
This commit is contained in:
|
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 12 KiB |
|
Before Width: | Height: | Size: 9.8 KiB After Width: | Height: | Size: 9.8 KiB |
@@ -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);
|
||||
|
||||
@@ -33,7 +33,7 @@ const STRATEGIES: Record<LovelaceStrategyConfigType, Record<string, any>> = {
|
||||
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<LovelaceStrategyConfigType, Record<string, any>> = {
|
||||
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: {},
|
||||
};
|
||||
|
||||
+7
-7
@@ -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;
|
||||
}
|
||||
}
|
||||
+4
-7
@@ -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<OverviewSummaries, string> = {
|
||||
export const HOME_SUMMARIES_ICONS: Record<HomeSummaries, string> = {
|
||||
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<HomeSummaries, EntityFilter[]> = {
|
||||
lights: [{ domain: "light", entity_category: "none" }],
|
||||
climate: [
|
||||
{ domain: "climate", entity_category: "none" },
|
||||
+18
-22
@@ -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<LovelaceViewConfig> {
|
||||
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<OverviewSummaries, string[]>
|
||||
{} as Record<HomeSummaries, string[]>
|
||||
);
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
+9
-12
@@ -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<LovelaceViewConfig> {
|
||||
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;
|
||||
}
|
||||
}
|
||||
+23
-23
@@ -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<LovelaceConfig> {
|
||||
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<LovelaceStrategyEditor> {
|
||||
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;
|
||||
}
|
||||
}
|
||||
+9
-12
@@ -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<LovelaceViewConfig> {
|
||||
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;
|
||||
}
|
||||
}
|
||||
+64
-25
@@ -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<LovelaceViewConfig> {
|
||||
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;
|
||||
}
|
||||
}
|
||||
+10
-13
@@ -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<LovelaceViewConfig> {
|
||||
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;
|
||||
}
|
||||
}
|
||||
+9
-12
@@ -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<LovelaceViewConfig> {
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -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"
|
||||
}
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user