From e014c7aff6176eec182def5151b44e5689eefde8 Mon Sep 17 00:00:00 2001 From: Bram Kragten Date: Fri, 4 Dec 2020 19:02:58 +0100 Subject: [PATCH] Entity is not required for button card (#7909) Fixes https://github.com/home-assistant/frontend/issues/7908 --- src/panels/lovelace/cards/hui-button-card.ts | 3 --- src/panels/lovelace/cards/hui-entity-button-card.ts | 9 ++++++++- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/panels/lovelace/cards/hui-button-card.ts b/src/panels/lovelace/cards/hui-button-card.ts index 719320ebcd..ef21e4c8b7 100644 --- a/src/panels/lovelace/cards/hui-button-card.ts +++ b/src/panels/lovelace/cards/hui-button-card.ts @@ -84,9 +84,6 @@ export class HuiButtonCard extends LitElement implements LovelaceCard { } public setConfig(config: ButtonCardConfig): void { - if (!config.entity) { - throw new Error("Entity must be specified"); - } if (config.entity && !isValidEntityId(config.entity)) { throw new Error("Invalid entity"); } diff --git a/src/panels/lovelace/cards/hui-entity-button-card.ts b/src/panels/lovelace/cards/hui-entity-button-card.ts index 7955ccf040..0cb0b7eb43 100644 --- a/src/panels/lovelace/cards/hui-entity-button-card.ts +++ b/src/panels/lovelace/cards/hui-entity-button-card.ts @@ -2,7 +2,14 @@ import { customElement } from "lit-element"; import { HuiButtonCard } from "./hui-button-card"; @customElement("hui-entity-button-card") -class HuiEntityButtonCard extends HuiButtonCard {} +class HuiEntityButtonCard extends HuiButtonCard { + public setConfig(config): void { + if (!config.entity) { + throw new Error("Entity must be specified"); + } + super.setConfig(config); + } +} declare global { interface HTMLElementTagNameMap {