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,
|
||||
ThermostatCardConfig,
|
||||
} from "../cards/types";
|
||||
import { processEditorEntities } from "../editor/process-editor-entities";
|
||||
import { LovelaceRowConfig } from "../entity-rows/types";
|
||||
|
||||
const DEFAULT_VIEW_ENTITY_ID = "group.default_view";
|
||||
const DOMAINS_BADGES = [
|
||||
"binary_sensor",
|
||||
"mailbox",
|
||||
"person",
|
||||
"sensor",
|
||||
"sun",
|
||||
"timer",
|
||||
];
|
||||
const HIDE_DOMAIN = new Set([
|
||||
"automation",
|
||||
"configurator",
|
||||
@ -91,10 +82,12 @@ const splitByAreas = (
|
||||
);
|
||||
for (const entity of entityEntries) {
|
||||
if (
|
||||
areaDevices.has(
|
||||
((areaDevices.has(
|
||||
// @ts-ignore
|
||||
entity.device_id
|
||||
) &&
|
||||
!entity.area_id) ||
|
||||
entity.area_id === area.area_id) &&
|
||||
entity.entity_id in allEntities
|
||||
) {
|
||||
areaEntities.push(allEntities[entity.entity_id]);
|
||||
@ -246,30 +239,18 @@ const generateViewConfig = (
|
||||
(gr1, gr2) => groupOrders[gr1.entity_id] - groupOrders[gr2.entity_id]
|
||||
);
|
||||
|
||||
const badgeEntities: { [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) => {
|
||||
const state = splitted.ungrouped[entityId];
|
||||
const domain = computeStateDomain(state);
|
||||
|
||||
const coll = DOMAINS_BADGES.includes(domain)
|
||||
? badgeEntities
|
||||
: ungroupedEntitites;
|
||||
|
||||
if (!(domain in coll)) {
|
||||
coll[domain] = [];
|
||||
if (!(domain in ungroupedEntitites)) {
|
||||
ungroupedEntitites[domain] = [];
|
||||
}
|
||||
|
||||
coll[domain].push(state.entity_id);
|
||||
});
|
||||
|
||||
let badges: string[] = [];
|
||||
DOMAINS_BADGES.forEach((domain) => {
|
||||
if (domain in badgeEntities) {
|
||||
badges = badges.concat(badgeEntities[domain]);
|
||||
}
|
||||
ungroupedEntitites[domain].push(state.entity_id);
|
||||
});
|
||||
|
||||
let cards: LovelaceCardConfig[] = [];
|
||||
@ -315,7 +296,6 @@ const generateViewConfig = (
|
||||
const view: LovelaceViewConfig = {
|
||||
path,
|
||||
title,
|
||||
badges: processEditorEntities(badges),
|
||||
cards,
|
||||
};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user