From a63f9a96a5e4d4582ca90095c49464b0462a451a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Wiedemann?= Date: Sun, 30 Jul 2023 14:13:52 +0000 Subject: [PATCH] fix: color: auto/auto-no-temperature was broken Fix #737 --- src/button-card.ts | 8 ++++---- src/common/const.ts | 2 ++ 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/button-card.ts b/src/button-card.ts index 56d76db..404c6be 100644 --- a/src/button-card.ts +++ b/src/button-card.ts @@ -45,7 +45,7 @@ import copy from 'fast-copy'; import * as pjson from '../package.json'; import { deepEqual } from './deep-equal'; import { stateColorCss } from './common/state_color'; -import { DOMAINS_TOGGLE } from './common/const'; +import { AUTO_COLORS, DOMAINS_TOGGLE } from './common/const'; import { handleAction } from './handle-action'; import { fireEvent } from './common/fire-event'; import { HomeAssistant } from './types/homeassistant'; @@ -515,7 +515,7 @@ class ButtonCard extends LitElement { } else if (this._config!.color) { colorValue = this._config!.color; } - if (colorValue == 'auto' || colorValue == 'auto-no-temperature') { + if (AUTO_COLORS.includes(colorValue)) { color = this._getColorForLightEntity(state, colorValue !== 'auto-no-temperature'); } else if (colorValue) { color = colorValue; @@ -827,9 +827,9 @@ class ButtonCard extends LitElement { private _cardHtml(): TemplateResult { const configState = this._getMatchingConfigState(this._stateObj); let color: string = 'var(--state-inactive-color)'; - if (!!configState?.color) { + if (!!configState?.color && !AUTO_COLORS.includes(configState.color)) { color = configState.color; - } else if (!!this._config?.color) { + } else if (!!this._config?.color && !AUTO_COLORS.includes(this._config.color)) { if (this._stateObj) { if (stateActive(this._stateObj)) { color = this._config?.color || color; diff --git a/src/common/const.ts b/src/common/const.ts index 6d70506..7f36e5a 100644 --- a/src/common/const.ts +++ b/src/common/const.ts @@ -17,3 +17,5 @@ export const isUnavailableState = arrayLiteralIncludes(UNAVAILABLE_STATES); export const isOffState = arrayLiteralIncludes(OFF_STATES); export const DOMAINS_TOGGLE = new Set(['fan', 'input_boolean', 'light', 'switch', 'group', 'automation', 'humidifier']); + +export const AUTO_COLORS = ['auto', 'auto-no-temperature'];