Widget templates
A widget template is a widget a plugin ships for Home: one read-only call of the plugin's own tool, a refresh rule, and a way to draw the answer. A person picks it under New widget, fills in its parameters, and accepts what it will call.


Templates live in a plugin's plugin.json, beside tools. This one, from the open-meteo plugin in the repository's catalog, shows the temperature at a place with a sky glyph:
"widgets": [
{
"id": "now",
"title": "Temperature now",
"description": "The temperature at a place now, and what the sky is doing.",
"params": {
"type": "object",
"properties": { "place": { "type": "string", "title": "Place", "default": "home", "maxLength": 64 } }
},
"source": { "tool": "forecast", "args": { "place": "{{param.place}}", "span": "hours" } },
"refresh": { "interval": { "every": "30m" } },
"places": ["chat", "pinned"],
"map": {
"temp": "$.now.temp | number:1",
"text": "$.now.text",
"sky": { "lookup": ["$.now.code", "$.now.day"], "table": { "0, 1": "clear", "3": "cloudy", "61, 63, 65": "rain" } }
},
"view": { "stat": { "value": "temp", "unit": "°C", "caption": "text", "glyph": { "from": "sky" } } },
"controls": [{ "picker": { "param": "place", "places": true } }],
"demo": { "place": "home", "now": { "temp": 7.4, "code": 61, "day": 1, "text": "Light rain" } }
}
]Fields
| Field | Meaning |
|---|---|
id | a-z0-9_-, up to 32 characters, unique in the plugin |
title, description | what the picker and the Library show |
params | a form schema: what the person chooses when adding it |
source | tool: one of the plugin's own tools, which must be readOnly; args, where {{param.<name>}} inserts a parameter |
refresh | interval (every, at least 1m, optional window with from, to, days), push, or before (lead, every) |
map | the values the view reads out of the tool's answer |
view | how it is drawn: one of the kinds below |
controls[] | up to six: segment, picker, drill, action |
places[] | where it may stand: pinned (Home, the default), chat, item |
runs | background (the default) or watched |
demo | a sample answer; the Library draws previews from it |
Views
| Kind | Fields |
|---|---|
stat | value, unit, label, caption, noTrend, glyph, ambient |
list | items, title, subtitle, trailing, badge, max |
countdown | at, label, caption, glyph, ambient |
status | state, states, otherwise, label, detail, glyph, ambient |
chart | data, spec (Vega-Lite), title |
A glyph is the name of a Lucide icon, such as cloud-rain; a name that is not Lucide's is refused when the template is read. An ambient moves behind the figure. Either is fixed, or { "from": "<mapped value>" }: a lookup whose every word is valid, as the weather template's sky:
"map": {
"sky": {
"lookup": ["$.now.code", "$.now.day"],
"table": {
"0/0, 1/0": "moon", "0, 1": "sun", "2/0": "cloud-moon", "2": "cloud-sun", "3": "cloud",
"45, 48": "cloud-fog", "51, 53, 55, 56, 57": "cloud-drizzle",
"61, 63, 65, 66, 67, 80, 81, 82": "cloud-rain", "71, 73, 75, 77, 85, 86": "snowflake",
"95, 96, 99": "cloud-lightning"
}
}
},
"view": { "stat": { "value": "temp", "caption": "text", "glyph": { "from": "sky" } } }| Ambient | What it draws |
|---|---|
rain | Slanted rain falling |
drizzle | Fine, sparse rain |
snow | Square flakes drifting down |
storm | Heavy rain and two faint flashes of light |
sun | Rays round the cell's top corner |
fog | Bands of mist drifting sideways |
Mapping
A mapped value is a path into the answer, then filters:
$.now.temp | number:1
$.stations[*].price | min
$.departures[0].when | time$ is the answer, @ the current element; steps are .name, [i], [*] and ["name"]. Filters: number, int, text, upper, lower, trim, truncate, default, time, date, iso, minutes, hours, count, first, last, sum, min, max, avg, join.
Besides a string, a value can be { "each": …, "fields": …, "max": … } for a list, or { "lookup": …, "table": …, "otherwise": … } to turn codes into words, such as glyph names.
Rules
- The source only reads. A tool without
readOnly: truecannot feed a widget. - A parameter that reaches a target has fixed values. A free text that becomes a host or a path is refused: give it an
enum, a control's options, or the household's places, so the owner sees every value the widget may ask for. - Accepted once. Installing a plugin accepts its templates' requests; a widget made from one asks nothing more. The plugin's page shows each as accepted or waiting.
A template that does not hold up is skipped, and nocturn ls -w <workspace> names it with the reason.