Buttons

Buttons

Buttons on a card that send a request to the service its source reads, where to put them, and the fields each one takes.

Add actions to a card that has a source, and it gets buttons: pause ad blocking, turn on a light, start a sprinkler zone. Each button sends a request to the same service as the source, signed in the same way, and Legato then refreshes the source to check for the change.

Where a button goes on a card and the fields it takes are below. Buttons that do more have a page each:

A card can also be only its buttons: a text card with a label, no body, and a source with just its ref, no map. The buttons' when conditions still read that source's answer. A machine's Controls card is one:

json
{ "id": "controls", "type": "text", "label": "Controls", "actions_placement": "corner",
  "source": { "ref": "guest" },
  "actions": [{ "label": "Start", "icon": "play.fill", "path": "/api2/json/nodes/pve/qemu/107/status/start",
                "when": { "path": "status.data.status", "equals": "stopped" } }] }

Every button also shows up in Spotlight under its own label: choose it and press Return, and Legato presses it, then opens its page (Settings → General → "Open the page when you press a button from Spotlight" turns that off). This actions field is a card fragment for the Pi-hole source:

A button that changes many things at once, such as one that accepts every suggestion on a list, can stay in the panel with "offer": false: Spotlight, Shortcuts and notifications then never offer it, so it's only pressed where the panel shows what it acts on. Give it "confirm" too, so the panel asks before it runs: offer alone doesn't ask.

A button in a card's corner is its icon alone, its name in a tooltip. When the icon wouldn't say enough, for a change that reaches every device, "show_label": true draws its name beside its icon in a plain bordered button: Pi-hole's Queries page has Block domain, Allow domain and Remove from deny list, each shown only for the query it fits.

Put each button on the card it changes

A card's buttons are drawn inside it, under what it shows. So attach each button to the card whose value it changes, not to a card of its own: Start climate on the cabin temperature, Lock on the doors' status, Water now on the zone it waters. The card then reads as one control: what's true now, and what you can do about it. The Tesla example's Inside card does this:

json
{
  "id": "inside", "type": "stat", "label": "Inside", "unit": "°F",
  "source": { "ref": "tesla", "map": {
    "value": { "path": "climate_state.inside_temp", "scale": 1.8, "offset": 32, "round": 0 },
    "delta": { "path": "climate_state.is_climate_on", "values": { "true": "Climate on", "false": "Climate off" } } } },
  "actions": [
    { "label": "Start climate", "icon": "fan", "method": "POST", "path": "/YOUR_VIN/command/start_climate",
      "when": { "path": "climate_state.is_climate_on", "equals": false } },
    { "label": "Stop climate", "icon": "fan.slash", "method": "POST", "path": "/YOUR_VIN/command/stop_climate",
      "when": { "path": "climate_state.is_climate_on", "equals": true } }
  ]
}

(The full example adds success and error; see the table below.)

  • Show the state the button changes on the same card. Here delta says "Climate off", so after a press the follow-up read turns it to "Climate on" right above the button, and the person sees it worked.

  • Offer only the button that makes sense now. Give opposite actions opposite when conditions, as Start and Stop climate do, so one button shows at a time, in the same place. Mark the one that ends something running "prominent": true, as the Tesla example does for Stop climate: the filled button says "this is on" at a glance.

  • Label with a verb, briefly. "Start climate", "Lock", "Pause 5m": up to 24 characters, with an SF Symbol icon that matches.

  • Keep it to one or two per card. Up to four fit; they sit side by side and stack when the card is too narrow, as a half-width card often is.

  • Or put them in the card's corner. "actions_placement": "corner" on the card puts its buttons at its top right, beside what it shows, instead of in a row under it. Each is drawn as its icon alone, with its label as the tooltip, so the card's own lines keep their room; give each button an icon (one without keeps its label). A button with "confirm": true asks in the corner too ("Reboot?", then ✕ and ✓), and the corner keeps room for that question all along, so asking doesn't move the card's lines. A question with its own message, or a name to type, needs the card's width and asks under the card. The corner suits a short card with a few buttons, such as Start or Stop climate on the cabin temperature, or a server's Start, Shut down and Reboot. On a text card that's only its name and buttons (no body), the corner buttons are drawn at the size of buttons under a card, beside the name. On a list, and on a facts or text card with a label, they sit on the name's line and the rows below keep the card's full width. A card with no name has no such line, so they sit beside its lines, which take the rest of the width: give a facts card a label to keep its values at the right edge. "bottom", under the card, is the default.

  • Or put them in the page's title row. "placement": "title" on a text card of buttons (no body) draws them at the right of the page's large title, as a window's toolbar: each its icon alone, its label in a tooltip, a menu showing its value. An on/off pair that shares a setting, each half with turns, is one icon, lit on a grey plate while it's on. Several such cards sit in one row, a thin line between them. The person arranges the row in Customize Controls (right-click the row, or the end of ⋯): one shelf of what's in the bar, in order, and one of the rest, with controls dragged along or between them. ⋯ always shows, and opens the rest as working rows (switches switch, menus show their value), each with + to put it in the bar. Menus in the row show their icon and value with no pill. Only a sheet page in the window has the large title; elsewhere the card is drawn as an ordinary card. Spotlight and Shortcuts offer every one either way.

  • Or make them settings rows. "actions_placement": "rows" draws each button with a setting as a row named by it, the way System Settings lists them: a menu (choices) shows its value on the row's right, and an on/off pair of buttons sharing one setting, each with "turns": "on" or "off", is a switch. Give the pair whens that never hold together: the one shown says the state, so the switch is on while the button that turns it off is the one offered, and flipping it presses that button, question and all. Buttons with no setting, such as Start charging, sit in the card's corner. Rows suit a Controls card on a sheet, where they read like the facts beside them. Up to 16 buttons.

