-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathnotify.yaml
More file actions
176 lines (170 loc) · 5.13 KB
/
Copy pathnotify.yaml
File metadata and controls
176 lines (170 loc) · 5.13 KB
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
####{ CreativeBC }####| Light |####[ github.com/wfurphy/creative-button-card-templates ]####>
# :: @Changes v0.3::> Fixed z-index, brightness & effects, replace __debugJson with __console.
notify:
type: custom:button-card
template:
- cbcjs
- resizable
- datetime
variables:
__console: >
[[[
const json = JSON.parse(entity.state);
if (json.type == 'clear') return;
const message = json.message ?? '';
const output = `::CBC::| ${json.type.toUpperCase()} |::[${entity?.entity_id}]::::>\n${message}`;
switch (json.type) {
case 'warning':
case 'warn':
console.warn(output, json);
break;
case 'error':
console.error(output, json);
break;
default:
console.log(output, json);
}
]]]
__color: >
[[[
return function(col, opc = 1) {
let out = null
if (col) {
if (Array.isArray(col) && col.length) {
out = `${col[0]}, ${col[1]}, ${col[2]}`
} else if (col !== '[]') {
col = col.trim()
switch (col.substring(0,1)) {
case '[':
out = col.substring(1, col.length - 1)
break
case 'r':
const b = col.search('(')
if (b !== -1) {
out = col.substring(b + 1, col.length - 1)
}
break
case '#':
return `${col}${Math.floor(opc * 255).toString(16).padStart(2, 0)}`
}
}
}
if (!out) {
switch (JSON.parse(entity.state).type) {
case 'event':
out = '25, 136, 115'
break
case 'warning':
case 'warn':
out = '254, 190, 110'
break
case 'error':
out = '157, 48, 66'
break
case 'info':
default:
out = '71, 133, 183'
break
}
}
return `rgba(${out}, ${opc})`
}
]]]
icon: >
[[[
const json = JSON.parse(entity.state)
if (json.icon && json.icon.search('mdi:') !== -1) { return json.icon }
switch (json.type) {
case 'event':
return 'mdi:calendar'
case 'warning':
case 'warn':
return 'mdi:alert-outline'
case 'error':
return 'mdi:alert-octagon-outline'
case 'info':
default:
return 'mdi:information-outline'
}
]]]
script: script.dashbaord_notification
_updated_at: "[[[ return entity.last_updated || null ]]]"
json: "[[[ return JSON.parse(entity.state) ]]]"
name: "[[[ return variables.json.title ]]]"
label: "[[[ return variables.json.message ]]]"
show_icon: true
show_name: true
show_label: true
size: 40px
tap_action:
action: call-service
service: input_text.set_value
service_data:
entity_id: "[[[ return entity?.entity_id ]]]"
value: >
[[[
return JSON.stringify({
type: 'clear',
persistent: false
})
]]]
double_tap_action:
action: call-service
service: input_text.set_value
service_data:
entity_id: "[[[ return entity?.entity_id ]]]"
value: >
[[[
return JSON.stringify({
type: "info",
icon: "mdi:egg-easter",
title: "You Found Me!",
message: "That's right, it's your old software favourite, an easter egg!",
color: '#bd4dfa',
persistent: false
})
]]]
icon: "[[[ return variables.icon ]]]"
styles:
card:
- display: "[[[ return !variables.json.type || variables.json.type === 'clear' ? 'none' : 'block' ]]]"
- background-color: "[[[ return variables.__color(variables.json.color, 0.4) ]]]"
- padding: 5px
- text-align: left
grid:
- grid-template-areas: |
"i n n x"
"i l l ."
"i . u u"
- grid-template-columns: 1fr 3fr 2fr 15px
- grid-template-rows: 1fr min-content 20px
- align-items: center
- justify-items: start
icon:
- color: "[[[ return variables.__color(variables.json.color, 1) ]]]"
name:
- text-align: left
- justify-self: start
- color: "[[[ return variables.__color(variables.json.color, 1) ]]]"
label:
- justify-self: start
- text-align: left
- font-size: 14px
- white-space: normal
- text-wrap: word
- opacity: 0.6
custom_fields:
x:
- width: 15px
- margin-top: -4px
- align-self: start
- justify-self: end
- opacity: 0.6
u:
- text-align: left
- justify-self: end
- font-size: 12px
- opacity: 0.6
custom_fields:
x: "[[[ return html`<ha-icon icon=\"mdi:close\"></ha-icon>` ]]]"
u: "[[[ return html`<span class=\"ellipses\">${variables._updated_at ? variables.__dateString(variables._updated_at, 'R') : ''}</span>` ]]]"