mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-25 18:26:35 +00:00
Move groups up, after areas, move devices down (#14741)
This commit is contained in:
parent
1da8a974f8
commit
f7aecb0d6d
@ -304,19 +304,13 @@ export const generateViewConfig = (
|
|||||||
path: string,
|
path: string,
|
||||||
title: string | undefined,
|
title: string | undefined,
|
||||||
icon: string | undefined,
|
icon: string | undefined,
|
||||||
entities: HassEntities,
|
entities: HassEntities
|
||||||
groupOrders: { [entityId: string]: number }
|
|
||||||
): LovelaceViewConfig => {
|
): LovelaceViewConfig => {
|
||||||
const splitted = splitByGroups(entities);
|
|
||||||
splitted.groups.sort(
|
|
||||||
(gr1, gr2) => groupOrders[gr1.entity_id] - groupOrders[gr2.entity_id]
|
|
||||||
);
|
|
||||||
|
|
||||||
const ungroupedEntitites: { [domain: string]: string[] } = {};
|
const ungroupedEntitites: { [domain: string]: string[] } = {};
|
||||||
|
|
||||||
// Organize ungrouped entities in ungrouped things
|
// Organize ungrouped entities in ungrouped things
|
||||||
for (const entityId of Object.keys(splitted.ungrouped)) {
|
for (const entityId of Object.keys(entities)) {
|
||||||
const state = splitted.ungrouped[entityId];
|
const state = entities[entityId];
|
||||||
const domain = computeStateDomain(state);
|
const domain = computeStateDomain(state);
|
||||||
|
|
||||||
if (!(domain in ungroupedEntitites)) {
|
if (!(domain in ungroupedEntitites)) {
|
||||||
@ -384,15 +378,6 @@ export const generateViewConfig = (
|
|||||||
delete ungroupedEntitites.person;
|
delete ungroupedEntitites.person;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const groupEntity of splitted.groups) {
|
|
||||||
cards.push(
|
|
||||||
...computeCards(entities, groupEntity.attributes.entity_id, {
|
|
||||||
title: computeStateName(groupEntity),
|
|
||||||
show_header_toggle: groupEntity.attributes.control !== "hidden",
|
|
||||||
})
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Group helper entities in a single card
|
// Group helper entities in a single card
|
||||||
const helperEntities: string[] = [];
|
const helperEntities: string[] = [];
|
||||||
|
|
||||||
@ -480,13 +465,28 @@ export const generateDefaultViewConfig = (
|
|||||||
states
|
states
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const splittedByGroups = splitByGroups(splittedByAreaDevice.otherEntities);
|
||||||
|
splittedByGroups.groups.sort(
|
||||||
|
(gr1, gr2) => groupOrders[gr1.entity_id] - groupOrders[gr2.entity_id]
|
||||||
|
);
|
||||||
|
|
||||||
|
const groupCards: LovelaceCardConfig[] = [];
|
||||||
|
|
||||||
|
for (const groupEntity of splittedByGroups.groups) {
|
||||||
|
groupCards.push(
|
||||||
|
...computeCards(entities, groupEntity.attributes.entity_id, {
|
||||||
|
title: computeStateName(groupEntity),
|
||||||
|
show_header_toggle: groupEntity.attributes.control !== "hidden",
|
||||||
|
})
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
const config = generateViewConfig(
|
const config = generateViewConfig(
|
||||||
localize,
|
localize,
|
||||||
path,
|
path,
|
||||||
title,
|
title,
|
||||||
icon,
|
icon,
|
||||||
splittedByAreaDevice.otherEntities,
|
splittedByGroups.ungrouped
|
||||||
groupOrders
|
|
||||||
);
|
);
|
||||||
|
|
||||||
const areaCards: LovelaceCardConfig[] = [];
|
const areaCards: LovelaceCardConfig[] = [];
|
||||||
@ -568,9 +568,11 @@ export const generateDefaultViewConfig = (
|
|||||||
|
|
||||||
config.cards!.unshift(
|
config.cards!.unshift(
|
||||||
...areaCards,
|
...areaCards,
|
||||||
...(energyCard ? [energyCard] : []),
|
...groupCards,
|
||||||
...deviceCards
|
...(energyCard ? [energyCard] : [])
|
||||||
);
|
);
|
||||||
|
|
||||||
|
config.cards!.push(...deviceCards);
|
||||||
|
|
||||||
return config;
|
return config;
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user