Skip to content

Commit a63f9a9

Browse files
committed
fix: color: auto/auto-no-temperature was broken
Fix #737
1 parent bb4bc29 commit a63f9a9

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

src/button-card.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ import copy from 'fast-copy';
4545
import * as pjson from '../package.json';
4646
import { deepEqual } from './deep-equal';
4747
import { stateColorCss } from './common/state_color';
48-
import { DOMAINS_TOGGLE } from './common/const';
48+
import { AUTO_COLORS, DOMAINS_TOGGLE } from './common/const';
4949
import { handleAction } from './handle-action';
5050
import { fireEvent } from './common/fire-event';
5151
import { HomeAssistant } from './types/homeassistant';
@@ -515,7 +515,7 @@ class ButtonCard extends LitElement {
515515
} else if (this._config!.color) {
516516
colorValue = this._config!.color;
517517
}
518-
if (colorValue == 'auto' || colorValue == 'auto-no-temperature') {
518+
if (AUTO_COLORS.includes(colorValue)) {
519519
color = this._getColorForLightEntity(state, colorValue !== 'auto-no-temperature');
520520
} else if (colorValue) {
521521
color = colorValue;
@@ -827,9 +827,9 @@ class ButtonCard extends LitElement {
827827
private _cardHtml(): TemplateResult {
828828
const configState = this._getMatchingConfigState(this._stateObj);
829829
let color: string = 'var(--state-inactive-color)';
830-
if (!!configState?.color) {
830+
if (!!configState?.color && !AUTO_COLORS.includes(configState.color)) {
831831
color = configState.color;
832-
} else if (!!this._config?.color) {
832+
} else if (!!this._config?.color && !AUTO_COLORS.includes(this._config.color)) {
833833
if (this._stateObj) {
834834
if (stateActive(this._stateObj)) {
835835
color = this._config?.color || color;

src/common/const.ts

+2
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,5 @@ export const isUnavailableState = arrayLiteralIncludes(UNAVAILABLE_STATES);
1717
export const isOffState = arrayLiteralIncludes(OFF_STATES);
1818

1919
export const DOMAINS_TOGGLE = new Set(['fan', 'input_boolean', 'light', 'switch', 'group', 'automation', 'humidifier']);
20+
21+
export const AUTO_COLORS = ['auto', 'auto-no-temperature'];

0 commit comments

Comments
 (0)