handle brightness reporting while light off (#5391)

This commit is contained in:
Ian Richardson 2020-04-01 04:06:58 -05:00 committed by GitHub
parent c351402556
commit 465efa460e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 3 deletions

View File

@ -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];

View File

@ -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;