mirror of
https://github.com/home-assistant/frontend.git
synced 2026-05-08 09:18:34 +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 = [
|
const STRATEGIES = [
|
||||||
{
|
{
|
||||||
type: "default",
|
type: "overview",
|
||||||
images: {
|
images: {
|
||||||
light:
|
light:
|
||||||
"/static/images/dashboard-options/light/icon-dashboard-default.svg",
|
"/static/images/dashboard-options/light/icon-dashboard-overview.svg",
|
||||||
dark: "/static/images/dashboard-options/dark/icon-dashboard-default.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:
|
description:
|
||||||
"ui.panel.config.lovelace.dashboards.dialog_new.strategy.default.description",
|
"ui.panel.config.lovelace.dashboards.dialog_new.strategy.overview.description",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type: "areas",
|
type: "areas",
|
||||||
@@ -47,14 +47,14 @@ const STRATEGIES = [
|
|||||||
"ui.panel.config.lovelace.dashboards.dialog_new.strategy.areas.description",
|
"ui.panel.config.lovelace.dashboards.dialog_new.strategy.areas.description",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type: "overview",
|
type: "home",
|
||||||
images: {
|
images: {
|
||||||
light: "/static/images/dashboard-options/light/icon-dashboard-areas.svg",
|
light: "/static/images/dashboard-options/light/icon-dashboard-areas.svg",
|
||||||
dark: "/static/images/dashboard-options/dark/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:
|
description:
|
||||||
"ui.panel.config.lovelace.dashboards.dialog_new.strategy.overview.description",
|
"ui.panel.config.lovelace.dashboards.dialog_new.strategy.home.description",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type: "map",
|
type: "map",
|
||||||
@@ -254,7 +254,7 @@ class DialogNewDashboard extends LitElement implements HassDialog {
|
|||||||
if (target.config) {
|
if (target.config) {
|
||||||
config = target.config;
|
config = target.config;
|
||||||
} else if (target.strategy) {
|
} else if (target.strategy) {
|
||||||
if (target.strategy === "default") {
|
if (target.strategy === "overview") {
|
||||||
config = null;
|
config = null;
|
||||||
} else {
|
} else {
|
||||||
config = this._generateStrategyConfig(target.strategy);
|
config = this._generateStrategyConfig(target.strategy);
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ const STRATEGIES: Record<LovelaceStrategyConfigType, Record<string, any>> = {
|
|||||||
map: () => import("./map/map-dashboard-strategy"),
|
map: () => import("./map/map-dashboard-strategy"),
|
||||||
iframe: () => import("./iframe/iframe-dashboard-strategy"),
|
iframe: () => import("./iframe/iframe-dashboard-strategy"),
|
||||||
areas: () => import("./areas/areas-dashboard-strategy"),
|
areas: () => import("./areas/areas-dashboard-strategy"),
|
||||||
overview: () => import("./overview/overview-dashboard-strategy"),
|
home: () => import("./home/home-dashboard-strategy"),
|
||||||
},
|
},
|
||||||
view: {
|
view: {
|
||||||
"original-states": () =>
|
"original-states": () =>
|
||||||
@@ -43,15 +43,13 @@ const STRATEGIES: Record<LovelaceStrategyConfigType, Record<string, any>> = {
|
|||||||
iframe: () => import("./iframe/iframe-view-strategy"),
|
iframe: () => import("./iframe/iframe-view-strategy"),
|
||||||
area: () => import("./areas/area-view-strategy"),
|
area: () => import("./areas/area-view-strategy"),
|
||||||
"areas-overview": () => import("./areas/areas-overview-view-strategy"),
|
"areas-overview": () => import("./areas/areas-overview-view-strategy"),
|
||||||
"overview-home": () => import("./overview/overview-home-view-strategy"),
|
"home-main": () => import("./home/home-main-view-strategy"),
|
||||||
"overview-lights": () => import("./overview/overview-lights-view-strategy"),
|
"home-lights": () => import("./home/home-lights-view-strategy"),
|
||||||
"overview-climate": () =>
|
"home-climate": () => import("./home/home-climate-view-strategy"),
|
||||||
import("./overview/overview-climate-view-strategy"),
|
"home-security": () => import("./home/home-security-view-strategy"),
|
||||||
"overview-security": () =>
|
"home-media-players": () =>
|
||||||
import("./overview/overview-security-view-strategy"),
|
import("./home/home-media-players-view-strategy"),
|
||||||
"overview-media-players": () =>
|
"home-area": () => import("./home/home-area-view-strategy"),
|
||||||
import("./overview/overview-media-players-view-strategy"),
|
|
||||||
"overview-area": () => import("./overview/overview-area-view-strategy"),
|
|
||||||
},
|
},
|
||||||
section: {},
|
section: {},
|
||||||
};
|
};
|
||||||
|
|||||||
+7
-7
@@ -4,19 +4,19 @@ import { fireEvent } from "../../../../../common/dom/fire_event";
|
|||||||
import "../../../../../components/entity/ha-entities-picker";
|
import "../../../../../components/entity/ha-entities-picker";
|
||||||
import type { HomeAssistant } from "../../../../../types";
|
import type { HomeAssistant } from "../../../../../types";
|
||||||
import type { LovelaceStrategyEditor } 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")
|
@customElement("hui-home-dashboard-strategy-editor")
|
||||||
export class HuiOverviewDashboardStrategyEditor
|
export class HuiHomeDashboardStrategyEditor
|
||||||
extends LitElement
|
extends LitElement
|
||||||
implements LovelaceStrategyEditor
|
implements LovelaceStrategyEditor
|
||||||
{
|
{
|
||||||
@property({ attribute: false }) public hass?: HomeAssistant;
|
@property({ attribute: false }) public hass?: HomeAssistant;
|
||||||
|
|
||||||
@state()
|
@state()
|
||||||
private _config?: OverviewDashboardStrategyConfig;
|
private _config?: HomeDashboardStrategyConfig;
|
||||||
|
|
||||||
public setConfig(config: OverviewDashboardStrategyConfig): void {
|
public setConfig(config: HomeDashboardStrategyConfig): void {
|
||||||
this._config = config;
|
this._config = config;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -47,7 +47,7 @@ export class HuiOverviewDashboardStrategyEditor
|
|||||||
|
|
||||||
const favoriteEntities = ev.detail.value as string[];
|
const favoriteEntities = ev.detail.value as string[];
|
||||||
|
|
||||||
const config: OverviewDashboardStrategyConfig = {
|
const config: HomeDashboardStrategyConfig = {
|
||||||
...this._config,
|
...this._config,
|
||||||
favorite_entities: favoriteEntities,
|
favorite_entities: favoriteEntities,
|
||||||
};
|
};
|
||||||
@@ -62,6 +62,6 @@ export class HuiOverviewDashboardStrategyEditor
|
|||||||
|
|
||||||
declare global {
|
declare global {
|
||||||
interface HTMLElementTagNameMap {
|
interface HTMLElementTagNameMap {
|
||||||
"hui-overview-dashboard-strategy-editor": HuiOverviewDashboardStrategyEditor;
|
"hui-home-dashboard-strategy-editor": HuiHomeDashboardStrategyEditor;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+4
-7
@@ -3,26 +3,23 @@ import type {
|
|||||||
EntityFilterFunc,
|
EntityFilterFunc,
|
||||||
} from "../../../../../common/entity/entity_filter";
|
} from "../../../../../common/entity/entity_filter";
|
||||||
|
|
||||||
export const OVERVIEW_SUMMARIES = [
|
export const HOME_SUMMARIES = [
|
||||||
"lights",
|
"lights",
|
||||||
"climate",
|
"climate",
|
||||||
"security",
|
"security",
|
||||||
"media_players",
|
"media_players",
|
||||||
] as const;
|
] 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",
|
lights: "mdi:lamps",
|
||||||
climate: "mdi:home-thermometer",
|
climate: "mdi:home-thermometer",
|
||||||
security: "mdi:security",
|
security: "mdi:security",
|
||||||
media_players: "mdi:multimedia",
|
media_players: "mdi:multimedia",
|
||||||
};
|
};
|
||||||
|
|
||||||
export const OVERVIEW_SUMMARIES_FILTERS: Record<
|
export const HOME_SUMMARIES_FILTERS: Record<HomeSummaries, EntityFilter[]> = {
|
||||||
OverviewSummaries,
|
|
||||||
EntityFilter[]
|
|
||||||
> = {
|
|
||||||
lights: [{ domain: "light", entity_category: "none" }],
|
lights: [{ domain: "light", entity_category: "none" }],
|
||||||
climate: [
|
climate: [
|
||||||
{ domain: "climate", entity_category: "none" },
|
{ 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 { computeAreaTileCardConfig } from "../areas/helpers/areas-strategy-helper";
|
||||||
import {
|
import {
|
||||||
findEntities,
|
findEntities,
|
||||||
OVERVIEW_SUMMARIES,
|
HOME_SUMMARIES,
|
||||||
OVERVIEW_SUMMARIES_FILTERS,
|
HOME_SUMMARIES_FILTERS,
|
||||||
OVERVIEW_SUMMARIES_ICONS,
|
HOME_SUMMARIES_ICONS,
|
||||||
type OverviewSummaries,
|
type HomeSummaries,
|
||||||
} from "./helpers/overview-summaries";
|
} from "./helpers/home-summaries";
|
||||||
|
|
||||||
export interface OverviewAreaViewStrategyConfig {
|
export interface HomeAreaViewStrategyConfig {
|
||||||
type: "overview-area";
|
type: "home-area";
|
||||||
area?: string;
|
area?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -42,10 +42,10 @@ const computeHeadingCard = (
|
|||||||
: undefined,
|
: undefined,
|
||||||
}) satisfies HeadingCardConfig;
|
}) satisfies HeadingCardConfig;
|
||||||
|
|
||||||
@customElement("overview-area-view-strategy")
|
@customElement("home-area-view-strategy")
|
||||||
export class OverviewAreaViewStrategy extends ReactiveElement {
|
export class HomeAreaViewStrategy extends ReactiveElement {
|
||||||
static async generate(
|
static async generate(
|
||||||
config: OverviewAreaViewStrategyConfig,
|
config: HomeAreaViewStrategyConfig,
|
||||||
hass: HomeAssistant
|
hass: HomeAssistant
|
||||||
): Promise<LovelaceViewConfig> {
|
): Promise<LovelaceViewConfig> {
|
||||||
if (!config.area) {
|
if (!config.area) {
|
||||||
@@ -87,16 +87,16 @@ export class OverviewAreaViewStrategy extends ReactiveElement {
|
|||||||
const allEntities = Object.keys(hass.states);
|
const allEntities = Object.keys(hass.states);
|
||||||
const areaEntities = allEntities.filter(areaFilter);
|
const areaEntities = allEntities.filter(areaFilter);
|
||||||
|
|
||||||
const entitiesBySummary = OVERVIEW_SUMMARIES.reduce(
|
const entitiesBySummary = HOME_SUMMARIES.reduce(
|
||||||
(acc, summary) => {
|
(acc, summary) => {
|
||||||
const summariesFilters = OVERVIEW_SUMMARIES_FILTERS[summary];
|
const summariesFilters = HOME_SUMMARIES_FILTERS[summary];
|
||||||
const filterFunctions = summariesFilters.map((filter) =>
|
const filterFunctions = summariesFilters.map((filter) =>
|
||||||
generateEntityFilter(hass, filter)
|
generateEntityFilter(hass, filter)
|
||||||
);
|
);
|
||||||
acc[summary] = findEntities(areaEntities, filterFunctions);
|
acc[summary] = findEntities(areaEntities, filterFunctions);
|
||||||
return acc;
|
return acc;
|
||||||
},
|
},
|
||||||
{} as Record<OverviewSummaries, string[]>
|
{} as Record<HomeSummaries, string[]>
|
||||||
);
|
);
|
||||||
|
|
||||||
const {
|
const {
|
||||||
@@ -110,11 +110,7 @@ export class OverviewAreaViewStrategy extends ReactiveElement {
|
|||||||
sections.push({
|
sections.push({
|
||||||
type: "grid",
|
type: "grid",
|
||||||
cards: [
|
cards: [
|
||||||
computeHeadingCard(
|
computeHeadingCard("Lights", HOME_SUMMARIES_ICONS.lights, "lights"),
|
||||||
"Lights",
|
|
||||||
OVERVIEW_SUMMARIES_ICONS.lights,
|
|
||||||
"lights"
|
|
||||||
),
|
|
||||||
...lights.map(computeTileCard),
|
...lights.map(computeTileCard),
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
@@ -126,7 +122,7 @@ export class OverviewAreaViewStrategy extends ReactiveElement {
|
|||||||
cards: [
|
cards: [
|
||||||
computeHeadingCard(
|
computeHeadingCard(
|
||||||
"Climate",
|
"Climate",
|
||||||
OVERVIEW_SUMMARIES_ICONS.climate,
|
HOME_SUMMARIES_ICONS.climate,
|
||||||
"climate"
|
"climate"
|
||||||
),
|
),
|
||||||
...climate.map(computeTileCard),
|
...climate.map(computeTileCard),
|
||||||
@@ -140,7 +136,7 @@ export class OverviewAreaViewStrategy extends ReactiveElement {
|
|||||||
cards: [
|
cards: [
|
||||||
computeHeadingCard(
|
computeHeadingCard(
|
||||||
"Security",
|
"Security",
|
||||||
OVERVIEW_SUMMARIES_ICONS.security,
|
HOME_SUMMARIES_ICONS.security,
|
||||||
"security"
|
"security"
|
||||||
),
|
),
|
||||||
...security.map(computeTileCard),
|
...security.map(computeTileCard),
|
||||||
@@ -154,7 +150,7 @@ export class OverviewAreaViewStrategy extends ReactiveElement {
|
|||||||
cards: [
|
cards: [
|
||||||
computeHeadingCard(
|
computeHeadingCard(
|
||||||
"Media players",
|
"Media players",
|
||||||
OVERVIEW_SUMMARIES_ICONS.media_players,
|
HOME_SUMMARIES_ICONS.media_players,
|
||||||
"media-players"
|
"media-players"
|
||||||
),
|
),
|
||||||
...mediaPlayers.map(computeTileCard),
|
...mediaPlayers.map(computeTileCard),
|
||||||
@@ -310,6 +306,6 @@ export class OverviewAreaViewStrategy extends ReactiveElement {
|
|||||||
|
|
||||||
declare global {
|
declare global {
|
||||||
interface HTMLElementTagNameMap {
|
interface HTMLElementTagNameMap {
|
||||||
"overview-area-view-strategy": OverviewAreaViewStrategy;
|
"home-area-view-strategy": HomeAreaViewStrategy;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+9
-12
@@ -12,14 +12,11 @@ import {
|
|||||||
getAreas,
|
getAreas,
|
||||||
getFloors,
|
getFloors,
|
||||||
} from "../areas/helpers/areas-strategy-helper";
|
} from "../areas/helpers/areas-strategy-helper";
|
||||||
import { getHomeStructure } from "./helpers/overview-home-structure";
|
import { getHomeStructure } from "./helpers/home-structure";
|
||||||
import {
|
import { findEntities, HOME_SUMMARIES_FILTERS } from "./helpers/home-summaries";
|
||||||
findEntities,
|
|
||||||
OVERVIEW_SUMMARIES_FILTERS,
|
|
||||||
} from "./helpers/overview-summaries";
|
|
||||||
|
|
||||||
export interface OverviewClimateViewStrategyConfig {
|
export interface HomeClimateViewStrategyConfig {
|
||||||
type: "overview-climate";
|
type: "home-climate";
|
||||||
}
|
}
|
||||||
|
|
||||||
const processAreasForClimate = (
|
const processAreasForClimate = (
|
||||||
@@ -61,10 +58,10 @@ const processAreasForClimate = (
|
|||||||
return cards;
|
return cards;
|
||||||
};
|
};
|
||||||
|
|
||||||
@customElement("overview-climate-view-strategy")
|
@customElement("home-climate-view-strategy")
|
||||||
export class OverviewClimateViewStrategy extends ReactiveElement {
|
export class HomeClimateViewStrategy extends ReactiveElement {
|
||||||
static async generate(
|
static async generate(
|
||||||
_config: OverviewClimateViewStrategyConfig,
|
_config: HomeClimateViewStrategyConfig,
|
||||||
hass: HomeAssistant
|
hass: HomeAssistant
|
||||||
): Promise<LovelaceViewConfig> {
|
): Promise<LovelaceViewConfig> {
|
||||||
const areas = getAreas(hass.areas);
|
const areas = getAreas(hass.areas);
|
||||||
@@ -75,7 +72,7 @@ export class OverviewClimateViewStrategy extends ReactiveElement {
|
|||||||
|
|
||||||
const allEntities = Object.keys(hass.states);
|
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)
|
generateEntityFilter(hass, filter)
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -147,6 +144,6 @@ export class OverviewClimateViewStrategy extends ReactiveElement {
|
|||||||
|
|
||||||
declare global {
|
declare global {
|
||||||
interface HTMLElementTagNameMap {
|
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 type { HomeAssistant } from "../../../../types";
|
||||||
import { getAreas } from "../areas/helpers/areas-strategy-helper";
|
import { getAreas } from "../areas/helpers/areas-strategy-helper";
|
||||||
import type { LovelaceStrategyEditor } from "../types";
|
import type { LovelaceStrategyEditor } from "../types";
|
||||||
import { OVERVIEW_SUMMARIES_ICONS } from "./helpers/overview-summaries";
|
import { HOME_SUMMARIES_ICONS } from "./helpers/home-summaries";
|
||||||
import type { OverviewAreaViewStrategyConfig } from "./overview-area-view-strategy";
|
import type { HomeAreaViewStrategyConfig } from "./home-area-view-strategy";
|
||||||
import type { OverviewHomeViewStrategyConfig } from "./overview-home-view-strategy";
|
import type { HomeMainViewStrategyConfig } from "./home-main-view-strategy";
|
||||||
|
|
||||||
export interface OverviewDashboardStrategyConfig {
|
export interface HomeDashboardStrategyConfig {
|
||||||
type: "overview";
|
type: "home";
|
||||||
favorite_entities?: string[];
|
favorite_entities?: string[];
|
||||||
}
|
}
|
||||||
|
|
||||||
@customElement("overview-dashboard-strategy")
|
@customElement("home-dashboard-strategy")
|
||||||
export class OverviewDashboardStrategy extends ReactiveElement {
|
export class HomeDashboardStrategy extends ReactiveElement {
|
||||||
static async generate(
|
static async generate(
|
||||||
config: OverviewDashboardStrategyConfig,
|
config: HomeDashboardStrategyConfig,
|
||||||
hass: HomeAssistant
|
hass: HomeAssistant
|
||||||
): Promise<LovelaceConfig> {
|
): Promise<LovelaceConfig> {
|
||||||
if (hass.config.state === STATE_NOT_RUNNING) {
|
if (hass.config.state === STATE_NOT_RUNNING) {
|
||||||
@@ -53,9 +53,9 @@ export class OverviewDashboardStrategy extends ReactiveElement {
|
|||||||
path: path,
|
path: path,
|
||||||
subview: true,
|
subview: true,
|
||||||
strategy: {
|
strategy: {
|
||||||
type: "overview-area",
|
type: "home-area",
|
||||||
area: area.area_id,
|
area: area.area_id,
|
||||||
} satisfies OverviewAreaViewStrategyConfig,
|
} satisfies HomeAreaViewStrategyConfig,
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -64,9 +64,9 @@ export class OverviewDashboardStrategy extends ReactiveElement {
|
|||||||
path: "lights",
|
path: "lights",
|
||||||
subview: true,
|
subview: true,
|
||||||
strategy: {
|
strategy: {
|
||||||
type: "overview-lights",
|
type: "home-lights",
|
||||||
},
|
},
|
||||||
icon: OVERVIEW_SUMMARIES_ICONS.lights,
|
icon: HOME_SUMMARIES_ICONS.lights,
|
||||||
} satisfies LovelaceViewRawConfig;
|
} satisfies LovelaceViewRawConfig;
|
||||||
|
|
||||||
const climateView = {
|
const climateView = {
|
||||||
@@ -74,9 +74,9 @@ export class OverviewDashboardStrategy extends ReactiveElement {
|
|||||||
path: "climate",
|
path: "climate",
|
||||||
subview: true,
|
subview: true,
|
||||||
strategy: {
|
strategy: {
|
||||||
type: "overview-climate",
|
type: "home-climate",
|
||||||
},
|
},
|
||||||
icon: OVERVIEW_SUMMARIES_ICONS.climate,
|
icon: HOME_SUMMARIES_ICONS.climate,
|
||||||
} satisfies LovelaceViewRawConfig;
|
} satisfies LovelaceViewRawConfig;
|
||||||
|
|
||||||
const securityView = {
|
const securityView = {
|
||||||
@@ -84,9 +84,9 @@ export class OverviewDashboardStrategy extends ReactiveElement {
|
|||||||
path: "security",
|
path: "security",
|
||||||
subview: true,
|
subview: true,
|
||||||
strategy: {
|
strategy: {
|
||||||
type: "overview-security",
|
type: "home-security",
|
||||||
},
|
},
|
||||||
icon: OVERVIEW_SUMMARIES_ICONS.security,
|
icon: HOME_SUMMARIES_ICONS.security,
|
||||||
} satisfies LovelaceViewRawConfig;
|
} satisfies LovelaceViewRawConfig;
|
||||||
|
|
||||||
const mediaPlayersView = {
|
const mediaPlayersView = {
|
||||||
@@ -94,9 +94,9 @@ export class OverviewDashboardStrategy extends ReactiveElement {
|
|||||||
path: "media-players",
|
path: "media-players",
|
||||||
subview: true,
|
subview: true,
|
||||||
strategy: {
|
strategy: {
|
||||||
type: "overview-media-players",
|
type: "home-media-players",
|
||||||
},
|
},
|
||||||
icon: OVERVIEW_SUMMARIES_ICONS.media_players,
|
icon: HOME_SUMMARIES_ICONS.media_players,
|
||||||
} satisfies LovelaceViewRawConfig;
|
} satisfies LovelaceViewRawConfig;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
@@ -105,9 +105,9 @@ export class OverviewDashboardStrategy extends ReactiveElement {
|
|||||||
icon: "mdi:home",
|
icon: "mdi:home",
|
||||||
path: "home",
|
path: "home",
|
||||||
strategy: {
|
strategy: {
|
||||||
type: "overview-home",
|
type: "home-main",
|
||||||
favorite_entities: config.favorite_entities,
|
favorite_entities: config.favorite_entities,
|
||||||
} satisfies OverviewHomeViewStrategyConfig,
|
} satisfies HomeMainViewStrategyConfig,
|
||||||
},
|
},
|
||||||
...areaViews,
|
...areaViews,
|
||||||
lightView,
|
lightView,
|
||||||
@@ -119,13 +119,13 @@ export class OverviewDashboardStrategy extends ReactiveElement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static async getConfigElement(): Promise<LovelaceStrategyEditor> {
|
public static async getConfigElement(): Promise<LovelaceStrategyEditor> {
|
||||||
await import("./editor/hui-overview-dashboard-strategy-editor");
|
await import("./editor/hui-home-dashboard-strategy-editor");
|
||||||
return document.createElement("hui-overview-dashboard-strategy-editor");
|
return document.createElement("hui-home-dashboard-strategy-editor");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
declare global {
|
declare global {
|
||||||
interface HTMLElementTagNameMap {
|
interface HTMLElementTagNameMap {
|
||||||
"overview-dashboard-strategy": OverviewDashboardStrategy;
|
"home-dashboard-strategy": HomeDashboardStrategy;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+9
-12
@@ -12,14 +12,11 @@ import {
|
|||||||
getAreas,
|
getAreas,
|
||||||
getFloors,
|
getFloors,
|
||||||
} from "../areas/helpers/areas-strategy-helper";
|
} from "../areas/helpers/areas-strategy-helper";
|
||||||
import { getHomeStructure } from "./helpers/overview-home-structure";
|
import { getHomeStructure } from "./helpers/home-structure";
|
||||||
import {
|
import { findEntities, HOME_SUMMARIES_FILTERS } from "./helpers/home-summaries";
|
||||||
findEntities,
|
|
||||||
OVERVIEW_SUMMARIES_FILTERS,
|
|
||||||
} from "./helpers/overview-summaries";
|
|
||||||
|
|
||||||
export interface OverviewLightsViewStrategyConfig {
|
export interface HomeLightsViewStrategyConfig {
|
||||||
type: "overview-lights";
|
type: "home-lights";
|
||||||
}
|
}
|
||||||
|
|
||||||
const processAreasForLights = (
|
const processAreasForLights = (
|
||||||
@@ -61,10 +58,10 @@ const processAreasForLights = (
|
|||||||
return cards;
|
return cards;
|
||||||
};
|
};
|
||||||
|
|
||||||
@customElement("overview-lights-view-strategy")
|
@customElement("home-lights-view-strategy")
|
||||||
export class OverviewLightsViewStrategy extends ReactiveElement {
|
export class HomeLightsViewStrategy extends ReactiveElement {
|
||||||
static async generate(
|
static async generate(
|
||||||
_config: OverviewLightsViewStrategyConfig,
|
_config: HomeLightsViewStrategyConfig,
|
||||||
hass: HomeAssistant
|
hass: HomeAssistant
|
||||||
): Promise<LovelaceViewConfig> {
|
): Promise<LovelaceViewConfig> {
|
||||||
const areas = getAreas(hass.areas);
|
const areas = getAreas(hass.areas);
|
||||||
@@ -75,7 +72,7 @@ export class OverviewLightsViewStrategy extends ReactiveElement {
|
|||||||
|
|
||||||
const allEntities = Object.keys(hass.states);
|
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)
|
generateEntityFilter(hass, filter)
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -147,6 +144,6 @@ export class OverviewLightsViewStrategy extends ReactiveElement {
|
|||||||
|
|
||||||
declare global {
|
declare global {
|
||||||
interface HTMLElementTagNameMap {
|
interface HTMLElementTagNameMap {
|
||||||
"overview-lights-view-strategy": OverviewLightsViewStrategy;
|
"home-lights-view-strategy": HomeLightsViewStrategy;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+64
-25
@@ -1,6 +1,9 @@
|
|||||||
import { ReactiveElement } from "lit";
|
import { ReactiveElement } from "lit";
|
||||||
import { customElement } from "lit/decorators";
|
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 type { AreaRegistryEntry } from "../../../../data/area_registry";
|
||||||
|
import { getEnergyPreferences } from "../../../../data/energy";
|
||||||
import type { LovelaceSectionConfig } from "../../../../data/lovelace/config/section";
|
import type { LovelaceSectionConfig } from "../../../../data/lovelace/config/section";
|
||||||
import type { LovelaceViewConfig } from "../../../../data/lovelace/config/view";
|
import type { LovelaceViewConfig } from "../../../../data/lovelace/config/view";
|
||||||
import type { HomeAssistant } from "../../../../types";
|
import type { HomeAssistant } from "../../../../types";
|
||||||
@@ -9,12 +12,13 @@ import type {
|
|||||||
ButtonCardConfig,
|
ButtonCardConfig,
|
||||||
MarkdownCardConfig,
|
MarkdownCardConfig,
|
||||||
TileCardConfig,
|
TileCardConfig,
|
||||||
|
WeatherForecastCardConfig,
|
||||||
} from "../../cards/types";
|
} from "../../cards/types";
|
||||||
import { getAreas } from "../areas/helpers/areas-strategy-helper";
|
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 {
|
export interface HomeMainViewStrategyConfig {
|
||||||
type: "overview-home";
|
type: "home-main";
|
||||||
favorite_entities?: string[];
|
favorite_entities?: string[];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -44,10 +48,10 @@ const computeAreaCard = (
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
@customElement("overview-home-view-strategy")
|
@customElement("home-main-view-strategy")
|
||||||
export class OverviewHomeViewStrategy extends ReactiveElement {
|
export class HomeMainViewStrategy extends ReactiveElement {
|
||||||
static async generate(
|
static async generate(
|
||||||
config: OverviewHomeViewStrategyConfig,
|
config: HomeMainViewStrategyConfig,
|
||||||
hass: HomeAssistant
|
hass: HomeAssistant
|
||||||
): Promise<LovelaceViewConfig> {
|
): Promise<LovelaceViewConfig> {
|
||||||
const areas = getAreas(hass.areas);
|
const areas = getAreas(hass.areas);
|
||||||
@@ -107,7 +111,7 @@ export class OverviewHomeViewStrategy extends ReactiveElement {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
type: "button",
|
type: "button",
|
||||||
icon: OVERVIEW_SUMMARIES_ICONS.lights,
|
icon: HOME_SUMMARIES_ICONS.lights,
|
||||||
name: "Lights",
|
name: "Lights",
|
||||||
icon_height: "24px",
|
icon_height: "24px",
|
||||||
grid_options: {
|
grid_options: {
|
||||||
@@ -121,7 +125,7 @@ export class OverviewHomeViewStrategy extends ReactiveElement {
|
|||||||
} satisfies ButtonCardConfig,
|
} satisfies ButtonCardConfig,
|
||||||
{
|
{
|
||||||
type: "button",
|
type: "button",
|
||||||
icon: OVERVIEW_SUMMARIES_ICONS.climate,
|
icon: HOME_SUMMARIES_ICONS.climate,
|
||||||
name: "Climate",
|
name: "Climate",
|
||||||
icon_height: "30px",
|
icon_height: "30px",
|
||||||
grid_options: {
|
grid_options: {
|
||||||
@@ -135,7 +139,7 @@ export class OverviewHomeViewStrategy extends ReactiveElement {
|
|||||||
} satisfies ButtonCardConfig,
|
} satisfies ButtonCardConfig,
|
||||||
{
|
{
|
||||||
type: "button",
|
type: "button",
|
||||||
icon: OVERVIEW_SUMMARIES_ICONS.security,
|
icon: HOME_SUMMARIES_ICONS.security,
|
||||||
name: "Security",
|
name: "Security",
|
||||||
icon_height: "30px",
|
icon_height: "30px",
|
||||||
grid_options: {
|
grid_options: {
|
||||||
@@ -149,7 +153,7 @@ export class OverviewHomeViewStrategy extends ReactiveElement {
|
|||||||
} satisfies ButtonCardConfig,
|
} satisfies ButtonCardConfig,
|
||||||
{
|
{
|
||||||
type: "button",
|
type: "button",
|
||||||
icon: OVERVIEW_SUMMARIES_ICONS.media_players,
|
icon: HOME_SUMMARIES_ICONS.media_players,
|
||||||
name: "Media Players",
|
name: "Media Players",
|
||||||
icon_height: "30px",
|
icon_height: "30px",
|
||||||
grid_options: {
|
grid_options: {
|
||||||
@@ -161,27 +165,62 @@ export class OverviewHomeViewStrategy extends ReactiveElement {
|
|||||||
navigation_path: "media-players",
|
navigation_path: "media-players",
|
||||||
},
|
},
|
||||||
} satisfies ButtonCardConfig,
|
} 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 = [
|
const sections = [
|
||||||
...(favoriteSection.cards ? [favoriteSection] : []),
|
...(favoriteSection.cards ? [favoriteSection] : []),
|
||||||
summarySection,
|
summarySection,
|
||||||
areasSection,
|
areasSection,
|
||||||
|
...(widgetSection.cards ? [widgetSection] : []),
|
||||||
];
|
];
|
||||||
return {
|
return {
|
||||||
type: "sections",
|
type: "sections",
|
||||||
@@ -201,6 +240,6 @@ export class OverviewHomeViewStrategy extends ReactiveElement {
|
|||||||
|
|
||||||
declare global {
|
declare global {
|
||||||
interface HTMLElementTagNameMap {
|
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 { HomeAssistant } from "../../../../types";
|
||||||
import type { MediaControlCardConfig } from "../../cards/types";
|
import type { MediaControlCardConfig } from "../../cards/types";
|
||||||
import { getAreas, getFloors } from "../areas/helpers/areas-strategy-helper";
|
import { getAreas, getFloors } from "../areas/helpers/areas-strategy-helper";
|
||||||
import { getHomeStructure } from "./helpers/overview-home-structure";
|
import { getHomeStructure } from "./helpers/home-structure";
|
||||||
import {
|
import { findEntities, HOME_SUMMARIES_FILTERS } from "./helpers/home-summaries";
|
||||||
findEntities,
|
|
||||||
OVERVIEW_SUMMARIES_FILTERS,
|
|
||||||
} from "./helpers/overview-summaries";
|
|
||||||
|
|
||||||
export interface OvervieMediaPlayersViewStrategyConfig {
|
export interface HomeMediaPlayersViewStrategyConfig {
|
||||||
type: "overview-media-players";
|
type: "home-media-players";
|
||||||
}
|
}
|
||||||
|
|
||||||
const processAreasForMediaPlayers = (
|
const processAreasForMediaPlayers = (
|
||||||
@@ -59,10 +56,10 @@ const processAreasForMediaPlayers = (
|
|||||||
return cards;
|
return cards;
|
||||||
};
|
};
|
||||||
|
|
||||||
@customElement("overview-media-players-view-strategy")
|
@customElement("home-media-players-view-strategy")
|
||||||
export class OverviewMediaPlayersViewStrategy extends ReactiveElement {
|
export class HomeMMediaPlayersViewStrategy extends ReactiveElement {
|
||||||
static async generate(
|
static async generate(
|
||||||
_config: OvervieMediaPlayersViewStrategyConfig,
|
_config: HomeMediaPlayersViewStrategyConfig,
|
||||||
hass: HomeAssistant
|
hass: HomeAssistant
|
||||||
): Promise<LovelaceViewConfig> {
|
): Promise<LovelaceViewConfig> {
|
||||||
const areas = getAreas(hass.areas);
|
const areas = getAreas(hass.areas);
|
||||||
@@ -73,8 +70,8 @@ export class OverviewMediaPlayersViewStrategy extends ReactiveElement {
|
|||||||
|
|
||||||
const allEntities = Object.keys(hass.states);
|
const allEntities = Object.keys(hass.states);
|
||||||
|
|
||||||
const filterFunctions = OVERVIEW_SUMMARIES_FILTERS.media_players.map(
|
const filterFunctions = HOME_SUMMARIES_FILTERS.media_players.map((filter) =>
|
||||||
(filter) => generateEntityFilter(hass, filter)
|
generateEntityFilter(hass, filter)
|
||||||
);
|
);
|
||||||
|
|
||||||
const entities = findEntities(allEntities, filterFunctions);
|
const entities = findEntities(allEntities, filterFunctions);
|
||||||
@@ -145,6 +142,6 @@ export class OverviewMediaPlayersViewStrategy extends ReactiveElement {
|
|||||||
|
|
||||||
declare global {
|
declare global {
|
||||||
interface HTMLElementTagNameMap {
|
interface HTMLElementTagNameMap {
|
||||||
"overview-media-players-view-strategy": OverviewMediaPlayersViewStrategy;
|
"home-media-players-view-strategy": HomeMMediaPlayersViewStrategy;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+9
-12
@@ -11,15 +11,12 @@ import {
|
|||||||
getAreas,
|
getAreas,
|
||||||
getFloors,
|
getFloors,
|
||||||
} from "../areas/helpers/areas-strategy-helper";
|
} from "../areas/helpers/areas-strategy-helper";
|
||||||
import {
|
import { findEntities, HOME_SUMMARIES_FILTERS } from "./helpers/home-summaries";
|
||||||
findEntities,
|
import { getHomeStructure } from "./helpers/home-structure";
|
||||||
OVERVIEW_SUMMARIES_FILTERS,
|
|
||||||
} from "./helpers/overview-summaries";
|
|
||||||
import { getHomeStructure } from "./helpers/overview-home-structure";
|
|
||||||
import type { LovelaceCardConfig } from "../../../../data/lovelace/config/card";
|
import type { LovelaceCardConfig } from "../../../../data/lovelace/config/card";
|
||||||
|
|
||||||
export interface OverviewSecurityViewStrategyConfig {
|
export interface HomeSecurityViewStrategyConfig {
|
||||||
type: "overview-security";
|
type: "home-security";
|
||||||
}
|
}
|
||||||
|
|
||||||
const processAreasForSecurity = (
|
const processAreasForSecurity = (
|
||||||
@@ -61,10 +58,10 @@ const processAreasForSecurity = (
|
|||||||
return cards;
|
return cards;
|
||||||
};
|
};
|
||||||
|
|
||||||
@customElement("overview-security-view-strategy")
|
@customElement("home-security-view-strategy")
|
||||||
export class OverviewSecurityViewStrategy extends ReactiveElement {
|
export class HomeSecurityViewStrategy extends ReactiveElement {
|
||||||
static async generate(
|
static async generate(
|
||||||
_config: OverviewSecurityViewStrategyConfig,
|
_config: HomeSecurityViewStrategyConfig,
|
||||||
hass: HomeAssistant
|
hass: HomeAssistant
|
||||||
): Promise<LovelaceViewConfig> {
|
): Promise<LovelaceViewConfig> {
|
||||||
const areas = getAreas(hass.areas);
|
const areas = getAreas(hass.areas);
|
||||||
@@ -75,7 +72,7 @@ export class OverviewSecurityViewStrategy extends ReactiveElement {
|
|||||||
|
|
||||||
const allEntities = Object.keys(hass.states);
|
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)
|
generateEntityFilter(hass, filter)
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -147,6 +144,6 @@ export class OverviewSecurityViewStrategy extends ReactiveElement {
|
|||||||
|
|
||||||
declare global {
|
declare global {
|
||||||
interface HTMLElementTagNameMap {
|
interface HTMLElementTagNameMap {
|
||||||
"overview-security-view-strategy": OverviewSecurityViewStrategy;
|
"home-security-view-strategy": HomeSecurityViewStrategy;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -3361,7 +3361,11 @@
|
|||||||
"description": "Display your devices grouped by area"
|
"description": "Display your devices grouped by area"
|
||||||
},
|
},
|
||||||
"overview": {
|
"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"
|
"description": "Global overview of your home"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user