Add with_state_indicator button template. Use for motion

This commit is contained in:
2020-05-01 16:39:12 +03:00
parent caf330bfed
commit 75522efb2b
6 changed files with 43 additions and 11 deletions
@@ -1,4 +1,4 @@
default:
template:
- small
- with_state
- with_state_background
@@ -1,5 +1,5 @@
half:
template: with_state
template: with_state_background
size: 30px
show_icon: false
hold_action:
@@ -1,4 +1,4 @@
with_state:
with_state_background:
state:
- value: 'on'
styles:
@@ -0,0 +1,22 @@
with_state_indicator:
variables:
state_indicator_id:
state_indicator_size: 3px
state_indicator_on_color: white
state_indicator_off_color: transparent
triggers_update: all # unfortunately a template doesn't seem to work here :/
double_tap_action:
action: call-service
service: "[[[ return variables.state_indicator_id.split('.')[0] + '.toggle' ]]]"
service_data:
entity_id: "[[[ return variables.state_indicator_id ]]]"
styles:
card:
- border-bottom: >-
[[[
const 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;
]]]