-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathai_creat_image_weather_2.yaml
More file actions
327 lines (303 loc) · 13.1 KB
/
Copy pathai_creat_image_weather_2.yaml
File metadata and controls
327 lines (303 loc) · 13.1 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
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
blueprint:
name: Tạo ảnh thời tiết (NVIDIA Flux - PyScript)
author: TriTue2011
source_url: https://raw.githubusercontent.com/TriTue2011/Blueprint/main/ai_creat_image_weather_2.yaml
description: '# Tạo ảnh thời tiết tự động với NVIDIA Flux qua PyScript
✨ Tính năng:
- Prompt tối ưu ~750 ký tự, thay đổi phong cảnh theo buổi
- Lighting được đặt ĐẦU prompt để model ưu tiên đúng thời điểm ngày/đêm
- Không cần shell_command, API key quản lý qua secrets.yaml
- Hỗ trợ đầy đủ sensors thời tiết và chất lượng không khí
⏰ TRIGGER: Kích hoạt khi pha thời gian trong ngày thay đổi
🔧 FIX: Ảnh không còn bị sai thời gian (ngày/đêm nhầm lẫn)
'
domain: automation
homeassistant:
min_version: 2025.10.0
input:
weather_sensors:
name: "\U0001F324️ Cảm biến thời tiết"
icon: mdi:weather-partly-cloudy
collapsed: false
input:
time_phase_sensor:
name: Pha thời gian trong ngày
description: Sensor buổi trong ngày (Sáng / Trưa / Chiều / Tối / Đêm)
selector:
entity:
filter:
- domain:
- sensor
multiple: false
reorder: false
weather_entity:
name: Thực thể thời tiết
selector:
entity:
filter:
- domain:
- weather
multiple: false
reorder: false
temperature_sensor:
name: Cảm biến nhiệt độ (tuỳ chọn)
default: ''
selector:
entity:
filter:
- domain:
- sensor
device_class:
- temperature
multiple: false
reorder: false
humidity_sensor:
name: Cảm biến độ ẩm (tuỳ chọn)
default: ''
selector:
entity:
filter:
- domain:
- sensor
device_class:
- humidity
multiple: false
reorder: false
wind_speed_sensor:
name: Cảm biến tốc độ gió (tuỳ chọn)
default: ''
selector:
entity:
filter:
- domain:
- sensor
multiple: false
reorder: false
air_quality_sensors:
name: "\U0001F3ED Chất lượng không khí"
icon: mdi:air-filter
collapsed: true
input:
aqi_sensor:
name: AQI (tuỳ chọn)
default: ''
selector:
entity:
filter:
- domain:
- sensor
device_class:
- aqi
multiple: false
reorder: false
pm25_sensor:
name: PM2.5 (tuỳ chọn)
default: ''
selector:
entity:
filter:
- domain:
- sensor
multiple: false
reorder: false
output_settings:
name: "\U0001F4BE Cài đặt lưu ảnh"
icon: mdi:content-save
collapsed: false
input:
output_path:
name: Đường dẫn lưu ảnh
default: /config/media/weather/weather_current.png
selector:
text:
multiline: false
multiple: false
steps:
name: Số bước sinh ảnh
description: Cao hơn = chất lượng tốt hơn, chậm hơn (khuyến nghị 6–8, tối thiểu 6 để đảm bảo đúng thời gian)
default: 6
selector:
number:
min: 1.0
max: 20.0
step: 1.0
mode: slider
width:
name: Chiều rộng (px)
default: 1344
selector:
number:
min: 512.0
max: 1920.0
step: 64.0
mode: slider
height:
name: Chiều cao (px)
default: 768
selector:
number:
min: 256.0
max: 1080.0
step: 64.0
mode: slider
trigger:
- platform: state
entity_id: !input time_phase_sensor
condition: []
action:
- variables:
time_phase_sensor: !input time_phase_sensor
weather_entity: !input weather_entity
temperature_sensor: !input temperature_sensor
humidity_sensor: !input humidity_sensor
wind_speed_sensor: !input wind_speed_sensor
aqi_sensor: !input aqi_sensor
pm25_sensor: !input pm25_sensor
tp: '{{ states(time_phase_sensor) | lower }}'
w: '{{ states(weather_entity) | lower }}'
temp: >-
{% if temperature_sensor != '' and states(temperature_sensor) not in ['unknown','unavailable',''] %}
{{ states(temperature_sensor) | float(30) }}
{% else %}
{{ state_attr(weather_entity, 'temperature') | float(30) }}
{% endif %}
hum: >-
{% if humidity_sensor != '' and states(humidity_sensor) not in ['unknown','unavailable',''] %}
{{ states(humidity_sensor) | int(70) }}
{% else %}
{{ state_attr(weather_entity, 'humidity') | int(70) }}
{% endif %}
wind: >-
{% if wind_speed_sensor != '' and states(wind_speed_sensor) not in ['unknown','unavailable',''] %}
{{ states(wind_speed_sensor) | float(5) }}
{% else %}
{{ state_attr(weather_entity, 'wind_speed') | float(5) }}
{% endif %}
aqi: >-
{% if aqi_sensor != '' and states(aqi_sensor) not in ['unknown','unavailable',''] %}
{{ states(aqi_sensor) | int(0) }}
{% else %}0{% endif %}
pm25: >-
{% if pm25_sensor != '' and states(pm25_sensor) not in ['unknown','unavailable',''] %}
{{ states(pm25_sensor) | float(0) }}
{% else %}0{% endif %}
- variables:
# ── LIGHTING: đặt ĐẦU TIÊN để model ưu tiên đúng thời gian ──────────────
lighting: >-
{% if 'sáng' in tp or 'morning' in tp %}
golden-hour sunrise, warm pink-orange sky, long soft morning shadows, dew on grass, bright daylight beginning
{% elif 'trưa' in tp or 'noon' in tp %}
harsh bright overhead noon sun, deep blue sky, vivid colours, short shadows, full daylight
{% elif 'chiều' in tp or 'afternoon' in tp %}
warm amber sunset light, long golden shadows, glowing orange horizon, late afternoon daylight
{% elif 'tối' in tp or 'evening' in tp %}
blue-hour twilight, NO daylight, dark sky gradient deep orange fading to indigo, first stars appearing, village lights and lanterns glowing, night atmosphere beginning
{% else %}
deep night scene, NO sun, NO daylight, full darkness, bright moonlight casting silver shadows, glowing lanterns, Milky Way overhead, stars filling sky
{% endif %}
# ── SCENE: phong cảnh theo buổi ─────────────────────────────────────────
scene: >-
{% if 'sáng' in tp or 'morning' in tp %}
Vietnam countryside, lush green rice paddy terraces, bamboo groves, wooden farmhouses, morning mist over fields, roosters crowing, farmers walking dirt paths
{% elif 'trưa' in tp or 'noon' in tp %}
Vietnam coastal fishing village, turquoise emerald sea, colorful wooden boats docked, white sand beach, palm trees swaying, fishermen sorting nets
{% elif 'chiều' in tp or 'afternoon' in tp %}
Vietnam old town street, yellowed colonial French buildings, narrow lantern-lined alley, motorbikes weaving, bougainvillea flowers on walls, street food vendors
{% elif 'tối' in tp or 'evening' in tp %}
Vietnam Sapa mountain valley at dusk, terraced rice fields reflecting twilight sky, ethnic minority hilltribe village with glowing lit windows, wooden stilt houses, pine trees on ridgeline, dark evening atmosphere
{% else %}
Vietnam remote mountain village at night, ancient stone houses, swirling fog between peaks, glowing orange lanterns, dirt road, wild forest surrounding, no daylight
{% endif %}
# ── WEATHER FX ──────────────────────────────────────────────────────────
weather_fx: >-
{% if 'rain' in w or 'mưa' in w %}
heavy rain falling, wet reflective ground, puddles everywhere, water droplets on leaves, grey overcast sky
{% elif 'thunder' in w or 'bão' in w %}
violent thunderstorm, dramatic dark cumulonimbus clouds, distant lightning strike, powerful wind gusts
{% elif 'cloud' in w or 'mây' in w %}
thick overcast clouds, diffused soft light, flat even lighting, no harsh shadows
{% elif 'fog' in w or 'sương' in w %}
dense rolling fog, misty dreamy atmosphere, very low visibility, soft ethereal mood
{% elif 'clear' in w or 'nắng' in w or 'sunny' in w %}
clear sky, vivid saturated colours, sharp defined shadows
{% elif 'snow' in w %}
light snowfall, white snow-covered ground, frosted tree branches, cold breath visible in air
{% else %}
partly cloudy, scattered white cumulus clouds, pleasant natural light
{% endif %}
# ── TEMPERATURE FX ──────────────────────────────────────────────────────
temp_fx: >-
{% if temp > 35 %}
scorching heat {{ temp | round }}°C, heat shimmer rising from ground, wilting leaves
{% elif temp > 30 %}
hot {{ temp | round }}°C, summer haze, people seeking shade
{% elif temp > 25 %}
warm {{ temp | round }}°C, comfortable outdoor weather, lush green vegetation
{% elif temp > 18 %}
cool {{ temp | round }}°C, refreshing fresh crisp air feeling
{% else %}
cold {{ temp | round }}°C, people wearing jackets, frost on surfaces, breath visible
{% endif %}
# ── WIND FX ─────────────────────────────────────────────────────────────
wind_fx: >-
{% if wind > 30 %}
powerful gale wind, trees bending violently, debris flying, rippling turbulent water
{% elif wind > 15 %}
moderate wind, leaves and branches swaying rhythmically, rippled puddle surfaces
{% elif wind > 5 %}
gentle breeze, soft subtle movement of grass tips and leaves
{% else %}
perfectly calm still air, glassy mirror-like water reflections
{% endif %}
# ── HUMIDITY FX ─────────────────────────────────────────────────────────
hum_fx: >-
{% if hum > 85 %}
oppressively humid {{ hum }}%, heavy tropical haze, damp glistening surfaces, condensation visible
{% elif hum > 60 %}
moderately humid {{ hum }}%, lush vegetation glistening with moisture
{% elif hum < 30 %}
very dry crisp air {{ hum }}%, dust particles floating, cracked dry earth
{% else %}
{% endif %}
# ── AQI FX ──────────────────────────────────────────────────────────────
aqi_fx: >-
{% if aqi > 150 %}
heavy toxic smog AQI {{ aqi }}, thick orange-brown haze, very poor visibility, sun barely a disc
{% elif aqi > 100 %}
significant hazy air AQI {{ aqi }}, washed-out distant objects, greyish sky tint
{% elif aqi > 50 %}
slight haze on horizon AQI {{ aqi }}, mildly muted distant colours
{% else %}
{% endif %}
# ── ASSEMBLE PROMPT: lighting ĐẦU TIÊN ──────────────────────────────────
_parts: >-
{{ [
lighting | trim,
scene | trim,
weather_fx | trim,
temp_fx | trim,
wind_fx | trim,
hum_fx | trim,
aqi_fx | trim
] | select('ne', '') | list | join(', ') }}
prompt_safe: >-
{{ ('Photorealistic aerial DSLR photograph, ' ~ _parts ~ ', wide-angle panoramic composition, deep depth of field, HDR cinematic colour grade, ultra sharp details, 8K resolution, no text, no watermark, no faces')
| regex_replace('\\s+', ' ')
| trim
| truncate(750, True, '') }}
- action: pyscript.generate_weather_image
data:
prompt: '{{ prompt_safe }}'
output_path: !input output_path
steps: !input steps
width: !input width
height: !input height
- action: system_log.write
data:
level: info
message: >-
[WeatherImage] ✅ {{ tp }} | {{ w }} | {{ temp }}°C | hum={{ hum }}%
| wind={{ wind }} | aqi={{ aqi }} | chars={{ prompt_safe | length }}
| prompt={{ prompt_safe | truncate(120) }}
mode: single
max_exceeded: silent