mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-30 12:46:35 +00:00
💄 color lights unless explicitly set not to (#4603)
This commit is contained in:
parent
30211fe61d
commit
67a91b7c19
@ -35,11 +35,15 @@ class StateBadge extends LitElement {
|
|||||||
return html``;
|
return html``;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const domain = computeStateDomain(stateObj);
|
||||||
|
|
||||||
return html`
|
return html`
|
||||||
<ha-icon
|
<ha-icon
|
||||||
id="icon"
|
id="icon"
|
||||||
data-domain=${ifDefined(
|
data-domain=${ifDefined(
|
||||||
this.stateColor ? computeStateDomain(stateObj) : undefined
|
this.stateColor || (domain === "light" && this.stateColor !== false)
|
||||||
|
? domain
|
||||||
|
: undefined
|
||||||
)}
|
)}
|
||||||
data-state=${computeActiveState(stateObj)}
|
data-state=${computeActiveState(stateObj)}
|
||||||
.icon=${this.overrideIcon || stateIcon(stateObj)}
|
.icon=${this.overrideIcon || stateIcon(stateObj)}
|
||||||
@ -73,14 +77,14 @@ class StateBadge extends LitElement {
|
|||||||
hostStyle.backgroundImage = `url(${imageUrl})`;
|
hostStyle.backgroundImage = `url(${imageUrl})`;
|
||||||
iconStyle.display = "none";
|
iconStyle.display = "none";
|
||||||
} else {
|
} else {
|
||||||
if (stateObj.attributes.hs_color) {
|
if (stateObj.attributes.hs_color && this.stateColor !== false) {
|
||||||
const hue = stateObj.attributes.hs_color[0];
|
const hue = stateObj.attributes.hs_color[0];
|
||||||
const sat = stateObj.attributes.hs_color[1];
|
const sat = stateObj.attributes.hs_color[1];
|
||||||
if (sat > 10) {
|
if (sat > 10) {
|
||||||
iconStyle.color = `hsl(${hue}, 100%, ${100 - sat / 2}%)`;
|
iconStyle.color = `hsl(${hue}, 100%, ${100 - sat / 2}%)`;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (stateObj.attributes.brightness) {
|
if (stateObj.attributes.brightness && this.stateColor !== false) {
|
||||||
const brightness = stateObj.attributes.brightness;
|
const brightness = stateObj.attributes.brightness;
|
||||||
if (typeof brightness !== "number") {
|
if (typeof brightness !== "number") {
|
||||||
const errorMessage = `Type error: state-badge expected number, but type of ${
|
const errorMessage = `Type error: state-badge expected number, but type of ${
|
||||||
|
Loading…
x
Reference in New Issue
Block a user