Backup automatico script del 2026-07-26 07:00
This commit is contained in:
1 parent
4802b021fe
commit
a9bbb92090
19 files changed
+1086
-550
No files matched your search
@@ -507,6 +507,13 @@ def analyze_freeze(chat_ids: Optional[List[str]] = None, debug_mode: bool = Fals
|
||||
|
||||
msg = "".join(msg_parts)
|
||||
ok = telegram_send_html(msg, chat_ids=chat_ids)
|
||||
web_ok = False
|
||||
try:
|
||||
from webapp_alert import publish_web_alert
|
||||
web_ok = bool(publish_web_alert(msg, "freeze", "warning", is_html=True, state=state,
|
||||
title="Allerta gelo"))
|
||||
except Exception as e:
|
||||
LOGGER.debug("Web summary failed: %s", e)
|
||||
if ok:
|
||||
LOGGER.info("Allerta gelo inviata. Tmin=%.1f°C at %s, nuove fasce: %d",
|
||||
min_temp_val, min_temp_time.isoformat(), len(new_periods))
|
||||
@@ -516,8 +523,15 @@ def analyze_freeze(chat_ids: Optional[List[str]] = None, debug_mode: bool = Fals
|
||||
"start": start.isoformat(),
|
||||
"end": end.isoformat(),
|
||||
})
|
||||
elif web_ok:
|
||||
LOGGER.info("Allerta gelo pubblicata su WebApp. Tmin=%.1f°C", min_temp_val)
|
||||
for start, end in new_periods:
|
||||
notified_periods.append({
|
||||
"start": start.isoformat(),
|
||||
"end": end.isoformat(),
|
||||
})
|
||||
else:
|
||||
LOGGER.warning("Allerta gelo NON inviata (token mancante o errore Telegram).")
|
||||
LOGGER.warning("Allerta gelo NON consegnata (Telegram/WebApp).")
|
||||
|
||||
else:
|
||||
LOGGER.info("Gelo già notificato (nessuna nuova fascia oraria, peggioramento < 2°C). Tmin=%.1f°C", min_temp_val)
|
||||
@@ -528,6 +542,12 @@ def analyze_freeze(chat_ids: Optional[List[str]] = None, debug_mode: bool = Fals
|
||||
"min_time": min_temp_time.isoformat(),
|
||||
"notified_periods": notified_periods,
|
||||
})
|
||||
if not state.get("summary"):
|
||||
state["summary"] = (
|
||||
f"Allerta gelo a {LOCATION_NAME}.\n"
|
||||
f"Minima prevista {min_temp_val:.1f}°C alle {fmt_dt(min_temp_time)} "
|
||||
f"(prossime {HOURS_AHEAD}h)."
|
||||
)
|
||||
save_state(state)
|
||||
return
|
||||
|
||||
|
||||
Reference in new issue
Block a user