json
{ "id": "controls", "type": "text", "label": "Controls", "actions_placement": "rows", "source": { "ref": "car" },
  "actions": [
    { "label": "Turn on Sentry", "icon": "eye", "path": "/sentry/on", "setting": "Sentry", "turns": "on", "when": { "path": "sentry_mode", "equals": false } },
    { "label": "Turn off Sentry", "icon": "eye.slash", "path": "/sentry/off", "setting": "Sentry", "turns": "off", "when": { "path": "sentry_mode", "equals": true } } ] }
  • Or offer a menu of values. Give a button choices, each a label and a value, and put {choice} in its path, body or headers: the button becomes a menu, and picking one sends the request with that value, such as a cabin temperature or a charge limit. current names where the source's answer holds the value now; that choice is ticked and titles the menu (70°F ▾). When the answer holds a value no choice has, such as the highest setting while a car defrosts, the menu shows the button's icon instead (its label without one). The labels can say one thing and the values another, such as °F labels for a service that takes °C:
json
{ "label": "Cabin temperature", "path": "/car/command/set_temperatures?temperature={choice}",
  "current": "climate_state.driver_temp_setting",
  "choices": [{ "label": "68°F", "value": 20 }, { "label": "70°F", "value": 21 }, { "label": "72°F", "value": 22 }] }

In a body, a string that is "{choice}" and nothing else takes the choice's value as it is, so a number stays a number. AdGuard Home's pause wants milliseconds as a number and refuses "300000":

json
{ "label": "Pause protection", "icon": "pause", "path": "/control/protection",
  "body": { "enabled": false, "duration": "{choice}" },
  "choices": [{ "label": "1 minute", "value": 60000 }, { "label": "1 hour", "value": 3600000 }] }

Any other body string, such as "for {choice} ms", is filled as text, where a number is grouped (300,000); {choice|raw} gives the digits as sent.

