mirror of
				https://github.com/home-assistant/frontend.git
				synced 2025-10-30 22:19:55 +00:00 
			
		
		
		
	Compare commits
	
		
			1 Commits
		
	
	
		
			20231205.0
			...
			add-Use-UU
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
|   | 1f6243145f | 
| @@ -18,6 +18,7 @@ import "./state-badge"; | |||||||
|  |  | ||||||
| interface HassEntityWithCachedName extends HassEntity { | interface HassEntityWithCachedName extends HassEntity { | ||||||
|   friendly_name: string; |   friendly_name: string; | ||||||
|  |   id: string; | ||||||
| } | } | ||||||
|  |  | ||||||
| export type HaEntityPickerEntityFilterFunc = (entityId: HassEntity) => boolean; | export type HaEntityPickerEntityFilterFunc = (entityId: HassEntity) => boolean; | ||||||
| @@ -96,6 +97,9 @@ export class HaEntityPicker extends LitElement { | |||||||
|  |  | ||||||
|   @property() public entityFilter?: HaEntityPickerEntityFilterFunc; |   @property() public entityFilter?: HaEntityPickerEntityFilterFunc; | ||||||
|  |  | ||||||
|  |   @property({ attribute: "item-value-path" }) public itemValuePath = | ||||||
|  |     "entity_id"; | ||||||
|  |  | ||||||
|   @property({ type: Boolean }) public hideClearIcon = false; |   @property({ type: Boolean }) public hideClearIcon = false; | ||||||
|  |  | ||||||
|   @state() private _opened = false; |   @state() private _opened = false; | ||||||
| @@ -144,6 +148,7 @@ export class HaEntityPicker extends LitElement { | |||||||
|             state: "", |             state: "", | ||||||
|             last_changed: "", |             last_changed: "", | ||||||
|             last_updated: "", |             last_updated: "", | ||||||
|  |             id: "", | ||||||
|             context: { id: "", user_id: null, parent_id: null }, |             context: { id: "", user_id: null, parent_id: null }, | ||||||
|             friendly_name: this.hass!.localize( |             friendly_name: this.hass!.localize( | ||||||
|               "ui.components.entity.entity-picker.no_entities" |               "ui.components.entity.entity-picker.no_entities" | ||||||
| @@ -164,10 +169,15 @@ export class HaEntityPicker extends LitElement { | |||||||
|         ); |         ); | ||||||
|  |  | ||||||
|         return entityIds |         return entityIds | ||||||
|           .map((key) => ({ |           .map((key) => { | ||||||
|             ...hass!.states[key], |             const stateObj = hass!.states[key]; | ||||||
|             friendly_name: computeStateName(hass!.states[key]) || key, |  | ||||||
|           })) |             return { | ||||||
|  |               ...stateObj, | ||||||
|  |               friendly_name: computeStateName(stateObj) || key, | ||||||
|  |               id: stateObj.context.id, | ||||||
|  |             }; | ||||||
|  |           }) | ||||||
|           .sort((entityA, entityB) => |           .sort((entityA, entityB) => | ||||||
|             caseInsensitiveStringCompare( |             caseInsensitiveStringCompare( | ||||||
|               entityA.friendly_name, |               entityA.friendly_name, | ||||||
| @@ -195,10 +205,15 @@ export class HaEntityPicker extends LitElement { | |||||||
|       } |       } | ||||||
|  |  | ||||||
|       states = entityIds |       states = entityIds | ||||||
|         .map((key) => ({ |         .map((key) => { | ||||||
|           ...hass!.states[key], |           const stateObj = hass!.states[key]; | ||||||
|           friendly_name: computeStateName(hass!.states[key]) || key, |  | ||||||
|         })) |           return { | ||||||
|  |             ...stateObj, | ||||||
|  |             friendly_name: computeStateName(stateObj) || key, | ||||||
|  |             id: stateObj.context?.id, | ||||||
|  |           }; | ||||||
|  |         }) | ||||||
|         .sort((entityA, entityB) => |         .sort((entityA, entityB) => | ||||||
|           caseInsensitiveStringCompare( |           caseInsensitiveStringCompare( | ||||||
|             entityA.friendly_name, |             entityA.friendly_name, | ||||||
| @@ -243,6 +258,7 @@ export class HaEntityPicker extends LitElement { | |||||||
|             state: "", |             state: "", | ||||||
|             last_changed: "", |             last_changed: "", | ||||||
|             last_updated: "", |             last_updated: "", | ||||||
|  |             id: "", | ||||||
|             context: { id: "", user_id: null, parent_id: null }, |             context: { id: "", user_id: null, parent_id: null }, | ||||||
|             friendly_name: this.hass!.localize( |             friendly_name: this.hass!.localize( | ||||||
|               "ui.components.entity.entity-picker.no_match" |               "ui.components.entity.entity-picker.no_match" | ||||||
| @@ -295,8 +311,8 @@ export class HaEntityPicker extends LitElement { | |||||||
|   protected render(): TemplateResult { |   protected render(): TemplateResult { | ||||||
|     return html` |     return html` | ||||||
|       <ha-combo-box |       <ha-combo-box | ||||||
|         item-value-path="entity_id" |  | ||||||
|         item-label-path="friendly_name" |         item-label-path="friendly_name" | ||||||
|  |         .itemValuePath=${this.itemValuePath} | ||||||
|         .hass=${this.hass} |         .hass=${this.hass} | ||||||
|         .value=${this._value} |         .value=${this._value} | ||||||
|         .label=${this.label === undefined |         .label=${this.label === undefined | ||||||
|   | |||||||
| @@ -33,6 +33,7 @@ export class HaEntitySelector extends SubscribeMixin(LitElement) { | |||||||
|         .excludeEntities=${this.selector.entity.exclude_entities} |         .excludeEntities=${this.selector.entity.exclude_entities} | ||||||
|         .entityFilter=${this._filterEntities} |         .entityFilter=${this._filterEntities} | ||||||
|         .disabled=${this.disabled} |         .disabled=${this.disabled} | ||||||
|  |         .itemValuePath=${!this.selector.entity.use_uuid ? "entity_id" : "id"} | ||||||
|         allow-custom-entity |         allow-custom-entity | ||||||
|       ></ha-entity-picker>`; |       ></ha-entity-picker>`; | ||||||
|     } |     } | ||||||
|   | |||||||
| @@ -106,6 +106,7 @@ export interface EntitySelector { | |||||||
|     domain?: string | string[]; |     domain?: string | string[]; | ||||||
|     device_class?: string; |     device_class?: string; | ||||||
|     multiple?: boolean; |     multiple?: boolean; | ||||||
|  |     use_uuid?: boolean; | ||||||
|     include_entities?: string[]; |     include_entities?: string[]; | ||||||
|     exclude_entities?: string[]; |     exclude_entities?: string[]; | ||||||
|   }; |   }; | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user