mirror of
https://github.com/home-assistant/frontend.git
synced 2025-11-09 19:09:48 +00:00
Rename safety panel to security panel (#27796)
This commit is contained in:
committed by
Bram Kragten
parent
d23e45e410
commit
eec99b2fa3
@@ -33,7 +33,7 @@ const COMPONENTS = {
|
|||||||
"media-browser": () =>
|
"media-browser": () =>
|
||||||
import("../panels/media-browser/ha-panel-media-browser"),
|
import("../panels/media-browser/ha-panel-media-browser"),
|
||||||
light: () => import("../panels/light/ha-panel-light"),
|
light: () => import("../panels/light/ha-panel-light"),
|
||||||
safety: () => import("../panels/safety/ha-panel-safety"),
|
security: () => import("../panels/security/ha-panel-security"),
|
||||||
climate: () => import("../panels/climate/ha-panel-climate"),
|
climate: () => import("../panels/climate/ha-panel-climate"),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -332,13 +332,13 @@ export class HaConfigLovelaceDashboards extends LitElement {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.hass.panels.safety) {
|
if (this.hass.panels.security) {
|
||||||
result.push({
|
result.push({
|
||||||
icon: "mdi:security",
|
icon: "mdi:security",
|
||||||
title: this.hass.localize("panel.safety"),
|
title: this.hass.localize("panel.security"),
|
||||||
show_in_sidebar: false,
|
show_in_sidebar: false,
|
||||||
mode: "storage",
|
mode: "storage",
|
||||||
url_path: "safety",
|
url_path: "security",
|
||||||
filename: "",
|
filename: "",
|
||||||
default: false,
|
default: false,
|
||||||
require_admin: false,
|
require_admin: false,
|
||||||
@@ -470,13 +470,13 @@ export class HaConfigLovelaceDashboards extends LitElement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private _canDelete(urlPath: string) {
|
private _canDelete(urlPath: string) {
|
||||||
return !["lovelace", "energy", "light", "safety", "climate"].includes(
|
return !["lovelace", "energy", "light", "security", "climate"].includes(
|
||||||
urlPath
|
urlPath
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
private _canEdit(urlPath: string) {
|
private _canEdit(urlPath: string) {
|
||||||
return !["light", "safety", "climate"].includes(urlPath);
|
return !["light", "security", "climate"].includes(urlPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
private _handleDelete = async (item: DataTableItem) => {
|
private _handleDelete = async (item: DataTableItem) => {
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ import type { HomeSummaryCard } from "./types";
|
|||||||
const COLORS: Record<HomeSummary, string> = {
|
const COLORS: Record<HomeSummary, string> = {
|
||||||
light: "amber",
|
light: "amber",
|
||||||
climate: "deep-orange",
|
climate: "deep-orange",
|
||||||
safety: "blue-grey",
|
security: "blue-grey",
|
||||||
media_players: "blue",
|
media_players: "blue",
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -142,20 +142,20 @@ export class HuiHomeSummaryCard extends LitElement implements LovelaceCard {
|
|||||||
? `${formattedMinTemp}°`
|
? `${formattedMinTemp}°`
|
||||||
: `${formattedMinTemp} - ${formattedMaxTemp}°`;
|
: `${formattedMinTemp} - ${formattedMaxTemp}°`;
|
||||||
}
|
}
|
||||||
case "safety": {
|
case "security": {
|
||||||
// Alarm and lock status
|
// Alarm and lock status
|
||||||
const safetyFilters = HOME_SUMMARIES_FILTERS.safety.map((filter) =>
|
const securityFilters = HOME_SUMMARIES_FILTERS.security.map((filter) =>
|
||||||
generateEntityFilter(this.hass!, filter)
|
generateEntityFilter(this.hass!, filter)
|
||||||
);
|
);
|
||||||
|
|
||||||
const safetyEntities = findEntities(allEntities, safetyFilters);
|
const securityEntities = findEntities(allEntities, securityFilters);
|
||||||
|
|
||||||
const locks = safetyEntities.filter((entityId) => {
|
const locks = securityEntities.filter((entityId) => {
|
||||||
const domain = computeDomain(entityId);
|
const domain = computeDomain(entityId);
|
||||||
return domain === "lock";
|
return domain === "lock";
|
||||||
});
|
});
|
||||||
|
|
||||||
const alarms = safetyEntities.filter((entityId) => {
|
const alarms = securityEntities.filter((entityId) => {
|
||||||
const domain = computeDomain(entityId);
|
const domain = computeDomain(entityId);
|
||||||
return domain === "alarm_control_panel";
|
return domain === "alarm_control_panel";
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ const STRATEGIES: Record<LovelaceStrategyConfigType, Record<string, any>> = {
|
|||||||
import("./home/home-media-players-view-strategy"),
|
import("./home/home-media-players-view-strategy"),
|
||||||
"home-area": () => import("./home/home-area-view-strategy"),
|
"home-area": () => import("./home/home-area-view-strategy"),
|
||||||
light: () => import("../../light/strategies/light-view-strategy"),
|
light: () => import("../../light/strategies/light-view-strategy"),
|
||||||
safety: () => import("../../safety/strategies/safety-view-strategy"),
|
security: () => import("../../security/strategies/security-view-strategy"),
|
||||||
climate: () => import("../../climate/strategies/climate-view-strategy"),
|
climate: () => import("../../climate/strategies/climate-view-strategy"),
|
||||||
},
|
},
|
||||||
section: {
|
section: {
|
||||||
|
|||||||
@@ -2,12 +2,12 @@ import type { EntityFilter } from "../../../../../common/entity/entity_filter";
|
|||||||
import type { LocalizeFunc } from "../../../../../common/translations/localize";
|
import type { LocalizeFunc } from "../../../../../common/translations/localize";
|
||||||
import { climateEntityFilters } from "../../../../climate/strategies/climate-view-strategy";
|
import { climateEntityFilters } from "../../../../climate/strategies/climate-view-strategy";
|
||||||
import { lightEntityFilters } from "../../../../light/strategies/light-view-strategy";
|
import { lightEntityFilters } from "../../../../light/strategies/light-view-strategy";
|
||||||
import { safetyEntityFilters } from "../../../../safety/strategies/safety-view-strategy";
|
import { securityEntityFilters } from "../../../../security/strategies/security-view-strategy";
|
||||||
|
|
||||||
export const HOME_SUMMARIES = [
|
export const HOME_SUMMARIES = [
|
||||||
"light",
|
"light",
|
||||||
"climate",
|
"climate",
|
||||||
"safety",
|
"security",
|
||||||
"media_players",
|
"media_players",
|
||||||
] as const;
|
] as const;
|
||||||
|
|
||||||
@@ -16,14 +16,14 @@ export type HomeSummary = (typeof HOME_SUMMARIES)[number];
|
|||||||
export const HOME_SUMMARIES_ICONS: Record<HomeSummary, string> = {
|
export const HOME_SUMMARIES_ICONS: Record<HomeSummary, string> = {
|
||||||
light: "mdi:lamps",
|
light: "mdi:lamps",
|
||||||
climate: "mdi:home-thermometer",
|
climate: "mdi:home-thermometer",
|
||||||
safety: "mdi:security",
|
security: "mdi:security",
|
||||||
media_players: "mdi:multimedia",
|
media_players: "mdi:multimedia",
|
||||||
};
|
};
|
||||||
|
|
||||||
export const HOME_SUMMARIES_FILTERS: Record<HomeSummary, EntityFilter[]> = {
|
export const HOME_SUMMARIES_FILTERS: Record<HomeSummary, EntityFilter[]> = {
|
||||||
light: lightEntityFilters,
|
light: lightEntityFilters,
|
||||||
climate: climateEntityFilters,
|
climate: climateEntityFilters,
|
||||||
safety: safetyEntityFilters,
|
security: securityEntityFilters,
|
||||||
media_players: [{ domain: "media_player", entity_category: "none" }],
|
media_players: [{ domain: "media_player", entity_category: "none" }],
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -31,7 +31,7 @@ export const getSummaryLabel = (
|
|||||||
localize: LocalizeFunc,
|
localize: LocalizeFunc,
|
||||||
summary: HomeSummary
|
summary: HomeSummary
|
||||||
) => {
|
) => {
|
||||||
if (summary === "light" || summary === "climate" || summary === "safety") {
|
if (summary === "light" || summary === "climate" || summary === "security") {
|
||||||
return localize(`panel.${summary}`);
|
return localize(`panel.${summary}`);
|
||||||
}
|
}
|
||||||
return localize(`ui.panel.lovelace.strategy.home.summary_list.${summary}`);
|
return localize(`ui.panel.lovelace.strategy.home.summary_list.${summary}`);
|
||||||
|
|||||||
@@ -104,7 +104,7 @@ export class HomeAreaViewStrategy extends ReactiveElement {
|
|||||||
const {
|
const {
|
||||||
light,
|
light,
|
||||||
climate,
|
climate,
|
||||||
safety,
|
security,
|
||||||
media_players: mediaPlayers,
|
media_players: mediaPlayers,
|
||||||
} = entitiesBySummary;
|
} = entitiesBySummary;
|
||||||
|
|
||||||
@@ -136,16 +136,16 @@ export class HomeAreaViewStrategy extends ReactiveElement {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (safety.length > 0) {
|
if (security.length > 0) {
|
||||||
sections.push({
|
sections.push({
|
||||||
type: "grid",
|
type: "grid",
|
||||||
cards: [
|
cards: [
|
||||||
computeHeadingCard(
|
computeHeadingCard(
|
||||||
getSummaryLabel(hass.localize, "safety"),
|
getSummaryLabel(hass.localize, "security"),
|
||||||
HOME_SUMMARIES_ICONS.safety,
|
HOME_SUMMARIES_ICONS.security,
|
||||||
"/safety?historyBack=1"
|
"/security?historyBack=1"
|
||||||
),
|
),
|
||||||
...safety.map(computeTileCard),
|
...security.map(computeTileCard),
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -162,7 +162,7 @@ export class HomeMainViewStrategy extends ReactiveElement {
|
|||||||
generateEntityFilter(hass, filter)
|
generateEntityFilter(hass, filter)
|
||||||
);
|
);
|
||||||
|
|
||||||
const safetyFilters = HOME_SUMMARIES_FILTERS.safety.map((filter) =>
|
const securityFilters = HOME_SUMMARIES_FILTERS.security.map((filter) =>
|
||||||
generateEntityFilter(hass, filter)
|
generateEntityFilter(hass, filter)
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -170,7 +170,7 @@ export class HomeMainViewStrategy extends ReactiveElement {
|
|||||||
const hasMediaPlayers =
|
const hasMediaPlayers =
|
||||||
findEntities(allEntities, mediaPlayerFilter).length > 0;
|
findEntities(allEntities, mediaPlayerFilter).length > 0;
|
||||||
const hasClimate = findEntities(allEntities, climateFilters).length > 0;
|
const hasClimate = findEntities(allEntities, climateFilters).length > 0;
|
||||||
const hasSafety = findEntities(allEntities, safetyFilters).length > 0;
|
const hasSecurity = findEntities(allEntities, securityFilters).length > 0;
|
||||||
|
|
||||||
const summaryCards: LovelaceCardConfig[] = [
|
const summaryCards: LovelaceCardConfig[] = [
|
||||||
hasLights &&
|
hasLights &&
|
||||||
@@ -201,14 +201,14 @@ export class HomeMainViewStrategy extends ReactiveElement {
|
|||||||
columns: 4,
|
columns: 4,
|
||||||
},
|
},
|
||||||
} satisfies HomeSummaryCard),
|
} satisfies HomeSummaryCard),
|
||||||
hasSafety &&
|
hasSecurity &&
|
||||||
({
|
({
|
||||||
type: "home-summary",
|
type: "home-summary",
|
||||||
summary: "safety",
|
summary: "security",
|
||||||
vertical: true,
|
vertical: true,
|
||||||
tap_action: {
|
tap_action: {
|
||||||
action: "navigate",
|
action: "navigate",
|
||||||
navigation_path: "/safety?historyBack=1",
|
navigation_path: "/security?historyBack=1",
|
||||||
},
|
},
|
||||||
grid_options: {
|
grid_options: {
|
||||||
rows: 2,
|
rows: 2,
|
||||||
|
|||||||
@@ -20,8 +20,8 @@ const SECURITY_LOVELACE_VIEW_CONFIG: LovelaceStrategyViewConfig = {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
@customElement("ha-panel-safety")
|
@customElement("ha-panel-security")
|
||||||
class PanelSafety extends LitElement {
|
class PanelSecurity extends LitElement {
|
||||||
@property({ attribute: false }) public hass!: HomeAssistant;
|
@property({ attribute: false }) public hass!: HomeAssistant;
|
||||||
|
|
||||||
@property({ type: Boolean, reflect: true }) public narrow = false;
|
@property({ type: Boolean, reflect: true }) public narrow = false;
|
||||||
@@ -146,7 +146,7 @@ class PanelSafety extends LitElement {
|
|||||||
config: config,
|
config: config,
|
||||||
rawConfig: rawConfig,
|
rawConfig: rawConfig,
|
||||||
editMode: false,
|
editMode: false,
|
||||||
urlPath: "safety",
|
urlPath: "security",
|
||||||
mode: "generated",
|
mode: "generated",
|
||||||
locale: this.hass.locale,
|
locale: this.hass.locale,
|
||||||
enableFullEditMode: () => undefined,
|
enableFullEditMode: () => undefined,
|
||||||
@@ -248,6 +248,6 @@ class PanelSafety extends LitElement {
|
|||||||
|
|
||||||
declare global {
|
declare global {
|
||||||
interface HTMLElementTagNameMap {
|
interface HTMLElementTagNameMap {
|
||||||
"ha-panel-safety": PanelSafety;
|
"ha-panel-security": PanelSecurity;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -17,11 +17,11 @@ import {
|
|||||||
} from "../../lovelace/strategies/areas/helpers/areas-strategy-helper";
|
} from "../../lovelace/strategies/areas/helpers/areas-strategy-helper";
|
||||||
import { getHomeStructure } from "../../lovelace/strategies/home/helpers/home-structure";
|
import { getHomeStructure } from "../../lovelace/strategies/home/helpers/home-structure";
|
||||||
|
|
||||||
export interface SafetyViewStrategyConfig {
|
export interface SecurityViewStrategyConfig {
|
||||||
type: "safety";
|
type: "security";
|
||||||
}
|
}
|
||||||
|
|
||||||
export const safetyEntityFilters: EntityFilter[] = [
|
export const securityEntityFilters: EntityFilter[] = [
|
||||||
{
|
{
|
||||||
domain: "camera",
|
domain: "camera",
|
||||||
entity_category: "none",
|
entity_category: "none",
|
||||||
@@ -67,7 +67,7 @@ export const safetyEntityFilters: EntityFilter[] = [
|
|||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
const processAreasForSafety = (
|
const processAreasForSecurity = (
|
||||||
areaIds: string[],
|
areaIds: string[],
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
entities: string[]
|
entities: string[]
|
||||||
@@ -81,12 +81,12 @@ const processAreasForSafety = (
|
|||||||
const areaFilter = generateEntityFilter(hass, {
|
const areaFilter = generateEntityFilter(hass, {
|
||||||
area: area.area_id,
|
area: area.area_id,
|
||||||
});
|
});
|
||||||
const areaSafetyEntities = entities.filter(areaFilter);
|
const areaSecurityEntities = entities.filter(areaFilter);
|
||||||
const areaCards: LovelaceCardConfig[] = [];
|
const areaCards: LovelaceCardConfig[] = [];
|
||||||
|
|
||||||
const computeTileCard = computeAreaTileCardConfig(hass, "", false);
|
const computeTileCard = computeAreaTileCardConfig(hass, "", false);
|
||||||
|
|
||||||
for (const entityId of areaSafetyEntities) {
|
for (const entityId of areaSecurityEntities) {
|
||||||
areaCards.push(computeTileCard(entityId));
|
areaCards.push(computeTileCard(entityId));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -121,10 +121,10 @@ const processUnassignedEntities = (
|
|||||||
return areaCards;
|
return areaCards;
|
||||||
};
|
};
|
||||||
|
|
||||||
@customElement("safety-view-strategy")
|
@customElement("security-view-strategy")
|
||||||
export class SafetyViewStrategy extends ReactiveElement {
|
export class SecurityViewStrategy extends ReactiveElement {
|
||||||
static async generate(
|
static async generate(
|
||||||
_config: SafetyViewStrategyConfig,
|
_config: SecurityViewStrategyConfig,
|
||||||
hass: HomeAssistant
|
hass: HomeAssistant
|
||||||
): Promise<LovelaceViewConfig> {
|
): Promise<LovelaceViewConfig> {
|
||||||
const areas = getAreas(hass.areas);
|
const areas = getAreas(hass.areas);
|
||||||
@@ -135,11 +135,11 @@ export class SafetyViewStrategy extends ReactiveElement {
|
|||||||
|
|
||||||
const allEntities = Object.keys(hass.states);
|
const allEntities = Object.keys(hass.states);
|
||||||
|
|
||||||
const safetyFilters = safetyEntityFilters.map((filter) =>
|
const securityFilters = securityEntityFilters.map((filter) =>
|
||||||
generateEntityFilter(hass, filter)
|
generateEntityFilter(hass, filter)
|
||||||
);
|
);
|
||||||
|
|
||||||
const entities = findEntities(allEntities, safetyFilters);
|
const entities = findEntities(allEntities, securityFilters);
|
||||||
|
|
||||||
const floorCount = home.floors.length + (home.areas.length ? 1 : 0);
|
const floorCount = home.floors.length + (home.areas.length ? 1 : 0);
|
||||||
|
|
||||||
@@ -164,7 +164,7 @@ export class SafetyViewStrategy extends ReactiveElement {
|
|||||||
],
|
],
|
||||||
};
|
};
|
||||||
|
|
||||||
const areaCards = processAreasForSafety(areaIds, hass, entities);
|
const areaCards = processAreasForSecurity(areaIds, hass, entities);
|
||||||
|
|
||||||
if (areaCards.length > 0) {
|
if (areaCards.length > 0) {
|
||||||
section.cards!.push(...areaCards);
|
section.cards!.push(...areaCards);
|
||||||
@@ -188,7 +188,7 @@ export class SafetyViewStrategy extends ReactiveElement {
|
|||||||
],
|
],
|
||||||
};
|
};
|
||||||
|
|
||||||
const areaCards = processAreasForSafety(home.areas, hass, entities);
|
const areaCards = processAreasForSecurity(home.areas, hass, entities);
|
||||||
|
|
||||||
if (areaCards.length > 0) {
|
if (areaCards.length > 0) {
|
||||||
section.cards!.push(...areaCards);
|
section.cards!.push(...areaCards);
|
||||||
@@ -209,9 +209,9 @@ export class SafetyViewStrategy extends ReactiveElement {
|
|||||||
heading:
|
heading:
|
||||||
sections.length > 0
|
sections.length > 0
|
||||||
? hass.localize(
|
? hass.localize(
|
||||||
"ui.panel.lovelace.strategy.safety.other_devices"
|
"ui.panel.lovelace.strategy.security.other_devices"
|
||||||
)
|
)
|
||||||
: hass.localize("ui.panel.lovelace.strategy.safety.devices"),
|
: hass.localize("ui.panel.lovelace.strategy.security.devices"),
|
||||||
},
|
},
|
||||||
...unassignedCards,
|
...unassignedCards,
|
||||||
],
|
],
|
||||||
@@ -229,6 +229,6 @@ export class SafetyViewStrategy extends ReactiveElement {
|
|||||||
|
|
||||||
declare global {
|
declare global {
|
||||||
interface HTMLElementTagNameMap {
|
interface HTMLElementTagNameMap {
|
||||||
"safety-view-strategy": SafetyViewStrategy;
|
"security-view-strategy": SecurityViewStrategy;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -12,7 +12,7 @@
|
|||||||
"media_browser": "Media",
|
"media_browser": "Media",
|
||||||
"profile": "Profile",
|
"profile": "Profile",
|
||||||
"light": "Lights",
|
"light": "Lights",
|
||||||
"safety": "Safety",
|
"security": "Security",
|
||||||
"climate": "Climate"
|
"climate": "Climate"
|
||||||
},
|
},
|
||||||
"state": {
|
"state": {
|
||||||
@@ -6955,7 +6955,7 @@
|
|||||||
"lights": "Lights",
|
"lights": "Lights",
|
||||||
"other_lights": "Other lights"
|
"other_lights": "Other lights"
|
||||||
},
|
},
|
||||||
"safety": {
|
"security": {
|
||||||
"devices": "Devices",
|
"devices": "Devices",
|
||||||
"other_devices": "Other devices"
|
"other_devices": "Other devices"
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user