-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy path7.5-date-weather.yaml
More file actions
193 lines (188 loc) · 5.79 KB
/
7.5-date-weather.yaml
File metadata and controls
193 lines (188 loc) · 5.79 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
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
alias: 7.5 종합
description: ""
triggers:
- trigger: time_pattern
hours: /1
conditions: []
actions:
- action: calendar.get_events
target:
entity_id:
- calendar.google
- calendar.holidays
data:
duration:
hours: 24
response_variable: response
- variables:
font_bold: fonts/GmarketSansTTFBold.ttf
font_med: fonts/GmarketSansTTFMedium.ttf
month_str: "{{ now().strftime('%-m') }}월"
day_num: "{{ now().strftime('%d') }}"
weekday_kr: >
{% set days =
{'Monday':'월요일','Tuesday':'화요일','Wednesday':'수요일','Thursday':'목요일','Friday':'금요일','Saturday':'토요일','Sunday':'일요일'}
%} {{ days[now().strftime('%A')] }}
today_data: >
{% set current_date = now().strftime('%Y-%m-%d') %} {% set ns =
namespace(is_holiday=false, summary='일정 없음', start=none,
holiday_name=none) %}
{# 1. 주말 체크 #} {% if now().strftime('%w') in ['0', '6'] %}
{% set ns.is_holiday = true %}
{% endif %}
{# 2. 공휴일 캘린더 확인 #} {% set holidays =
response['calendar.holidays']['events'] %} {% for h in holidays %}
{% if h.start is string and h.start.startswith(current_date) %}
{% set ns.is_holiday = true %}
{% set ns.holiday_name = h.summary %} {# 공휴일 이름 저장 #}
{% endif %}
{% endfor %}
{# 3. 개인 일정 확인 #} {% set personal =
response['calendar.google']['events'] | sort(attribute='start') %} {%
for e in personal %}
{% if e.start is string and e.start.startswith(current_date) %}
{% set ns.summary = e.summary %}
{% set ns.start = e.start %}
{% break %}
{% endif %}
{% endfor %}
{# 4. 공휴일 이름 처리 (일정이 없을 때 하단 일정에 표시) #} {% if ns.summary == '일정 없음' and
ns.holiday_name is not none %}
{% set ns.summary = ns.holiday_name %}
{% endif %}
{{ {
'summary': ns.summary,
'start': ns.start,
'is_holiday': ns.is_holiday
} }}
weather_state: "{{ states('weather.tongbogdong') }}"
temp_cur: "{{ states('sensor.hyeonjaeondo') }}"
temp_min: "{{ states('sensor.coejeoondo') }}"
temp_max: "{{ states('sensor.coegoondo') }}"
rain_amount: "{{ states('sensor.sigandanggangsuryang') | float(0) }}"
rain_start: "{{ states('sensor.bisijagsiganoneul') }}"
weather_text: |
{% if rain_amount > 0 %}
비 {{ rain_amount }}mm
{% elif rain_start not in ['비안옴', 'unknown', 'unavailable'] %}
{{ rain_start }} 비 예보
{% else %}
비안옴
{% endif %}
color_num: white
color_point: |
{{ 'red' if today_data.is_holiday else 'white' }}
color_event: |
{{ 'red' if today_data.is_holiday else 'black' }}
color_rain: >
{{ 'red' if (rain_amount > 0) or (rain_start not in ['비안옴', 'unknown',
'unavailable']) else 'black' }}
- action: gicisky.write
data:
rotate: 270
target:
entity_id: esphome.gicisky_display_75
payload:
- type: rectangle
x_start: 0
y_start: 0
x_end: 480
y_end: 800
fill: white
outline: white
- type: rectangle
x_start: 0
y_start: 0
x_end: 480
y_end: 320
fill: black
outline: black
- type: text
value: "{{ month_str }}"
x: 30
"y": 30
font: "{{ font_med }}"
size: 40
color: white
anchor: lt
- type: text
value: "{{ day_num }}"
x: 240
"y": 160
font: "{{ font_bold }}"
size: 200
color: "{{ color_num }}"
anchor: mm
- type: text
value: "{{ weekday_kr }}"
x: 240
"y": 270
font: "{{ font_med }}"
size: 50
color: "{{ color_point }}"
anchor: mm
- type: icon
value: weather-{{ weather_state }}
x: 120
"y": 430
size: 140
color: black
anchor: mm
- type: text
value: "{{ temp_cur }}°"
x: 360
"y": 410
font: "{{ font_bold }}"
size: 90
color: black
anchor: mm
- type: text
value: "{{ temp_min }}° / {{ temp_max }}°"
x: 360
"y": 470
font: "{{ font_med }}"
size: 35
color: black
anchor: mm
- type: text
value: "{{ weather_text }}"
x: 240
"y": 530
font: "{{ font_bold }}"
size: 40
color: "{{ color_rain }}"
anchor: mm
- type: line
x_start: 40
x_end: 440
y_start: 570
y_end: 570
width: 3
fill: black
- type: text
value: "{{ today_data.summary | truncate(10, true, '..') }}"
x: 240
"y": 650
font: "{{ font_bold }}"
size: 60
color: "{{ color_event }}"
anchor: mm
- type: text
value: |
{% if today_data.start and 'T' in today_data.start %}
{{ as_timestamp(today_data.start) | timestamp_custom('%H:%M') }}
{% elif today_data.summary == '일정 없음' %}
-
{% else %}
종일
{% endif %}
x: 240
"y": 730
font: "{{ font_med }}"
size: 40
color: "{{ color_event }}"
anchor: mm
target:
device_id: 2766ccde02539d2b8cfe034556aa95ae
enabled: true
mode: single