From 0edef3c5268f5d6b2e62edeb58350275ca172eac Mon Sep 17 00:00:00 2001 From: Georgi Gardev Date: Fri, 1 May 2020 16:48:03 +0300 Subject: [PATCH] Add more options --- .../with_state_indicator_button.yaml | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/config/lovelace/button_card_templates/with_state_indicator_button.yaml b/config/lovelace/button_card_templates/with_state_indicator_button.yaml index 4219396..c355400 100644 --- a/config/lovelace/button_card_templates/with_state_indicator_button.yaml +++ b/config/lovelace/button_card_templates/with_state_indicator_button.yaml @@ -4,6 +4,10 @@ with_state_indicator: state_indicator_size: 3px state_indicator_on_color: white state_indicator_off_color: transparent + + # Used when the button entity's state is 'on': + state_on_indicator_on_color: white + state_on_indicator_off_color: transparent triggers_update: all # unfortunately a template doesn't seem to work here :/ double_tap_action: action: call-service @@ -14,9 +18,17 @@ with_state_indicator: card: - border-bottom: >- [[[ - const color = states[variables.state_indicator_id].state === 'on' + let color; + + if (entity.state === 'on') { + color = states[variables.state_indicator_id].state === 'on' + ? variables.state_on_indicator_on_color + : variables.state_on_indicator_off_color; + } else { + color = states[variables.state_indicator_id].state === 'on' ? variables.state_indicator_on_color : variables.state_indicator_off_color; + } return variables.state_indicator_size + ' solid ' + color; ]]]