nws: replace NWSheadline with structured line 2 — Until {time} {tz} — {area}

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 <noreply@anthropic.com>
This commit is contained in:
Matt Johnson (via Claude) 2026-06-08 14:23:18 +00:00
commit fa8d89c9cd

View file

@ -32,6 +32,7 @@ from meshai.adapter_config import adapter_config
import logging import logging
import re import re
import time import time
import zoneinfo
from datetime import datetime, timezone from datetime import datetime, timezone
from typing import Any, Optional 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) # Line 1: emoji + event type (no office)
line1 = f"{emoji} {prefix_seg}{event_type or 'Weather Alert'}" line1 = f"{emoji} {prefix_seg}{event_type or 'Weather Alert'}"
# Line 2: NWSheadline (raw, truncated to 80 bytes at word boundary) or fallback # Line 2: "Until {time} {tz} — {area}"
nws_hl = (params.get("NWSheadline") or [""])[0].strip() tz = zoneinfo.ZoneInfo("America/Boise")
if nws_hl: if expires_epoch:
if len(nws_hl.encode("utf-8")) > 80: exp_local = datetime.fromtimestamp(expires_epoch, tz=tz)
while len(nws_hl.encode("utf-8")) > 80: exp_str = exp_local.strftime("%-I:%M %p %Z")
nws_hl = nws_hl.rsplit(" ", 1)[0] time_seg = f"Until {exp_str}"
line2 = nws_hl
else: else:
area_first = (area_desc or "").split(";")[0].strip() time_seg = ""
line2 = f"{event_type or 'Weather Alert'} for {area_first}" if area_first else "" 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) # Line 3: hazard + certainty/threat (SAME-code branched)
certainty = (d.get("certainty") or "").strip() certainty = (d.get("certainty") or "").strip()