/
ui-lovelace.yaml
178 lines (178 loc) · 5.74 KB
/
ui-lovelace.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
title: Home
background: var(--background-image)
views:
- !include ui-lovelace/main.yaml
- !include ui-lovelace/environment.yaml
- !include ui-lovelace/entertainment.yaml
- !include ui-lovelace/internet.yaml
- !include ui-lovelace/security.yaml
- !include ui-lovelace/gallery.yaml
- !include ui-lovelace/floorplan.yaml
- !include ui-lovelace/devices.yaml
- !include ui-lovelace/test.yaml
button_card_templates:
clock:
variables:
timezone: "Continent/City"
show_name: true
show_state: true
show_icon: true
show_label: true
label: >
[[[
return (new Date()).toLocaleDateString("en-ZA", {timeZone: variables.timezone});
]]]
icon: >
[[[
var hourNamesIndexed = ["twelve", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten", "eleven", "twelve"];
var timeParts = (new Date()).toLocaleTimeString("en-ZA", {timeZone: variables.timezone, hour12: true}).split(':');
var hour = parseInt(timeParts[0]);
var minute = parseInt(timeParts[1]);
return "mdi:clock-time-" + hourNamesIndexed[hour] + "-outline";
]]]
color: var(--paper-item-icon-color)
styles:
grid:
- grid-template-areas: '"n" "i" "s" "l"'
name:
- color: var(--secondary-text-color)
- font-size: 1rem
state:
- color: var(--secondary-text-color)
- font-size: 0.8rem
label:
- color: var(--secondary-text-color)
- font-size: 0.8rem
tap_action: none
smart_bulb_light:
variables:
above_threshold: |
[[[
let threshold = 255;
if (entity.state === 'on' && entity.attributes.rgb_color) {
let rgb_sum = entity.attributes.rgb_color.reduce((a, b) => a + b, 0);
return rgb_sum >= 3 * threshold;
}
return false;
]]]
size: 20%
color: var(--button-card-light-color)
show_label: true
label: >
[[[
var b = entity.attributes.brightness;
return parseInt(b ? (b/255)*100 : '0') + '%';
]]]
styles:
name:
- color: var(--paper-item-icon-color)
label:
- color: var(--paper-item-icon-color)
- padding-left: 1ex
# https://community.home-assistant.io/t/lovelace-button-card/65981/4599
# https://community.home-assistant.io/t/lovelace-button-card/65981/4788
icon:
- color: |
[[[
if (variables.above_threshold) { // above threshold == white here
return 'var(--paper-item-icon-active-color)';
} else if (entity.state === 'on') {
return 'var(--button-card-light-color)'; // already includes brightness/color support
} else if (entity.state === 'off') { // off
return 'var(--paper-item-icon-color)';
} else { // unavailable
return 'var(--primary-text-color)';
}
]]]
- filter: '[[[ return variables.above_threshold ? `brightness(${(entity.attributes.brightness/255 + 1)/2})` : null; ]]]'
card:
- font-size: 12px
grid:
- grid-template-areas: '"l" "i" "n"'
- grid-template-rows: min-content 1fr min-content
- grid-template-columns: 1fr
state:
- value: 'unavailable'
styles:
icon:
- color: var(--state-icon-unavailable-color)
tap_action:
haptic: light
action: call-service
service: script.toggle_light
service_data:
light: "[[[ return entity.entity_id; ]]]"
profile: "[[[ return variables.profile; ]]]"
double_tap_action:
action: call-service
haptic: medium
service: script.force_on_smart_bulb
service_data:
light: "[[[ return entity.entity_id; ]]]"
hold_action:
action: more-info
haptic: selection
shutdown:
name: "[[[ return entity.attributes.friendly_name; ]]]"
size: 30%
styles:
name:
- color: var(--paper-item-icon-color)
card:
- font-size: 12px
hold_action:
action: call-service
haptic: heavy
service: script.shutdown_remote_host
service_data:
name: "[[[ return entity.attributes.friendly_name; ]]]"
host: "[[[ return entity.attributes.friendly_name.toLowerCase(); ]]]" # must match .ssh/config
confirmation:
text: "[[[ return `Are you sure you want to shut down ${entity.attributes.friendly_name}?` ]]]"
restart:
name: "[[[ return variables.name; ]]]"
size: 20%
styles:
name:
- color: var(--paper-item-icon-color)
card:
- font-size: 12px
double_tap_action:
action: call-service
haptic: medium
service: switch.turn_on
service_data:
entity_id: "[[[ return variables.switch_entity; ]]]"
confirmation:
text: "[[[ return `Are you sure you want to restart the ${variables.name.toLowerCase()} device?`; ]]]"
remote:
variables:
selection: "Remote State"
entity: input_select.selected_remote
name: "[[[ return variables.selection ]]]"
size: 50%
color_type: icon
styles:
name:
- color: var(--paper-item-icon-color)
label:
- color: var(--paper-item-icon-color)
- padding-left: 1ex
card:
- font-size: 12px
icon:
- color: |
[[[
if (entity.state == variables.selection) {
return 'var(--paper-item-icon-active-color)';
} else {
return 'var(--paper-item-icon-color)';
}
]]]
tap_action:
action: call-service
haptic: light
service: input_select.select_option
service_data:
entity_id: input_select.selected_remote
option: "[[[ return variables.selection; ]]]"