Skip to content

Commit

Permalink
Remove mobile_app from generated Lovelace (home-assistant#6873)
Browse files Browse the repository at this point in the history
* Hide mobile_app from generated Lovelace

* simplify

* Move to computeDefaultViewStates

* removed -> hidden

* Update src/panels/lovelace/common/generate-lovelace-config.ts

Co-authored-by: Bram Kragten <[email protected]>

* Adjust for Set

* Review comments

Co-authored-by: Bram Kragten <[email protected]>
  • Loading branch information
ludeeus and bramkragten authored Sep 9, 2020
1 parent 6c2b8c2 commit 498882d
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions src/panels/lovelace/common/generate-lovelace-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ const HIDE_DOMAIN = new Set([
"zone",
]);

const HIDE_PLATFORM = new Set(["mobile_app"]);

let subscribedRegistries = false;

interface SplittedByAreas {
Expand Down Expand Up @@ -206,11 +208,23 @@ export const computeCards = (
return cards;
};

const computeDefaultViewStates = (entities: HassEntities): HassEntities => {
const computeDefaultViewStates = (
entities: HassEntities,
entityEntries: EntityRegistryEntry[]
): HassEntities => {
const states = {};
const hiddenEntities = new Set(
entityEntries
.filter((entry) => HIDE_PLATFORM.has(entry.platform))
.map((entry) => entry.entity_id)
);

Object.keys(entities).forEach((entityId) => {
const stateObj = entities[entityId];
if (!HIDE_DOMAIN.has(computeStateDomain(stateObj))) {
if (
!HIDE_DOMAIN.has(computeStateDomain(stateObj)) &&
!hiddenEntities.has(stateObj.entity_id)
) {
states[entityId] = entities[entityId];
}
});
Expand Down Expand Up @@ -317,7 +331,7 @@ export const generateDefaultViewConfig = (
entities: HassEntities,
localize: LocalizeFunc
): LovelaceViewConfig => {
const states = computeDefaultViewStates(entities);
const states = computeDefaultViewStates(entities, entityEntries);
const path = "default_view";
const title = "Home";
const icon = undefined;
Expand Down

0 comments on commit 498882d

Please sign in to comment.