From fa8d89c9cd3973cb77d602403e822072bfc49777 Mon Sep 17 00:00:00 2001 From: "Matt Johnson (via Claude)" Date: Mon, 8 Jun 2026 14:23:18 +0000 Subject: [PATCH] =?UTF-8?q?nws:=20replace=20NWSheadline=20with=20structure?= =?UTF-8?q?d=20line=202=20=E2=80=94=20Until=20{time}=20{tz}=20=E2=80=94=20?= =?UTF-8?q?{area}?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Drop NWSheadline entirely. Build line 2 from expires_epoch (formatted to local America/Boise time with timezone abbrev) and first areaDesc segment (truncated to 50 chars at word boundary). Co-Authored-By: Claude Opus 4.6 --- meshai/central/nws_handler.py | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/meshai/central/nws_handler.py b/meshai/central/nws_handler.py index e064f6b..e541327 100644 --- a/meshai/central/nws_handler.py +++ b/meshai/central/nws_handler.py @@ -32,6 +32,7 @@ from meshai.adapter_config import adapter_config import logging import re import time +import zoneinfo from datetime import datetime, timezone from typing import Any, Optional @@ -314,16 +315,25 @@ def _render(*, event_type, area_desc, geocoder_city, county, state, # Line 1: emoji + event type (no office) line1 = f"{emoji} {prefix_seg}{event_type or 'Weather Alert'}" - # Line 2: NWSheadline (raw, truncated to 80 bytes at word boundary) or fallback - nws_hl = (params.get("NWSheadline") or [""])[0].strip() - if nws_hl: - if len(nws_hl.encode("utf-8")) > 80: - while len(nws_hl.encode("utf-8")) > 80: - nws_hl = nws_hl.rsplit(" ", 1)[0] - line2 = nws_hl + # Line 2: "Until {time} {tz} — {area}" + tz = zoneinfo.ZoneInfo("America/Boise") + if expires_epoch: + exp_local = datetime.fromtimestamp(expires_epoch, tz=tz) + exp_str = exp_local.strftime("%-I:%M %p %Z") + time_seg = f"Until {exp_str}" else: - area_first = (area_desc or "").split(";")[0].strip() - line2 = f"{event_type or 'Weather Alert'} for {area_first}" if area_first else "" + time_seg = "" + area = (area_desc or "").split(";")[0].strip() + if len(area) > 50: + area = area[:50].rsplit(" ", 1)[0] + if time_seg and area: + line2 = f"{time_seg} — {area}" + elif time_seg: + line2 = time_seg + elif area: + line2 = area + else: + line2 = "" # Line 3: hazard + certainty/threat (SAME-code branched) certainty = (d.get("certainty") or "").strip()