mirror of
https://github.com/GeorgeSG/sarah.git
synced 2026-09-07 02:18:43 +00:00
Add with_state_indicator button template. Use for motion
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
default:
|
default:
|
||||||
template:
|
template:
|
||||||
- small
|
- small
|
||||||
- with_state
|
- with_state_background
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
half:
|
half:
|
||||||
template: with_state
|
template: with_state_background
|
||||||
size: 30px
|
size: 30px
|
||||||
show_icon: false
|
show_icon: false
|
||||||
hold_action:
|
hold_action:
|
||||||
|
|||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
with_state:
|
with_state_background:
|
||||||
state:
|
state:
|
||||||
- value: 'on'
|
- value: 'on'
|
||||||
styles:
|
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;
|
||||||
|
]]]
|
||||||
@@ -129,7 +129,7 @@
|
|||||||
- type: custom:button-card
|
- type: custom:button-card
|
||||||
template:
|
template:
|
||||||
- xs
|
- xs
|
||||||
- with_state
|
- with_state_background
|
||||||
entity: script.sonos_join_tv
|
entity: script.sonos_join_tv
|
||||||
icon: mdi:speaker-multiple
|
icon: mdi:speaker-multiple
|
||||||
name: TV
|
name: TV
|
||||||
@@ -141,29 +141,29 @@
|
|||||||
- type: custom:button-card
|
- type: custom:button-card
|
||||||
template:
|
template:
|
||||||
- xs
|
- xs
|
||||||
- with_state
|
- with_state_background
|
||||||
entity: binary_sensor.browser_kitchen
|
entity: binary_sensor.browser_kitchen
|
||||||
name: Motion
|
name: Motion
|
||||||
- type: custom:button-card
|
- type: custom:button-card
|
||||||
template:
|
template:
|
||||||
- xs
|
- xs
|
||||||
- with_state
|
- with_state_background
|
||||||
entity: binary_sensor.motion_1_ias_zone
|
entity: binary_sensor.motion_1_ias_zone
|
||||||
name: Motion 2
|
name: Motion 2
|
||||||
- type: custom:button-card
|
- type: custom:button-card
|
||||||
template:
|
template:
|
||||||
- xs
|
- xs
|
||||||
- with_state
|
- with_state_background
|
||||||
entity: binary_sensor.motion_2_ias_zone
|
entity: binary_sensor.motion_2_ias_zone
|
||||||
name: Hallway
|
name: Hallway
|
||||||
- type: custom:button-card
|
- type: custom:button-card
|
||||||
template:
|
template:
|
||||||
- xs
|
- xs
|
||||||
- with_state
|
- with_state_background
|
||||||
entity: media_player.nvidia_shield
|
entity: media_player.nvidia_shield
|
||||||
name: Shield
|
name: Shield
|
||||||
- type: custom:button-card
|
- type: custom:button-card
|
||||||
template:
|
template:
|
||||||
- xs
|
- xs
|
||||||
- with_state
|
- with_state_background
|
||||||
entity: switch.titanium_power
|
entity: switch.titanium_power
|
||||||
|
|||||||
@@ -236,17 +236,27 @@
|
|||||||
- type: horizontal-stack
|
- type: horizontal-stack
|
||||||
cards:
|
cards:
|
||||||
- type: custom:button-card
|
- type: custom:button-card
|
||||||
template: default
|
template:
|
||||||
|
- default
|
||||||
|
- with_state_indicator
|
||||||
entity: binary_sensor.motion_2_ias_zone
|
entity: binary_sensor.motion_2_ias_zone
|
||||||
name: Hallway
|
name: Hallway
|
||||||
|
variables:
|
||||||
|
state_indicator_id: automation.lighting_hallway_day_mode_motion_turn_lights_on
|
||||||
|
state_indicator_on_color: "var(--accent-color)"
|
||||||
- type: custom:button-card
|
- type: custom:button-card
|
||||||
template: default
|
template: default
|
||||||
entity: binary_sensor.browser_kitchen
|
entity: binary_sensor.browser_kitchen
|
||||||
name: Kitchen
|
name: Kitchen
|
||||||
- type: custom:button-card
|
- type: custom:button-card
|
||||||
template: default
|
template:
|
||||||
|
- default
|
||||||
|
- with_state_indicator
|
||||||
entity: binary_sensor.motion_1_ias_zone
|
entity: binary_sensor.motion_1_ias_zone
|
||||||
name: Kitchen 2
|
name: Kitchen 2
|
||||||
|
variables:
|
||||||
|
state_indicator_id: automation.lighting_kitchen_day_mode_motion_turn_lights_on_after_sunset
|
||||||
|
state_indicator_on_color: "var(--accent-color)"
|
||||||
|
|
||||||
- type: vertical-stack
|
- type: vertical-stack
|
||||||
title: Presence
|
title: Presence
|
||||||
|
|||||||
Reference in New Issue
Block a user