From 465efa460efaa71c305c3a226eab48673ce7f5b3 Mon Sep 17 00:00:00 2001 From: Ian Richardson Date: Wed, 1 Apr 2020 04:06:58 -0500 Subject: [PATCH] handle brightness reporting while light off (#5391) --- src/components/entity/state-badge.ts | 2 +- src/panels/lovelace/cards/hui-light-card.ts | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/components/entity/state-badge.ts b/src/components/entity/state-badge.ts index 172c56261b..c201e50b8c 100644 --- a/src/components/entity/state-badge.ts +++ b/src/components/entity/state-badge.ts @@ -76,7 +76,7 @@ export class StateBadge extends LitElement { } hostStyle.backgroundImage = `url(${imageUrl})`; iconStyle.display = "none"; - } else { + } else if (stateObj.state === "on") { if (stateObj.attributes.hs_color && this.stateColor !== false) { const hue = stateObj.attributes.hs_color[0]; const sat = stateObj.attributes.hs_color[1]; diff --git a/src/panels/lovelace/cards/hui-light-card.ts b/src/panels/lovelace/cards/hui-light-card.ts index 51fcd575f8..23b2b46427 100644 --- a/src/panels/lovelace/cards/hui-light-card.ts +++ b/src/panels/lovelace/cards/hui-light-card.ts @@ -233,7 +233,7 @@ export class HuiLightCard extends LitElement implements LovelaceCard { } private _computeBrightness(stateObj: LightEntity): string { - if (!stateObj.attributes.brightness) { + if (stateObj.state === "off" || !stateObj.attributes.brightness) { return ""; } const brightness = stateObj.attributes.brightness; @@ -241,7 +241,7 @@ export class HuiLightCard extends LitElement implements LovelaceCard { } private _computeColor(stateObj: LightEntity): string { - if (!stateObj.attributes.hs_color) { + if (stateObj.state === "off" || !stateObj.attributes.hs_color) { return ""; } const [hue, sat] = stateObj.attributes.hs_color;