mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-28 11:46:42 +00:00
Don't use badges in generated Lovelace + group entities by area (#8291)
This commit is contained in:
parent
8ea6baaf5d
commit
db9597d2e7
@ -43,18 +43,9 @@ import {
|
|||||||
PictureEntityCardConfig,
|
PictureEntityCardConfig,
|
||||||
ThermostatCardConfig,
|
ThermostatCardConfig,
|
||||||
} from "../cards/types";
|
} from "../cards/types";
|
||||||
import { processEditorEntities } from "../editor/process-editor-entities";
|
|
||||||
import { LovelaceRowConfig } from "../entity-rows/types";
|
import { LovelaceRowConfig } from "../entity-rows/types";
|
||||||
|
|
||||||
const DEFAULT_VIEW_ENTITY_ID = "group.default_view";
|
const DEFAULT_VIEW_ENTITY_ID = "group.default_view";
|
||||||
const DOMAINS_BADGES = [
|
|
||||||
"binary_sensor",
|
|
||||||
"mailbox",
|
|
||||||
"person",
|
|
||||||
"sensor",
|
|
||||||
"sun",
|
|
||||||
"timer",
|
|
||||||
];
|
|
||||||
const HIDE_DOMAIN = new Set([
|
const HIDE_DOMAIN = new Set([
|
||||||
"automation",
|
"automation",
|
||||||
"configurator",
|
"configurator",
|
||||||
@ -91,10 +82,12 @@ const splitByAreas = (
|
|||||||
);
|
);
|
||||||
for (const entity of entityEntries) {
|
for (const entity of entityEntries) {
|
||||||
if (
|
if (
|
||||||
areaDevices.has(
|
((areaDevices.has(
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
entity.device_id
|
entity.device_id
|
||||||
) &&
|
) &&
|
||||||
|
!entity.area_id) ||
|
||||||
|
entity.area_id === area.area_id) &&
|
||||||
entity.entity_id in allEntities
|
entity.entity_id in allEntities
|
||||||
) {
|
) {
|
||||||
areaEntities.push(allEntities[entity.entity_id]);
|
areaEntities.push(allEntities[entity.entity_id]);
|
||||||
@ -246,30 +239,18 @@ const generateViewConfig = (
|
|||||||
(gr1, gr2) => groupOrders[gr1.entity_id] - groupOrders[gr2.entity_id]
|
(gr1, gr2) => groupOrders[gr1.entity_id] - groupOrders[gr2.entity_id]
|
||||||
);
|
);
|
||||||
|
|
||||||
const badgeEntities: { [domain: string]: string[] } = {};
|
|
||||||
const ungroupedEntitites: { [domain: string]: string[] } = {};
|
const ungroupedEntitites: { [domain: string]: string[] } = {};
|
||||||
|
|
||||||
// Organize ungrouped entities in badges/ungrouped things
|
// Organize ungrouped entities in ungrouped things
|
||||||
Object.keys(splitted.ungrouped).forEach((entityId) => {
|
Object.keys(splitted.ungrouped).forEach((entityId) => {
|
||||||
const state = splitted.ungrouped[entityId];
|
const state = splitted.ungrouped[entityId];
|
||||||
const domain = computeStateDomain(state);
|
const domain = computeStateDomain(state);
|
||||||
|
|
||||||
const coll = DOMAINS_BADGES.includes(domain)
|
if (!(domain in ungroupedEntitites)) {
|
||||||
? badgeEntities
|
ungroupedEntitites[domain] = [];
|
||||||
: ungroupedEntitites;
|
|
||||||
|
|
||||||
if (!(domain in coll)) {
|
|
||||||
coll[domain] = [];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
coll[domain].push(state.entity_id);
|
ungroupedEntitites[domain].push(state.entity_id);
|
||||||
});
|
|
||||||
|
|
||||||
let badges: string[] = [];
|
|
||||||
DOMAINS_BADGES.forEach((domain) => {
|
|
||||||
if (domain in badgeEntities) {
|
|
||||||
badges = badges.concat(badgeEntities[domain]);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
let cards: LovelaceCardConfig[] = [];
|
let cards: LovelaceCardConfig[] = [];
|
||||||
@ -315,7 +296,6 @@ const generateViewConfig = (
|
|||||||
const view: LovelaceViewConfig = {
|
const view: LovelaceViewConfig = {
|
||||||
path,
|
path,
|
||||||
title,
|
title,
|
||||||
badges: processEditorEntities(badges),
|
|
||||||
cards,
|
cards,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user