From 6802f647b3de62c98729291e7cf9306d29e5d1d6 Mon Sep 17 00:00:00 2001 From: "2569718930@qq.com" <2569718930@qq.com> Date: Wed, 13 May 2026 15:04:54 +0800 Subject: [PATCH] =?UTF-8?q?Busan=20=E9=AB=98=E6=B8=A9=E7=AA=97=E5=8F=A3=20?= =?UTF-8?q?fallback=EF=BC=9Apeak=20=E5=81=8F=E7=AA=84=EF=BC=8813-14?= =?UTF-8?q?=EF=BC=89=E6=97=B6=E6=8B=93=E5=AE=BD=E5=88=B0=2012-16?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 沿海城市受海风影响,Open-Meteo 算出的 peak 窗口仅 1 小时, 导致 time_ok 在 16:01 就关窗。加 _AIRPORT_PEAK_FALLBACK, last_h - first_h < 3 时用 fallback 值。 Constraint: 仅影响 Busan,其他城市无 fallback 保持原逻辑 --- src/utils/telegram_push.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/utils/telegram_push.py b/src/utils/telegram_push.py index 196e3a0d..bcd8d2d0 100644 --- a/src/utils/telegram_push.py +++ b/src/utils/telegram_push.py @@ -852,11 +852,20 @@ _AIRPORT_HEAT_THRESHOLD = { } -def _in_peak_time_window(city_weather: Dict[str, Any]) -> bool: +# 部分城市 Open-Meteo 算出的 peak 窗口偏窄,用 fallback 拓宽 +# (例如沿海城市受海风影响,高温窗口被压缩) +_AIRPORT_PEAK_FALLBACK = { + "busan": (12, 16), +} + +def _in_peak_time_window(city: str, city_weather: Dict[str, Any]) -> bool: """Check if current local time is within the expected peak temperature window.""" peak = city_weather.get("peak") or {} first_h = peak.get("first_h") last_h = peak.get("last_h") + fallback = _AIRPORT_PEAK_FALLBACK.get(city) + if fallback and ((first_h is None) or (last_h is not None and last_h - first_h < 3)): + first_h, last_h = fallback local_time = city_weather.get("local_time") or "" if first_h is None or not local_time: return False @@ -964,7 +973,7 @@ def _run_high_freq_airport_cycle( # ── Three-condition heat window ── threshold = _AIRPORT_HEAT_THRESHOLD.get(city, 3.0) - time_ok = _in_peak_time_window(city_weather) + time_ok = _in_peak_time_window(city, city_weather) temp_ok = (deb_pred - current_temp) <= threshold trend_ok = _check_rising_trend(airport_icao) if city != "paris" else True