Spotlight and Shortcuts list each choice as its own button, "Cabin temperature: 70°F". A menu can't ask first (confirm).

  • Or make the menu from the answer. When the choices are things the service lists, such as the models an Ollama server has installed, choices can be a list rule instead: each names the array, and fields gives each choice's label and value. Picking one sends the request with that value, as a fixed menu does:

    json
    { "label": "Load a model", "icon": "play.fill", "path": "/api/generate",
      "body": { "model": "{choice}" },
      "choices": { "each": "tags.models", "fields": { "label": "name", "value": "name" } } }

    The menu is read from the source's answer each time it opens: up to 24 choices in the answer's order (a where or sort in the rule changes that), each label cut to 24 characters. A choice is pressed by its value, so if the list changes before you pick, the request still goes to the one you picked, or not at all if it's gone. With nothing to choose, or two choices with the same value, the button is dimmed and its tooltip says why. current ticks the choice the answer holds, as on a fixed menu. A menu made from the answer stays in the panel: Spotlight, Shortcuts and notifications don't offer it, since its choices change. It can't go on a row or a checklist's itemAction.

  • Or send a time. Some services want a moment in the request, such as when a silence or a snooze ends. In a body, {action.at} is the moment of the press and {choice|from_now} is the moment a menu's number of seconds from then, both in ISO 8601 UTC (2026-11-17T20:41:05Z). Grafana's Silence menu sends both:

    json
    { "label": "Silence", "icon": "bell.slash", "path": "/api/alertmanager/grafana/api/v2/silences",
      "body": { "matchers": [{ "name": "__alert_rule_uid__", "value": "{param.uid}", "isEqual": true, "isRegex": false }],
                "startsAt": "{action.at}", "endsAt": "{choice|from_now}", "createdBy": "Legato", "comment": "Silenced from Legato" },
      "choices": [{ "label": "1 hour", "value": 3600 }, { "label": "1 day", "value": 86400 }, { "label": "1 week", "value": 604800 }] }

    {action.at} goes wherever {action.id} does, on a card's buttons and a row's. from_now reads any number of seconds, so {answer.snooze|from_now} works too.

  • Part them into runs. Put "|" between two buttons in actions to start a new run of them: the panel draws a thin upright line between the runs that show, as in Lock, Sentry | climate, defrost, steering wheel heat | seats. A run whose buttons are all hidden leaves no line. A card holds up to six buttons, or sixteen in its corner (the "|" don't count), so one Controls card can carry a car's on/off pairs, one of each showing at a time.

  • Or centre the row. "actions_align": "center" on the card centres the row of buttons under it; the card's label and lines stay where they are. It suits a card that is mostly its buttons, such as a row of scenes. "leading" is the default.

json
"actions": [
  { "label": "Pause 5m", "icon": "pause.fill", "method": "POST", "path": "/api/dns/blocking",
    "body": { "blocking": false, "timer": 300 }, "when": { "path": "blocking.blocking", "equals": "enabled" } },
  { "label": "Resume", "icon": "play.fill", "method": "POST", "path": "/api/dns/blocking",
    "body": { "blocking": true, "timer": null }, "when": { "path": "blocking.blocking", "equals": "disabled" } }
]
Field
kindoptionalhttp (the default) calls the service, as below. open opens an address instead; see after this table. add-event opens a New Event form on a calendar source's card; see Calendar sources. complete-reminder works only as a checklist's itemAction; see Reminders sources.
labelrequired1–24 characters. It can show a value from the answer, {answer.name}; see Buttons that act on what the card shows.
iconoptionalAn SF Symbol name.
methodoptionalPOST (the default), PUT, PATCH, DELETE or GET. Use GET only for a service that takes a command that way, such as changedetection.io's ?recheck=1. A GET sends no body or form, so its values go in the path's query.
pathrequiredStarts with /, and is added to the source's scheme, host and port. It can't name another host. {answer.<path>} fills a value from the card's answer.
bodyoptionalA JSON body. Its strings can take {answer.<path>} too.
graphqloptionalA GraphQL request in place of body: { "query": "…", "variables": { … } }. See Buttons that send GraphQL.
formoptionalA form in place of a JSON body, for services whose commands read only a form: { "hashes": "all" }. See Buttons that send a form.
headersoptionalExtra headers for the button request, as { "name": "value" }. Common source headers are inherited; button headers can override them. Keep credentials in a named secret.
whenoptionalShow the button only when the source's last answer meets a condition, such as { "path": "blocking.blocking", "equals": "enabled" }. With it, a card can offer Pause while blocking is on and Resume while it's paused.
successoptionalA condition checked against the button's JSON response, such as { "path": "result", "equals": true }. Use this when HTTP success alone does not mean the service accepted the command.
erroroptionalA path to the failure reason in the button's response, such as "reason".
prominentoptionaltrue draws the button filled in the accent colour. Use it for the one that matters most right now, such as Stop climate while the climate runs. Off by default.
confirmoptionalAsk in the panel before the request goes out: true asks the label with a question mark, or { "message", "button", "type" } gives the question (up to 160 characters), the button that runs it (up to 24) and text to type first (up to 40), each optional; the question and the text to type can take {answer.<path>}. See Buttons that ask first.
timeoutoptionalHow long the request may take, in seconds: 60 (the default) to 1800. For a service that works only while the request stays open, such as Ollama, which stops downloading a model when the request closes. The button spins until the service answers. A button with more than 60 is pressed only in the panel: Spotlight, Shortcuts and notifications don't offer it.
inputsoptionalAsk for what to send: 1 to 4 fields, typed text or a pick from a list, filled into the request as {input.<name>}. A press opens a form in the page's place. See Buttons that ask for text. On an open button, the form opens one of your pages with what was typed, such as a search: see Forms that open a page.
submitoptionalWith inputs: the form's own button, up to 24 characters. "Add" unless set.
ruleoptionalLegato presses the button itself: { "when": …, "every": "6h" }. See Buttons that press themselves.
shownoptionalfalse, with a rule: the button isn't drawn or offered anywhere, and only its rule presses it.
  • A card can have up to 6 buttons; give them when conditions so only the ones that fit the state show at once. They're hidden until the source has answered once, since what a button means can depend on the state.
  • A button runs only when you click it, and only on this Mac. While it runs it shows a spinner; a press may take up to a minute, since a car has to wake up first, for example, or as long as its timeout. After an accepted command the source checks again at once, and again 2, 5, 20 and 60 seconds later.
  • HTTP success means the request reached the service successfully. A configured success condition decides whether the response reports a successful command. Without that condition, result: false or response.result: false is treated as failure automatically; other HTTP 2xx responses are accepted. A failure reason appears under the card for two minutes.
  • Command acceptance does not prove the device has changed state yet. The follow-up reads update the card with the service's latest state; those reads can themselves fail or report the old state.
  • A button needs a source on the same card: it calls that source's service, signed in the same way. A card with written-in values can't carry one.

Buttons that press themselves

A rule presses a button for you. Each time the card's source answers, Legato checks the rule's when against the answer, derived values included. When it holds, and the time in every has passed since the rule last pressed, the button is pressed the way a click presses it, with the same checks. A press that fails waits the same every before the next try. Rules run only while Legato is open and the Mac is awake.

This suits upkeep you'd otherwise have to remember, such as asking a bank to sync once its last full sync is 12 hours old:

json
{ "label": "Sync banks", "method": "POST", "path": "/v2/plaid_accounts/fetch", "shown": false,
  "rule": { "when": { "path": "age", "gte": 12 }, "every": "6h" } }

every is at least 15m. With "shown": false, only the rule presses the button: it isn't drawn on the card or offered to Spotlight, Shortcuts or notifications. Leave shown out to keep the button on the card as well. A rule can't go on a button that asks first (confirm), takes inputs or choices, or sits on a row. Details lists the page's rules under Rules, with when each last ran and whether the press went through.

Buttons that send GraphQL

A service with a GraphQL API takes every change as a mutation sent to one address. Give the button graphql in place of body, and it sends { "query": …, "variables": … } there. This button marks an issue done in an issue tracker:

json
{ "label": "Done", "icon": "checkmark", "path": "/graphql",
  "graphql": {
    "query": "mutation($id: String!, $state: String!) { issueUpdate(id: $id, input: { stateId: $state }) { success } }",
    "variables": { "id": "{answer.issue.id}", "state": "{answer.done_state}" } },
  "success": { "path": "data.issueUpdate.success", "equals": true } }
  • query goes exactly as written. Its braces belong to GraphQL, so Legato never fills anything in it. Put each value in variables and use it in the query as $name. A query holding {answer.…}, {input.…}, {action.id} or {param.…} won't load, since it would go out unfilled; nor will {choice} in a menu's query.
  • variables is filled like a body in that kind of button: {answer.…} on a card's button, {choice} on a menu, {input.…} from a form, a row's own fields on a row's button or a checklist's itemAction. A string that is one placeholder alone keeps its type, so a number stays a number for an Int!. Leave variables out for a mutation that takes none.
  • The request is always a POST to path. A button can't have graphql and body together, and it can't follow a task with completion.
  • A GraphQL service usually answers HTTP 200 even when it refuses, so any errors in the answer fails the press, with the first one's message as the reason, even when data came back as well, since part of the mutation may not have run. An answer with no data fails too. Legato doesn't send the press again, with one exception: on a source that signs in for a session, a press refused with HTTP 401 goes once more after signing in again, since the service ran nothing. success then checks data the way it checks any answer.
  • A query the service can't read often gets HTTP 400 with errors; the first message is the reason shown.

Buttons that send a form

Some services read a command's values only from a web form (application/x-www-form-urlencoded), not from JSON. qBittorrent is one. Give the button form in place of body, and it sends each field as name=value. This row button stops a torrent in qBittorrent:

json
{ "label": "Stop", "icon": "stop.fill", "path": "/api/v2/torrents/stop",
  "form": { "hashes": "{hash}" } }
  • form is an object of 1 to 20 fields. Each value is text, a number or true/false, and is filled like a body in that kind of button: {answer.…} on a card's button, {choice} on a menu, {input.…} from a form, a row's own fields on a row's button or a checklist's itemAction.
  • Each value goes as text: a number as its digits (1048576, never 1,048,576), true and false as words. A value filled with a list or an object can't be sent, and the press fails.
  • An empty optional {input.…} leaves its field out, as in a JSON body. A field written as "" goes as name=.
  • The fields go in name order, and the request's Content-Type is always the form's: a Content-Type in the source's or the button's headers doesn't change it.
  • A form request never follows a redirect.
  • The method is POST (the default), PUT or PATCH. A button can't have form with body or graphql.