Weather is a native pipeline (met.no fetch, symbol folding, unit
handling) exposed as a finished model — you get the answer, not the API.
Scope: weather. No location scope needed: the provider resolves coarse
location itself and never hands coordinates to packages.
The model
| Field | Type | Meaning |
|---|---|---|
city | string | resolved place name |
temp | string | current temperature, already in the user’s unit |
cond | string | condition text (“Partly cloudy”) |
icon | string | a symbol key for your icon set |
hi / lo | string | today’s range |
week | array | seven rolling days from today |
Each week entry:
| Field | Meaning |
|---|---|
d | weekday short name |
i | symbol key |
t | representative temp (the day’s high) |
today | flag for the boxed cell |
on_weather(host, w) — the stream
function M.on_weather(host, w)
host.set_presence("weather", w.city ~= nil and w.city ~= "", w)
end
Fires after each fetch cycle and on unit changes (re-emitted from cache,
no refetch). The model is bind-ready — the builtin weather card binds it
almost verbatim, with the week strip as a list and icon picking from
a shape set.
perch.weather.read()
local w = perch.weather.read() -- {} until the first fetch lands
Pull the last model — seed your on_start so a widget placed mid-session
renders immediately. An empty table means no fetch has landed yet: show
your waiting state, never a hole.
perch.weather.set_config(tbl)
function M.on_configure(host, s)
perch.weather.set_config({ unit = s.unit }) -- "celsius" | "fahrenheit"
end
Forwards unit (and notch-related) preferences to the provider. Unit changes live-apply — the provider re-emits the folded model in the new unit instantly.