void;
path?: [number];
- entities?: string[]; // Entities used to generate the card config. We pass this to create dialog when user chooses "Pick own"
- cardConfig?: LovelaceCardConfig[]; // We can pass a suggested config
+ entities?: string[]; // We pass this to create dialog when user chooses "Pick own"
+ cardConfig: LovelaceCardConfig[]; // We can pass a suggested config
}
-const importsuggestCardDialog = () => import("./hui-dialog-suggest-card");
+const importSuggestCardDialog = () => import("./hui-dialog-suggest-card");
export const showSuggestCardDialog = (
element: HTMLElement,
@@ -19,7 +19,7 @@ export const showSuggestCardDialog = (
): void => {
fireEvent(element, "show-dialog", {
dialogTag: "hui-dialog-suggest-card",
- dialogImport: importsuggestCardDialog,
+ dialogImport: importSuggestCardDialog,
dialogParams: suggestCardDialogParams,
});
};
diff --git a/src/panels/lovelace/editor/unused-entities/hui-unused-entities.ts b/src/panels/lovelace/editor/unused-entities/hui-unused-entities.ts
index 18ce15b683..98cd3f3163 100644
--- a/src/panels/lovelace/editor/unused-entities/hui-unused-entities.ts
+++ b/src/panels/lovelace/editor/unused-entities/hui-unused-entities.ts
@@ -21,6 +21,7 @@ import "../card-editor/hui-entity-picker-table";
import { showSuggestCardDialog } from "../card-editor/show-suggest-card-dialog";
import { showSelectViewDialog } from "../select-view/show-select-view-dialog";
import { LovelaceConfig } from "../../../../data/lovelace/config/types";
+import { computeCards } from "../../common/generate-lovelace-config";
@customElement("hui-unused-entities")
export class HuiUnusedEntities extends LitElement {
@@ -126,12 +127,18 @@ export class HuiUnusedEntities extends LitElement {
}
private _addToLovelaceView(): void {
+ const cardConfig = computeCards(
+ this.hass.states,
+ this._selectedEntities,
+ {}
+ );
if (this.lovelace.config.views.length === 1) {
showSuggestCardDialog(this, {
lovelaceConfig: this.lovelace.config!,
saveConfig: this.lovelace.saveConfig,
path: [0],
entities: this._selectedEntities,
+ cardConfig,
});
return;
}
@@ -144,6 +151,7 @@ export class HuiUnusedEntities extends LitElement {
saveConfig: this.lovelace.saveConfig,
path: [viewIndex],
entities: this._selectedEntities,
+ cardConfig,
});
},
});
diff --git a/src/panels/lovelace/entity-rows/hui-input-select-entity-row.ts b/src/panels/lovelace/entity-rows/hui-input-select-entity-row.ts
index 4dbfd6f6bf..2d4f6e5bf3 100644
--- a/src/panels/lovelace/entity-rows/hui-input-select-entity-row.ts
+++ b/src/panels/lovelace/entity-rows/hui-input-select-entity-row.ts
@@ -40,14 +40,20 @@ class HuiInputSelectEntityRow extends LitElement implements LovelaceRow {
protected updated(changedProps: PropertyValues) {
super.updated(changedProps);
+ if (!this._config) {
+ return;
+ }
if (changedProps.has("hass")) {
const oldHass = changedProps.get("hass");
+ const stateObj = this.hass?.states[this._config.entity] as
+ | InputSelectEntity
+ | undefined;
+ const oldStateObj = oldHass?.states[this._config.entity] as
+ | InputSelectEntity
+ | undefined;
if (
- this.hass &&
- oldHass &&
- this._config?.entity &&
- this.hass.states[this._config.entity].attributes.options !==
- oldHass.states[this._config.entity].attributes.options
+ stateObj &&
+ stateObj.attributes.options !== oldStateObj?.attributes.options
) {
this._haSelect.layoutOptions();
}