Aggiorna script backup e bot meteo Telegram.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
3a7b867e83
commit
beb790ed7e
6 files changed
+350
-102
No files matched your search
@@ -17,6 +17,7 @@ from open_meteo_precip import (
|
||||
CASA_TZ,
|
||||
daily_precip_from_hourly,
|
||||
hourly_precip_mm,
|
||||
hourly_table_should_show,
|
||||
is_casa,
|
||||
)
|
||||
|
||||
@@ -499,16 +500,15 @@ def generate_weather_report(lat, lon, location_name, debug_mode=False, cc="IT",
|
||||
day_date = dt.date()
|
||||
is_new_day = (current_day is not None and day_date != current_day)
|
||||
|
||||
# Determina se mostrare questo timestamp in base alla posizione nelle 48h
|
||||
# Prime 24h: ogni ora (step=1)
|
||||
# Dalla 25a alla 48a: ogni 2 ore (step=2)
|
||||
if hours_from_start < 24:
|
||||
step = 1 # Prime 24h: dettaglio 1 ora
|
||||
else:
|
||||
step = 2 # Dalla 25a alla 48a: dettaglio 2 ore
|
||||
|
||||
# Controlla se questo timestamp deve essere mostrato
|
||||
should_show = (hours_from_start % step == 0)
|
||||
# Prime 24h: ogni ora. Dalla 25a alla 48a: ogni 2 ore, ma mai nascondere
|
||||
# un'ora con precipitazione (altrimenti il picco cade sulle ore dispari
|
||||
# e la tabella 48h mostra 5 mm mentre Meteo7 ha 22.4 mm sul giorno).
|
||||
Pr_early = get_val(l_prec[idx], 0)
|
||||
Rain_early = get_val(l_rain[idx], 0)
|
||||
Showers_early = get_val(l_showers[idx], 0) if idx < len(l_showers) else 0
|
||||
Code_early = int(get_val(l_code[idx], 0))
|
||||
Pr_display = hourly_precip_mm(Pr_early, Rain_early, Showers_early)
|
||||
should_show = hourly_table_should_show(hours_from_start, Pr_display, Code_early)
|
||||
|
||||
# Se è un nuovo giorno, chiudi il blocco precedente
|
||||
if is_new_day and current_block_lines:
|
||||
@@ -541,12 +541,11 @@ def generate_weather_report(lat, lon, location_name, debug_mode=False, cc="IT",
|
||||
elif diff >= 2.5: t_suffix = "H"
|
||||
t_s = f"{int(round(T))}{t_suffix}"
|
||||
|
||||
Pr = get_val(l_prec[idx], 0)
|
||||
Pr = Pr_early
|
||||
Sn = get_val(l_snow[idx], 0)
|
||||
Code = int(get_val(l_code[idx], 0))
|
||||
Rain = get_val(l_rain[idx], 0)
|
||||
Showers = get_val(l_showers[idx], 0) if idx < len(l_showers) else 0
|
||||
Pr_display = hourly_precip_mm(Pr, Rain, Showers)
|
||||
Code = Code_early
|
||||
Rain = Rain_early
|
||||
Showers = Showers_early
|
||||
|
||||
# Determina se è neve
|
||||
is_snowing = Sn > 0 or (Code in [71, 73, 75, 77, 85, 86])
|
||||
@@ -676,7 +675,7 @@ def generate_weather_report(lat, lon, location_name, debug_mode=False, cc="IT",
|
||||
|
||||
legend = {
|
||||
"temp": "W=wind chill, H=heat index",
|
||||
"precip": "G=grandine, Z=ghiacciato, N=neve",
|
||||
"precip": "G=grandine, Z=ghiacciato, N=neve. Dalla 25ª ora: secco ogni 2h, pioggia sempre visibile",
|
||||
"cloud": "FOG=nebbia",
|
||||
"sky": "Icona condizioni (☀️🌧️⛈️…)",
|
||||
"sx": "☃️ neve · 🧊 ghiaccio · ⚡/🌪️ temporali · 🥵 caldo · ☔️ pioggia · 💨 vento forte",
|
||||
|
||||
Reference in new issue
Block a user