-
Notifications
You must be signed in to change notification settings - Fork 3
/
card.yaml
218 lines (218 loc) · 8.95 KB
/
card.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
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
type: vertical-stack
cards:
- type: conditional
conditions:
- entity: sensor.formula_1
state: "no race this week"
card:
type: entities
title: Formula 1
state_color: true
header:
type: picture
image: >-
https://upload.wikimedia.org/wikipedia/commons/thumb/3/33/F1.svg/1280px-F1.svg.png
entities:
- type: custom:text-divider-row
text: NEXT EVENT
- type: custom:template-entity-row
icon: mdi:alpha-g-box-outline
name: "{{ state_attr('calendar.f1_race', 'message') |replace('Race: 2022', '')}}"
state: "{{ state_attr('calendar.f1_race', 'location') }}"
- type: custom:template-entity-row
icon: mdi:alpha-c-box-outline
name: Count Down
state: >
{% set midnight = now().replace(hour=0, minute=0, second=0, microsecond=0).timestamp() %}
{% set event = state_attr('calendar.f1_race', 'start_time') | as_timestamp %}
{% set delta = ((event - midnight) // 86400) | int %}
{% if delta == 0 %}
{{ ((as_timestamp(state_attr('calendar.f1_race', 'start_time')) - as_timestamp(now()))/3600) |round }} hours
{% else %}
{% if (delta / 7) | int < 2 and (delta / 7) | int >= 1 %}
{{ (delta / 7) | int}} week and {{ delta - (((delta / 7 )|int) * 7)}} days.
{% elif (delta / 7) | int == 0 %}
{{ delta - (((delta / 7 )|int) * 7) }} days.
{% else %}
{{ (delta / 7) | int}} week and {{ delta - (((delta / 7 )|int) * 7)}} days.
{% endif %}
{% endif %}
secondary: >
{% if states('sensor.f1_sprint') == 'on' %}
{{ as_timestamp(state_attr('calendar.f1_fp1', 'start_time'), 0) | timestamp_custom('%d') }}, {{ as_timestamp(state_attr('calendar.f1_fp2', 'start_time'), 0) | timestamp_custom('%d') }} & {{ as_timestamp(state_attr('calendar.f1_race', 'start_time'), 0) | timestamp_custom('%d %B') }}
{% else %}
{{ as_timestamp(state_attr('calendar.f1_fp1', 'start_time'), 0) | timestamp_custom('%d') }}, {{ as_timestamp(state_attr('calendar.f1_fp3', 'start_time'), 0) | timestamp_custom('%d') }} & {{ as_timestamp(state_attr('calendar.f1_race', 'start_time'), 0) | timestamp_custom('%d %B') }}
{% endif %}
- type: conditional
conditions:
- entity: sensor.formula_1
state: "race this week"
card:
type: entities
title: Formula 1
state_color: true
header:
type: picture
image: >-
https://upload.wikimedia.org/wikipedia/commons/thumb/3/33/F1.svg/1280px-F1.svg.png
entities:
- type: custom:text-divider-row
text: LOCATION DETAILS
- type: custom:template-entity-row
name: Track
state: '{{ state_attr(''sensor.formula_1'', ''track'') }}'
icon: mdi:alpha-t-box-outline
- type: custom:template-entity-row
name: GP
state: '{{ state_attr(''sensor.formula_1'', ''gp_name'') }}'
icon: mdi:alpha-g-box-outline
- type: custom:text-divider-row
text: RACE DETAILS
- type: conditional
conditions:
- entity: sensor.f1_sprint
state: 'off'
row:
type: custom:template-entity-row
name: 1st free practice
state: >
{% if state_attr('sensor.formula_1', 'fp1_day') != 'No 1st free practice
this week' %}
{{ state_attr('sensor.formula_1', 'fp1_day') }}, {{ state_attr('sensor.formula_1', 'fp1_time') }}
{% else %}
No 1st free practice this week
{% endif %}
icon: mdi:numeric-1-box-outline
- type: conditional
conditions:
- entity: sensor.f1_sprint
state: 'off'
row:
type: custom:template-entity-row
name: 2nd free practice
state: >
{% if state_attr('sensor.formula_1', 'fp2_day') != 'No 2nd free practice
this week' %}
{{ state_attr('sensor.formula_1', 'fp2_day') }}, {{ state_attr('sensor.formula_1', 'fp2_time') }}
{% else %}
No 2nd free practice this week
{% endif %}
icon: mdi:numeric-2-box-outline
- type: conditional
conditions:
- entity: sensor.f1_sprint
state: 'off'
row:
type: custom:template-entity-row
name: 3rd free practice
state: >
{% if state_attr('sensor.formula_1', 'fp3_day') != 'No 3rd free practice
this week' %}
{{ state_attr('sensor.formula_1', 'fp3_day') }}, {{ state_attr('sensor.formula_1', 'fp3_time') }}
{% else %}
No 3rd free practice this week
{% endif %}
icon: mdi:numeric-3-box-outline
- type: conditional
conditions:
- entity: sensor.f1_sprint
state: 'off'
row:
type: custom:template-entity-row
name: Qualification
state: >
{% if state_attr('sensor.formula_1', 'q_day') != 'No qualification this
week' %}
{{ state_attr('sensor.formula_1', 'q_day') }}, {{ state_attr('sensor.formula_1', 'q_time') }}
{% else %}
No qualification this week
{% endif %}
icon: mdi:alpha-q-box-outline
- type: conditional
conditions:
- entity: sensor.f1_sprint
state: 'off'
row:
type: custom:template-entity-row
name: Race
state: |
{% if state_attr('sensor.formula_1', 'r_day') != 'No race this week' %}
{{ state_attr('sensor.formula_1', 'r_day') }}, {{ state_attr('sensor.formula_1', 'r_time') }}
{% else %}
No race this week
{% endif %}
icon: mdi:alpha-r-box-outline
- type: conditional
conditions:
- entity: sensor.f1_sprint
state: 'on'
row:
type: custom:template-entity-row
name: 1st free practice
state: >
{% if state_attr('sensor.formula_1', 'fp1_day') != 'No 1st free practice
this week' %}
{{ state_attr('sensor.formula_1', 'fp1_day') }}, {{ state_attr('sensor.formula_1', 'fp1_time') }}
{% else %}
No 1st free practice this week
{% endif %}
icon: mdi:numeric-1-box-outline
- type: conditional
conditions:
- entity: sensor.f1_sprint
state: 'on'
row:
type: custom:template-entity-row
name: Sprint Qualification
state: >
{% if state_attr('sensor.formula_1', 'sprint_q_day') != 'No sprint
qualification this week' %}
{{ state_attr('sensor.formula_1', 'sprint_q_day') }}, {{ state_attr('sensor.formula_1', 'sprint_q_time') }}
{% else %}
No sprint qualification this week
{% endif %}
icon: mdi:alpha-q-box-outline
- type: conditional
conditions:
- entity: sensor.f1_sprint
state: 'on'
row:
type: custom:template-entity-row
name: 2nd free practice
state: >
{% if state_attr('sensor.formula_1', 'fp2_day') != 'No 2nd free practice
this week' %}
{{ state_attr('sensor.formula_1', 'fp2_day') }}, {{ state_attr('sensor.formula_1', 'fp2_time') }}
{% else %}
No 2nd free practice this week
{% endif %}
icon: mdi:numeric-2-box-outline
- type: conditional
conditions:
- entity: sensor.f1_sprint
state: 'on'
row:
type: custom:template-entity-row
name: Sprint Race
state: >
{% if state_attr('sensor.formula_1', 'sprint_race_day') != 'No sprint
race this week' %}
{{ state_attr('sensor.formula_1', 'sprint_race_day') }}, {{ state_attr('sensor.formula_1', 'sprint_race_time') }}
{% else %}
No sprint race this week
{% endif %}
icon: mdi:alpha-r-box-outline
- type: conditional
conditions:
- entity: sensor.f1_sprint
state: 'on'
row:
type: custom:template-entity-row
name: Race
state: |
{% if state_attr('sensor.formula_1', 'r_day') != 'No race this week' %}
{{ state_attr('sensor.formula_1', 'r_day') }}, {{ state_attr('sensor.formula_1', 'r_time') }}
{% else %}
No race this week
{% endif %}
icon: mdi:alpha-r-box-outline