-
Notifications
You must be signed in to change notification settings - Fork 3
/
clockface_awtrix_app.yaml
451 lines (413 loc) · 16.7 KB
/
clockface_awtrix_app.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
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
blueprint:
name: "AWTRIX Clock face"
description: >
## Custom Clockface for AWTRIX Light
This blueprint provides a custom clockface for the AWTRIX Light. It allows you to personalize various aspects of the clockface to suit your preferences.
## Deprecated
Since this blueprint is now native implemented in AWTRIX v0.72, this blueprint will not recieve any updates anymore.
### Screenshot
![](https://raw.githubusercontent.com/RDG88/Homeassistant_Blueprints/main/thumbnails/clockface_screenshot.svg)
### Features
- Change the color of the top and bottom parts of the calendar display.
- Choose between two different calendar types.
- Customize the color of the displayed time.
- Select the day that will mark the beginning of the week. Monday or Sunday.
- Make adjustments to the positioning and color of the weekday bar, with the ability to change the color specifically for Sundays.
- It is not necessary to upload icons for the days because the draw function is used, so the icons are generated dynamically.
- A night clock mode is available, which displays a customized color, and you have the possibility to disable app transitions, automatic brightness, and the color of the night clock.
### Prerequisites
Before using this blueprint, ensure that you have the Home Assistant time_date Sensor integrated with the display_option time. If you haven't already set it up, you can find instructions for the integration [here](https://www.home-assistant.io/integrations/time_date/).
### Credits
@Hans from the AWTRIX discord deserves credit for this blueprint. He originally designed a nodered flow that incorporates the drawing functions to create this custom clock face.
domain: automation
input:
awtrix:
name: AWTRIX Light
description: Select the Awtrix light
selector:
device:
filter:
- integration: mqtt
manufacturer: Blueforcer
model: AWTRIX Light
multiple: true
awtrix_app_name:
name: AWTRIX Application name
description: This is the custom app name that will be added to AWTRIX, should be unique
selector:
text: {}
default: clock_face
time_sensor:
name: Time sensor
description: Select the time sensor from the time_date integration
selector:
entity:
filter:
- integration: time_date
multiple: false
duration:
name: Duration (in seconds)
description: Sets how long the app should be displayed.
default: "10"
lifetime:
name: Lifetime of the app (in seconds)
description: Removes the custom app when there is no update after the given time in seconds.
default: "70"
weekday_marker_bar_position:
name: Where should the weekday bar be positioned?
description: >
Select the position of the weekday bar.
![](https://raw.githubusercontent.com/RDG88/Homeassistant_Blueprints/main/thumbnails/clockface_no-weekbar.svg) `Don't show the weekday bar`
---
![](https://raw.githubusercontent.com/RDG88/Homeassistant_Blueprints/main/thumbnails/clockface_above-weekbar.svg) `Show the weekday bar above the time`
---
![](https://raw.githubusercontent.com/RDG88/Homeassistant_Blueprints/main/thumbnails/clockface_below-weekbar.svg) `Show the weekday bar below the time`
selector:
select:
options:
- label: Don't show the weekday bar
value: never
- label: Show the weekday bar above the time
value: top
- label: Show the weekday bar below the time
value: bottom
default: "bottom"
week_start:
name: With what day should the week begin?
description: >
Please select the day that will mark the beginning of the week. Depending on your choice, the Sunday marker will either be positioned at the start or the end.
selector:
select:
options:
- label: Monday
value: "monday"
- label: Sunday
value: "sunday"
default: "monday"
calendar_style:
name: Select the calendar style
description: >
Select the calendar style
![](https://raw.githubusercontent.com/RDG88/Homeassistant_Blueprints/main/thumbnails/clockface_cal_style1.svg) `Calendar Style 1`
---
![](https://raw.githubusercontent.com/RDG88/Homeassistant_Blueprints/main/thumbnails/clockface_cal_style2.svg) `Calendar Style 2`
selector:
select:
options:
- label: Calendar style 1
value: style1
- label: Calendar style 2
value: style2
default: "style1"
color_marker_current:
name: Color for the current weekday marker
description: Select the color for the current week day marker
selector:
color_rgb:
default: [255, 255, 255]
color_marker_sunday:
name: Color for when the current day is sunday marker
description: Select the color when the current day is Sunday.
selector:
color_rgb:
default: [255, 255, 255]
color_weekday_marker:
name: Color for the weekday bar
description: Choose the color of the markers displayed on the weekday bar.
selector:
color_rgb:
default: [69, 69, 69]
color_weekday_number:
name: Color for the weekday number
description: Choose the color for the weekday number displayed within the calendar icon.
selector:
color_rgb:
default: [0, 0, 0]
color_time:
name: Color for the time
description: Specify the color for the displayed time.
selector:
color_rgb:
default: [255, 255, 255]
color_top_calendar:
name: Color for the top part of the calendar
description: >
Select the color for the top part of the calendar.
*Note: This color selector is applicable only to Calendar style 1.*
selector:
color_rgb:
default: [255, 0, 0]
color_bottom_calendar:
name: Color for the bottom part of the calendar
description: >
Select the color for the bottom part of the calendar.
*Note: This color selector is applicable only to Calendar style 1 and Calendar style 2.*
selector:
color_rgb:
default: [255, 255, 255]
night_mode:
name: Enables or disables night mode
description: >
This settings allows you to enable or disable night mode.
![](https://raw.githubusercontent.com/RDG88/Homeassistant_Blueprints/main/thumbnails/clockface_night-clock.svg)
*Note: If you keep night mode disabled, the settings below won't do anything*
selector:
boolean:
default: false
wake_up_time:
name: Wake-up time
description: At what time the clock needs to wake-up?
selector:
time: {}
default: "08:00:00"
sleep_time:
name: Sleep time
description: At what time the clock should go to sleep?
selector:
time: {}
default: "23:00:00"
sleep_settings_atrans:
name: Enables or disables automatic transition of apps in sleep mode.
description: >
This setting allows you to enable or disable automatic transition of apps in sleep mode.
selector:
boolean:
default: false
sleep_settings_bri:
name: Sleep brightness settings
description: >
What is the brightness for night mode?
selector:
number:
min: 0
max: 255
default: "1"
sleep_settings_abri:
name: Enables or disables automatic brightening in sleep mode
description: >
This setting allows you to enable or disable automatic brightening in sleep mode.
selector:
boolean:
default: false
sleep_settings_color:
name: Color settings for the night clock
description: This settings allows you to change the color of the night clock.
selector:
color_rgb:
default: [255, 0, 0]
wakeup_settings_atrans:
name: Enables or disables automatic transition of apps in wake-up mode
description: >
This setting allows you to enable or disable the automatic transition of apps in wake-up mode.
selector:
boolean:
default: true
wakeup_settings_bri:
name: Wake up brightness settings (1-255)
description: >
This settings allows you to adjust the brightness for wake-up mode, pick a value between 1 and 255.
selector:
number:
min: 1
max: 255
default: "127"
wakeup_settings_abri:
name: Enables or disables automatic brightening in wake-up mode
description: >
This setting allows you to enable or disable automatic brightening in wake-up mode.
selector:
boolean:
default: false
variables:
device_ids: !input awtrix
app: !input awtrix_app_name
marker_color: !input color_weekday_marker
weekday_color: !input color_weekday_number
marker_color_current: !input color_marker_current
marker_color_sunday: !input color_marker_sunday
time_color: !input color_time
top_calendar_color: !input color_top_calendar
bottom_calendar_color: !input color_bottom_calendar
marker_bar_position: !input weekday_marker_bar_position
sensor_time: !input time_sensor
calendar_style: !input calendar_style
week_start: !input week_start
duration: !input duration
lifetime: !input lifetime
night_mode: !input night_mode
wake_up_time: !input wake_up_time
sleep_time: !input sleep_time
wakeup_settings_atrans: !input wakeup_settings_atrans
sleep_settings_atrans: !input sleep_settings_atrans
sleep_settings_color: !input sleep_settings_color
sleep_settings_abri: !input sleep_settings_abri
sleep_settings_bri: !input sleep_settings_bri
wakeup_settings_bri: !input wakeup_settings_bri
wakeup_settings_abri: !input wakeup_settings_abri
awtrix_devices: >-
{%- set ns = namespace(awtrix = []) -%}
{%- for device_id in device_ids -%}
{%- set device_name = iif(device_attr(device_id, 'name_by_user') != none, device_attr(device_id, 'name_by_user'), device_attr(device_id, 'name')) -%}
{%- set entity = expand(device_entities(device_id)) | select('search', 'device_topic') | map(attribute='entity_id') | first -%}
{%- set topic = states(entity) -%}
{% set ns.awtrix = ns.awtrix + [{"device": device_name, "entity": entity, "topic": topic}] -%}
{%- endfor -%}
{{ ns.awtrix }}
payload_sleep_switch: >-
{
"name": "{{ app }}"
}
payload_sleep_settings: >-
{ "ATRANS": {{ sleep_settings_atrans | lower }},
"BRI": {{ sleep_settings_bri }},
"ABRI": {{ sleep_settings_abri | lower }}
}
payload_wakeup_settings: >-
{ "ATRANS": {{ wakeup_settings_atrans | lower }},
"BRI": {{ wakeup_settings_bri }},
"ABRI": {{ wakeup_settings_abri | lower }}
}
payload: >-
{% set weekday = now().isoweekday() %}
{% if week_start == "sunday" %} {% set weekday = (weekday % 7) + 1 %} {% endif %}
{% set time = states(sensor_time) %}
{% set day = now().day %}
{% set marker_bar_pos, clock_pos = 0, 2 %}
{% if marker_bar_position == "bottom" %} {% set marker_bar_pos, clock_pos = 7, 1 %} {% endif %}
{% set current_time = now().strftime('%H:%M:%S') %}
{% set current_time_obj = strptime(current_time, '%H:%M:%S') %}
{% set wake_up_time_obj = strptime(wake_up_time, '%H:%M:%S') %}
{% set sleep_time_obj = strptime(sleep_time, '%H:%M:%S') %}
{% set is_night_mode = (wake_up_time_obj > sleep_time_obj) %}
{% if not is_night_mode %}
{% set is_night_mode = (current_time_obj >= sleep_time_obj) or (current_time_obj < wake_up_time_obj) %}
{% else %}
{% set is_night_mode = (current_time_obj >= sleep_time_obj) and (current_time_obj < wake_up_time_obj) %}
{% endif %}
{% if is_night_mode and night_mode %}
{% set clock_mode = "sleep" %}
{% else %}
{% set clock_mode = "awake" %}
{% endif %}
{% set text_pos = 3 if day < 10 else 1 %}
{% macro draw_marker_bar(marker_bar_pos, marker_color) %}
{% for marker in range(10, 30, 3) %}
{"dl": [{{ marker }}, {{ marker_bar_pos }}, {{ marker + 1 }}, {{ marker_bar_pos }}, {{ marker_color }}]},
{% endfor %}
{% endmacro %}
{% macro draw_weekday_marker(marker_bar_pos, marker_color_current, marker_color_sunday, weekday) %}
{% set gen_weekday_start = 10 + (weekday | int - 1) * 3 %}
{% set gen_weekday_end = gen_weekday_start + 1 %}
{% if now().isoweekday() == 7 %}
{"dl": [{{ gen_weekday_start }}, {{ marker_bar_pos }}, {{ gen_weekday_end }}, {{ marker_bar_pos }}, {{ marker_color_sunday }}]},
{% else %}
{"dl": [{{ gen_weekday_start }}, {{ marker_bar_pos }}, {{ gen_weekday_end }}, {{ marker_bar_pos }}, {{ marker_color_current }}]},
{% endif %}
{% endmacro %}
{% macro draw_calendar_style1(bottom_calendar_color, top_calendar_color) %}
{"df": [0, 2, 9, 7, {{ bottom_calendar_color }}]},
{"df": [0, 0, 9, 2, {{ top_calendar_color }}]},
{% endmacro %}
{% macro draw_calendar_style2(bottom_calendar_color) %}
{"df": [0, 0, 9, 8, {{ bottom_calendar_color }}]},
{"dl": [1, 0, 2, 0, [0, 0, 0]]},
{"dl": [6, 0, 7, 0, [0, 0, 0]]},
{% endmacro %}
{
"draw": [
{% if clock_mode == "awake" %}
{% if marker_bar_position != "never" %}
{{ draw_marker_bar(marker_bar_pos, marker_color) }}
{{ draw_weekday_marker(marker_bar_pos, marker_color_current, marker_color_sunday, weekday) }}
{% endif %}
{% if calendar_style == "style1" %}
{{ draw_calendar_style1(bottom_calendar_color, top_calendar_color) }}
{% elif calendar_style == "style2" %}
{{ draw_calendar_style2(bottom_calendar_color) }}
{% endif %}
{"dt": [{{ text_pos }}, 2, {{ day }}, {{ weekday_color }}]},
{"dt": [12, {{ clock_pos }}, "{{ time }}", {{ time_color }}]}
{% else %}
{"dt": [7, 1, "{{ time }}", {{ sleep_settings_color }}]}
{% endif %}
],
"duration": {{ duration }},
"lifetime": {{ lifetime }}
}
trigger:
- platform: state
entity_id:
- !input time_sensor
id: time_timer
- platform: time
at: !input wake_up_time
id: wakeup_timer
- platform: time
at: !input sleep_time
id: sleep_timer
- platform: event
id: automation_timer
event_type:
- automation_reloaded
condition: []
action:
- repeat:
for_each: "{{ awtrix_devices }}"
sequence:
- choose:
- conditions:
- condition: template
value_template: >
{{ states(repeat.item.entity) not in ['unavailable', 'unknown'] }}
- condition: template
value_template: >
{{ states(sensor_time) not in ['unavailable', 'unknown'] }}
sequence:
- if:
- condition: trigger
id:
- wakeup_timer
- sleep_timer
- time_timer
- automation_timer
then:
- service: mqtt.publish
data:
qos: 0
retain: false
topic: "{{ repeat.item.topic ~ '/custom/' ~ app }}"
payload: "{{ payload }}"
- if:
- condition: trigger
id:
- wakeup_timer
- condition: template
value_template: >
{{ night_mode }}
then:
- service: mqtt.publish
data:
qos: 0
retain: false
topic: "{{ repeat.item.topic ~ '/settings'}}"
payload: "{{ payload_wakeup_settings }}"
- if:
- condition: trigger
id:
- sleep_timer
- condition: template
value_template: >
{{ night_mode }}
then:
- service: mqtt.publish
data:
qos: 0
retain: false
topic: "{{ repeat.item.topic ~ '/settings'}}"
payload: "{{ payload_sleep_settings }}"
- service: mqtt.publish
data:
qos: 0
retain: false
topic: "{{ repeat.item.topic ~ '/switch'}}"
payload: "{{ payload_sleep_switch }}"