diff --git a/src/panels/lovelace/cards/hui-entity-button-card.ts b/src/panels/lovelace/cards/hui-entity-button-card.ts index cc0b7fdfbe..25b79be422 100644 --- a/src/panels/lovelace/cards/hui-entity-button-card.ts +++ b/src/panels/lovelace/cards/hui-entity-button-card.ts @@ -31,7 +31,9 @@ import { DOMAINS_TOGGLE } from "../../../common/const"; export interface Config extends LovelaceCardConfig { entity: string; name?: string; + snow_name?: boolean; icon?: string; + show_icon?: boolean; theme?: string; tap_action?: ActionConfig; hold_action?: ActionConfig; @@ -48,6 +50,8 @@ class HuiEntityButtonCard extends LitElement implements LovelaceCard { return { tap_action: { action: "toggle" }, hold_action: { action: "more-info" }, + show_icon: true, + show_name: true, }; } @@ -68,6 +72,8 @@ class HuiEntityButtonCard extends LitElement implements LovelaceCard { theme: "default", hold_action: { action: "more-info" }, ...config, + show_icon: true, + show_name: true, }; if (DOMAINS_TOGGLE.has(computeDomain(config.entity))) { @@ -126,18 +132,26 @@ class HuiEntityButtonCard extends LitElement implements LovelaceCard { @ha-hold="${this._handleHold}" .longPress="${longPress()}" > - - - ${this._config.name || computeStateName(stateObj)} - + ${this._config.show_icon + ? html` + + ` + : ""} + ${this._config.show_name + ? html` + + ${this._config.name || computeStateName(stateObj)} + + ` + : ""} `; diff --git a/src/panels/lovelace/editor/config-elements/hui-entity-button-card-editor.ts b/src/panels/lovelace/editor/config-elements/hui-entity-button-card-editor.ts index 7318a1f270..93ecd9498a 100644 --- a/src/panels/lovelace/editor/config-elements/hui-entity-button-card-editor.ts +++ b/src/panels/lovelace/editor/config-elements/hui-entity-button-card-editor.ts @@ -28,7 +28,9 @@ const cardConfigStruct = struct({ type: "string", entity: "string?", name: "string?", + show_name: "boolean?", icon: "string?", + show_icon: "boolean?", tap_action: struct.optional(actionConfigStruct), hold_action: struct.optional(actionConfigStruct), theme: "string?", @@ -54,10 +56,18 @@ export class HuiEntityButtonCardEditor extends LitElement return this._config!.name || ""; } + get _show_name(): boolean { + return this._config!.show_name || true; + } + get _icon(): string { return this._config!.icon || ""; } + get _show_icon(): boolean { + return this._config!.show_icon || true; + } + get _tap_action(): ActionConfig { return this._config!.tap_action || { action: "more-info" }; } @@ -101,6 +111,20 @@ export class HuiEntityButtonCardEditor extends LitElement @value-changed="${this._valueChanged}" > +
+ Show Name? + Show Icon? +