> ## Documentation Index
> Fetch the complete documentation index at: https://docs.coreflux.org/llms.txt
> Use this file to discover all available pages before exploring further.

# Actions & Events

> Reacting to clicks and value changes — publishing commands and navigating between panels.

![An operator control panel with Start and Stop Conveyor buttons and a speed setpoint field, each wired to an event handler that publishes commands](https://mintcdn.com/coreflux/ry-30sFxFVWzN72U/images/dashboard/patterns/control-panel.png?fit=max\&auto=format\&n=ry-30sFxFVWzN72U\&q=85\&s=7bf104e56761bbaae30067a2eab551dc)

A control panel in action: each control fires an ON event that publishes back to the broker

Events make a panel interactive: a click publishes a command, a field change writes a setpoint. The pattern is always `ON <EVENT> DO <ACTION>`.

> [!TIP]
>
> **Like a light switch wired to more than a light.** Flipping it (the event) can turn on the lamp, ring a bell, and log the time (the actions) — the switch doesn't care what's wired to it.

***

First the event triggers, then each action you can wire to them. The broker parses this grammar; which triggers the HUB actually dispatches, and any write-back caveats, are documented with the [input components](https://docs.coreflux.org/hub/dashboards/components/inputs.md) — that catalog ships with the HUB, not the broker.

## Event triggers

| Event | Fires when |
| - | - |
| `ON CLICK DO` | Mouse click / tap |
| `ON CHANGE DO` | Value changed (`text-field`, `number-field`) |
| `ON TOGGLE DO` | Toggle state changed — see [input components](https://docs.coreflux.org/hub/dashboards/components/inputs.md) for HUB write-back support |

## Actions

### Publish to a topic

The workhorse: send a command or value to any MQTT topic.

```lot wrap theme={"theme":{"light":"css-variables","dark":"css-variables"},"languages":{"custom":["/languages/lot.json"]}}
ON CLICK DO
    PUBLISH TOPIC "factory/commands/start" WITH 1
```

Literal payloads on buttons work out of the box. On `text-field` and `number-field`, use `WITH VALUE` to publish what the operator typed — see the [Input components](https://docs.coreflux.org/hub/dashboards/components/inputs.md) page for full write-back examples.

### Navigate between panels

Jump to another panel by name:

```lot wrap theme={"theme":{"light":"css-variables","dark":"css-variables"},"languages":{"custom":["/languages/lot.json"]}}
ON CLICK DO
    NAVIGATE TO PANEL "Zone1Details"
```

Or return to the previous panel:

```lot wrap theme={"theme":{"light":"css-variables","dark":"css-variables"},"languages":{"custom":["/languages/lot.json"]}}
ON CLICK DO
    NAVIGATE BACK
```

See the [Navigation section in Defining a Panel](https://docs.coreflux.org/v2.22/lot-language/panels/defining-panels.md#navigation) for a complete overview-and-detail example with screenshots.

### Wait on a button

A click can start work that finishes later, such as an agent briefing. `SET AWAIT` names the components that should show progress, and `SET AWAIT_TIMEOUT` sets how long to wait.

The button stays busy after the click. Each id in `SET AWAIT` shows a pending indicator until that component's next message. If nothing arrives in time, the panel shows a timeout note. The wait is 120 seconds when you omit `SET AWAIT_TIMEOUT`.

Ids are the names from `ADD COMPONENT`, separated by commas inside one quoted string.

This panel asks for a briefing and waits on the text that will show it:

```lot wrap theme={"theme":{"light":"css-variables","dark":"css-variables"},"languages":{"custom":["/languages/lot.json"]}}
DEFINE PANEL SiteBriefing
WITH VISIBILITY PUBLIC
WITH STATE PUBLISHED
WITH TITLE "Site briefing"
WITH LAYOUT "vertical"

    ADD COMPONENT "AskBrief" WITH TYPE "button"
        SET LABEL "Refresh briefing"
        SET AWAIT "Briefing"
        SET AWAIT_TIMEOUT 30
        ON CLICK DO
            PUBLISH TOPIC "site/briefing/refresh" WITH 1

    ADD COMPONENT "Briefing" WITH TYPE "text"
        BIND CONTENT TO TOPIC "site/briefing"
```

`SET AWAIT "Briefing, StatusLamp"` waits on two components. The same clauses are listed with the [button properties](https://docs.coreflux.org/hub/dashboards/components/inputs.md#button).

## Common mistakes

> [accordion] The control shows data but does nothing when used
>
> Input components don't publish by themselves — the `ON <EVENT> DO` handler does. A button without `ON CLICK DO PUBLISH ...` is a label in practice.

> [accordion] The handler runs but nothing changes on the panel
>
> `PUBLISH` writes to the broker; the panel only reflects it if some component **binds** to that topic. Check the bound topic and the published topic match (command vs. feedback topics are often intentionally different).

## Next Steps

> [card] [Input & control components](https://docs.coreflux.org/hub/dashboards/components/inputs.md)
>
> The controls that fire these events, with full write-back examples.

> [card] [Common patterns](https://docs.coreflux.org/hub/dashboards/patterns.md)
>
> Complete panels that put events and actions to work.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.