Perch
Lua APIperch.weather

perch.weather

The folded met.no forecast model — current conditions plus a seven-day strip, ready to bind.

2 min readUpdated Jul 21, 2026

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

FieldTypeMeaning
citystringresolved place name
tempstringcurrent temperature, already in the user’s unit
condstringcondition text (“Partly cloudy”)
iconstringa symbol key for your icon set
hi / lostringtoday’s range
weekarrayseven rolling days from today

Each week entry:

FieldMeaning
dweekday short name
isymbol key
trepresentative temp (the day’s high)
todayflag 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.

esc
Type to search
navigate open