Skip to content

Reference

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.

The sheet New widget: the templates of the installed plugins, each with its view kind, its plugin and what it shows.The sheet New widget: the templates of the installed plugins, each with its view kind, its plugin and what it shows.

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:

json
"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 ​

FieldMeaning
ida-z0-9_-, up to 32 characters, unique in the plugin
title, descriptionwhat the picker and the Library show
paramsa form schema: what the person chooses when adding it
sourcetool: one of the plugin's own tools, which must be readOnly; args, where {{param.<name>}} inserts a parameter
refreshinterval (every, at least 1m, optional window with from, to, days), push, or before (lead, every)
mapthe values the view reads out of the tool's answer
viewhow 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
runsbackground (the default) or watched
demoa sample answer; the Library draws previews from it

Views ​

KindFields
statvalue, unit, label, caption, noTrend, glyph, ambient
listitems, title, subtitle, trailing, badge, max
countdownat, label, caption, glyph, ambient
statusstate, states, otherwise, label, detail, glyph, ambient
chartdata, 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:

json
"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" } } }
AmbientWhat it draws
rainSlanted rain falling
drizzleFine, sparse rain
snowSquare flakes drifting down
stormHeavy rain and two faint flashes of light
sunRays round the cell's top corner
fogBands of mist drifting sideways

Mapping ​

A mapped value is a path into the answer, then filters:

text
$.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: true cannot 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.

nocturn is open source. Example hosts and people on these pages are made up.