From c6d02de1229f9d7616c8f2f5256eb6119c3dd564 Mon Sep 17 00:00:00 2001 From: = Date: Tue, 16 May 2023 08:54:46 +0100 Subject: [PATCH] add fallbacks for state badge color to improve compatibility with themes --- src/data/entity.ts | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/data/entity.ts b/src/data/entity.ts index de0cce7..db1d32e 100755 --- a/src/data/entity.ts +++ b/src/data/entity.ts @@ -36,11 +36,13 @@ export const codeRequired = (stateObj: HassEntity) => { }; export const computeStateColor = (stateObj: HassEntity) => { - if(!stateObj || !stateObj.state) return 'var(--state-unavailable-color)'; + if (!stateObj || !stateObj.state) return 'var(--state-unavailable-color)'; const state = stateObj.state; - if(state == AlarmStates.Disarmed) return 'var(--state-inactive-color)'; - if(Object.values(AlarmStates).includes(state as any)) return `var(--state-alarm_control_panel-${state}-color)`; + if (state == AlarmStates.Disarmed) + return 'var(--state-alarm_control_panel-disarmed-color, var(--state-alarm_control_panel-inactive-color, var(--state-inactive-color)))'; + if (Object.values(AlarmStates).includes(state as any)) + return `var(--state-alarm_control_panel-${state}-color, var(--state-alarm_control_panel-active-color, var(--state-active-color)))`; - return 'var(--disabled-color)'; -} \ No newline at end of file + return 'var(--disabled-color, var(--state-inactive-color))'; +};