-
Notifications
You must be signed in to change notification settings - Fork 0
/
automation-2.9-trivia.yaml
113 lines (113 loc) · 3.76 KB
/
automation-2.9-trivia.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
alias: EPaper Tags - API Ninjas - Trivia
description: "Show a trivia question every hour, with the answer only being revealed after 30 minutes!"
trigger:
- platform: time_pattern
minutes: /30
action:
- service: open_epaper_link.drawcustom
data:
background: white
rotate: 0
payload:
- type: icon
value: message-question
x: 1
"y": 1
size: 32
color: red
- type: text
value: >-
{% set topic_object = {
"artliterature": "Art & Literature",
"language": "Language",
"sciencenature": "Science & Nature",
"general": "General Knowledge",
"fooddrink": "Food & Drink",
"peopleplaces": "People & Places",
"geography": "Geography",
"historyholidays": "History & Holidays",
"entertainment": "Entertainment",
"toysgames": "Toys & Games",
"music": "Music",
"mathematics": "Mathematics",
"religionmythology": "Religion & Mythology",
"sportsleisure": "Sports & Leisure",
"question": "Question",
"": "Trivia"
} %} {% set topic_key =
state_attr('sensor.api_ninja_trivia','category') | string |
default("question") %} {{topic_object[topic_key]}}
font: ../../media/GothamRnd-Bold.ttf
x: 35
"y": >-
{% set cat_len = state_attr('sensor.api_ninja_trivia','question') |
length | int %} {{ 1 if cat_len < 16 else 7 | int }}
size: >-
{% set cat_len = state_attr('sensor.api_ninja_trivia','question') |
length | int %} {{ 30 if cat_len < 16 else 23 | int }}
color: red
anchor: lt
y_padding: 0
spacing: 2
- type: text
value: "{{state_attr('sensor.api_ninja_trivia','question') | string }}"
font: ../../media/GothamRnd-Bold.ttf
x: 15
"y": 38
size: >-
{% set string_len = state_attr('sensor.api_ninja_trivia','question')
| length | int %} {% if string_len <= 50 %}
22
{% elif string_len <= 60 %}
18
{% elif string_len <= 100 %}
16
{% elif string_len <= 150 %}
12
{% elif string_len <= 200 %}
10
{% else %}
8
{% endif %}
color: black
anchor: lt
max_width: 266
y_padding: 0
spacing: 2
- type: text
value: |-
{% if now().minute < 30 %}
...???
{% else %}
{{state_attr('sensor.api_ninja_trivia','answer') | string }}
{% endif %}
font: ../../media/GothamRnd-Bold.ttf
x: 5
size: |-
{% if now().minute < 30 %}
28
{% else %}
{% set string_len = state_attr('sensor.api_ninja_trivia','answer') | length | int %}
{% if string_len <= 20 %}
28
{% elif string_len <= 50 %}
20
{% elif string_len <= 60 %}
18
{% elif string_len <= 100 %}
16
{% elif string_len <= 150 %}
12
{% else %}
8
{% endif %}
{% endif %}
color: red
anchor: lt
max_width: 291
y_padding: 8
spacing: 2
target:
entity_id:
- open_epaper_link.000002123456ABC
mode: restart