Skip to content

Commit

Permalink
fix: color: auto/auto-no-temperature was broken
Browse files Browse the repository at this point in the history
Fix #737
  • Loading branch information
RomRider committed Jul 30, 2023
1 parent bb4bc29 commit a63f9a9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/button-card.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 2 additions & 0 deletions src/common/const.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'];

0 comments on commit a63f9a9

Please sign in to comment.