Convert entity picker to ha-combo (#11560)

* Convert entity picker to ha-combo

* Update ha-entity-picker.ts

* Handle empty better

* Clear value when no device/area/entity
This commit is contained in:
Bram Kragten
2022-02-07 10:59:11 +01:00
committed by GitHub
parent d05f807b9d
commit 76af6e48cd
6 changed files with 77 additions and 129 deletions

View File

@@ -139,7 +139,7 @@ export class HaAreaPicker extends SubscribeMixin(LitElement) {
if (!areas.length) {
return [
{
area_id: "",
area_id: "no_areas",
name: this.hass.localize("ui.components.area-picker.no_areas"),
picture: null,
},
@@ -263,7 +263,7 @@ export class HaAreaPicker extends SubscribeMixin(LitElement) {
if (!outputAreas.length) {
outputAreas = [
{
area_id: "",
area_id: "no_areas",
name: this.hass.localize("ui.components.area-picker.no_match"),
picture: null,
},
@@ -369,7 +369,11 @@ export class HaAreaPicker extends SubscribeMixin(LitElement) {
private _areaChanged(ev: PolymerChangedEvent<string>) {
ev.stopPropagation();
const newValue = ev.detail.value;
let newValue = ev.detail.value;
if (newValue === "no_areas") {
newValue = "";
}
if (!["add_new_suggestion", "add_new"].includes(newValue)) {
if (newValue !== this._value) {