mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-24 09:46:36 +00:00
Ensure consistent light state icon brightness (#14740)
* Ensure consistent light state icon brightness * Update hui-entity-card.ts * Update hui-entity-card.ts Co-authored-by: Paul Bottein <paul.bottein@gmail.com>
This commit is contained in:
parent
f2b7288e92
commit
9c27bb37a0
@ -193,8 +193,10 @@ export class HuiButtonCard extends LitElement implements LovelaceCard {
|
||||
.icon=${this._config.icon}
|
||||
.state=${stateObj}
|
||||
style=${styleMap({
|
||||
color: colored ? this._computeColor(stateObj) : "",
|
||||
filter: colored ? this._computeBrightness(stateObj) : "",
|
||||
color: colored ? this._computeColor(stateObj) : undefined,
|
||||
filter: colored
|
||||
? this._computeBrightness(stateObj)
|
||||
: undefined,
|
||||
height: this._config.icon_height
|
||||
? this._config.icon_height
|
||||
: "",
|
||||
|
@ -29,6 +29,7 @@ import "../../../components/ha-card";
|
||||
import "../../../components/ha-icon";
|
||||
import { UNAVAILABLE_STATES } from "../../../data/entity";
|
||||
import { formatAttributeValue } from "../../../data/entity_attributes";
|
||||
import { LightEntity } from "../../../data/light";
|
||||
import { HomeAssistant } from "../../../types";
|
||||
import { computeCardSize } from "../common/compute-card-size";
|
||||
import { findEntities } from "../common/find-entities";
|
||||
@ -149,6 +150,7 @@ export class HuiEntityCard extends LitElement implements LovelaceCard {
|
||||
data-state=${stateObj.state}
|
||||
style=${styleMap({
|
||||
color: colored ? this._computeColor(stateObj) : undefined,
|
||||
filter: colored ? this._computeBrightness(stateObj) : undefined,
|
||||
height: this._config.icon_height
|
||||
? this._config.icon_height
|
||||
: "",
|
||||
@ -201,6 +203,9 @@ export class HuiEntityCard extends LitElement implements LovelaceCard {
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
if (stateObj.attributes.rgb_color && stateActive(stateObj)) {
|
||||
return `rgb(${stateObj.attributes.rgb_color.join(",")})`;
|
||||
}
|
||||
const iconColor = stateColorCss(stateObj);
|
||||
if (iconColor) {
|
||||
return `rgb(${iconColor})`;
|
||||
@ -208,6 +213,14 @@ export class HuiEntityCard extends LitElement implements LovelaceCard {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
private _computeBrightness(stateObj: HassEntity | LightEntity): string {
|
||||
if (stateObj.attributes.brightness && stateActive(stateObj)) {
|
||||
const brightness = stateObj.attributes.brightness;
|
||||
return `brightness(${(brightness + 245) / 5}%)`;
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
protected shouldUpdate(changedProps: PropertyValues): boolean {
|
||||
// Side Effect used to update footer hass while keeping optimizations
|
||||
if (this._footerElement) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user