Only pick entities with location in map card editor (#15839)

This commit is contained in:
karwosts 2023-03-17 08:19:43 -07:00 committed by GitHub
parent b0f3006c4b
commit 952028a7be
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 1 deletions

View File

@ -5,7 +5,10 @@ import { repeat } from "lit/directives/repeat";
import type { SortableEvent } from "sortablejs";
import { fireEvent } from "../../../common/dom/fire_event";
import "../../../components/entity/ha-entity-picker";
import type { HaEntityPicker } from "../../../components/entity/ha-entity-picker";
import type {
HaEntityPicker,
HaEntityPickerEntityFilterFunc,
} from "../../../components/entity/ha-entity-picker";
import "../../../components/ha-icon-button";
import { sortableStyles } from "../../../resources/ha-sortable-style";
import {
@ -21,6 +24,8 @@ export class HuiEntityEditor extends LitElement {
@property({ attribute: false }) protected entities?: EntityConfig[];
@property() protected entityFilter?: HaEntityPickerEntityFilterFunc;
@property() protected label?: string;
private _entityKeys = new WeakMap<EntityConfig, string>();
@ -65,6 +70,7 @@ export class HuiEntityEditor extends LitElement {
.hass=${this.hass}
.value=${entityConf.entity}
.index=${index}
.entityFilter=${this.entityFilter}
@value-changed=${this._valueChanged}
allow-custom-entity
></ha-entity-picker>
@ -75,6 +81,7 @@ export class HuiEntityEditor extends LitElement {
<ha-entity-picker
class="add-entity"
.hass=${this.hass}
.entityFilter=${this.entityFilter}
@value-changed=${this._addEntity}
></ha-entity-picker>
`;

View File

@ -27,6 +27,7 @@ import { baseLovelaceCardConfig } from "../structs/base-card-struct";
import { entitiesConfigStruct } from "../structs/entities-struct";
import { EntitiesEditorEvent } from "../types";
import { configElementStyle } from "./config-elements-style";
import { hasLocation } from "../../../../common/entity/has_location";
const cardConfigStruct = assign(
baseLovelaceCardConfig,
@ -93,6 +94,7 @@ export class HuiMapCardEditor extends LitElement implements LovelaceCardEditor {
<hui-entity-editor
.hass=${this.hass}
.entities=${this._configEntities}
.entityFilter=${hasLocation}
@entities-changed=${this._entitiesValueChanged}
></hui-entity-editor>
<h3>