Skip to content

MQTT

The editor talks to a panel over MQTT. You can send the same messages from anything that speaks MQTT, which is how a script gets wired to a sensor, a web page or a home-automation rule.

You need a broker address and a credential that is allowed to reach your panel. The editor gets one for you when you sign in; its Use a custom connection instead section accepts your own for a local setup.

Every panel has an ID of 12 hex characters. Its topics are:

Topic Direction Carries
ledpanel/<ID>/command To the panel Commands, as JSON
ledpanel/<ID>/script From the panel The result of loading or running a script
ledpanel/<ID>/status From the panel Whether the panel is online
{"cmd": "set_script", "name": "my_script", "source": "function _draw() gfx.cls(0, 0, 40) end"}

source is the whole Lua script as one JSON string, up to 24 KB. name is what the panel calls it in replies and error messages: letters, digits, _ and -, up to 32 characters.

The panel answers on the script topic:

{"ok": true, "name": "my_script"}
{"ok": false, "name": "my_script", "error": "[string \"my_script\"]:3: attempt to call a nil value"}

A script that fails later, while running, is reported on the same topic.

To send a compiled shader, send the script with its shader = gfx.shader("...") line already appended. The editor’s Compiled setting produces exactly that text.

One at a time:

{"cmd": "set_uniform", "name": "speed", "value": 2}

Or several:

{"cmd": "set_uniforms", "uniforms": {"speed": 2, "tint": [1, 0.8, 0.6]}}

A number becomes a number in the script’s uniforms table; a list of two to four numbers becomes a vector. The values arrive at the start of the next frame.

{"online": true, "enabled": true}

online turns false when the panel drops off the broker. enabled is false when its display is switched off.