From 89175f8e85fce8d65af24c142ee63159f6db6a69 Mon Sep 17 00:00:00 2001 From: Bram Kragten Date: Wed, 25 Nov 2020 15:10:08 +0100 Subject: [PATCH] Add description and device class (#7816) https://github.com/home-assistant/core/pull/43321 --- .../ha-selector/ha-selector-entity.ts | 8 +++ src/data/blueprint.ts | 1 + src/data/selector.ts | 1 + .../automation/blueprint-automation-editor.ts | 67 ++++++++++--------- 4 files changed, 45 insertions(+), 32 deletions(-) diff --git a/src/components/ha-selector/ha-selector-entity.ts b/src/components/ha-selector/ha-selector-entity.ts index be4bfda550..c32f995ae4 100644 --- a/src/components/ha-selector/ha-selector-entity.ts +++ b/src/components/ha-selector/ha-selector-entity.ts @@ -56,6 +56,14 @@ export class HaEntitySelector extends SubscribeMixin(LitElement) { return false; } } + if (this.selector.entity.device_class) { + if ( + !entity.attributes.device_class || + entity.attributes.device_class !== this.selector.entity.device_class + ) { + return false; + } + } if (this.selector.entity.integration) { if ( !this._entities || diff --git a/src/data/blueprint.ts b/src/data/blueprint.ts index d7dd60ad36..4a3283b565 100644 --- a/src/data/blueprint.ts +++ b/src/data/blueprint.ts @@ -11,6 +11,7 @@ export interface Blueprint { export interface BlueprintMetaData { domain: string; name: string; + description?: string; input: Record; } diff --git a/src/data/selector.ts b/src/data/selector.ts index f002adaa88..fd20dbce95 100644 --- a/src/data/selector.ts +++ b/src/data/selector.ts @@ -4,6 +4,7 @@ export interface EntitySelector { entity: { integration?: string; domain?: string; + device_class?: string; }; } diff --git a/src/panels/config/automation/blueprint-automation-editor.ts b/src/panels/config/automation/blueprint-automation-editor.ts index 7b8103e904..7153cee0ee 100644 --- a/src/panels/config/automation/blueprint-automation-editor.ts +++ b/src/panels/config/automation/blueprint-automation-editor.ts @@ -156,39 +156,42 @@ export class HaBlueprintAutomationEditor extends LitElement { ? html`

There is an error in this Blueprint: ${blueprint.error}

` - : blueprint?.metadata?.input && + : html`${blueprint?.metadata.description + ? html`

${blueprint.metadata.description}

` + : ""} + ${blueprint?.metadata?.input && Object.keys(blueprint.metadata.input).length - ? html`

- ${this.hass.localize( - "ui.panel.config.automation.editor.blueprint.inputs" - )} -

- ${Object.entries(blueprint.metadata.input).map( - ([key, value]) => - html`
- ${value?.description} - ${value?.selector - ? html`` - : html``} -
` - )}` - : this.hass.localize( - "ui.panel.config.automation.editor.blueprint.no_inputs" - ) + ? html`

+ ${this.hass.localize( + "ui.panel.config.automation.editor.blueprint.inputs" + )} +

+ ${Object.entries(blueprint.metadata.input).map( + ([key, value]) => + html`
+ ${value?.description} + ${value?.selector + ? html`` + : html``} +
` + )}` + : this.hass.localize( + "ui.panel.config.automation.editor.blueprint.no_inputs" + )}` : ""}