Script API Reference
All functions and objects available in the Muxit script sandbox.
Device Access
| API | Description |
|---|---|
connector(name) | Get a device proxy by name |
device(name) | Alias for connector() |
javascript
const psu = connector("psu");
await psu.voltage() // read property
await psu.voltage(12) // write property
await psu.reset() // execute action
await psu.rampTo(24) // call custom methodLogging
| API | Description |
|---|---|
log.info(msg) | Info-level log |
log.warn(msg) | Warning-level log |
log.error(msg) | Error-level log |
log.debug(msg) | Debug-level log |
console.log(msg) | Alias for log.info() |
Events
| API | Description |
|---|---|
emit(event, data) | Publish event (namespaced as script:<event>) |
on(event, handler) | Subscribe to events (auto-cleaned on stop) |
stream(connector, stream, data) | Emit stream data to dashboards |
Timing
| API | Description |
|---|---|
delay(ms) | Async sleep (abortable on stop) |
timestamp() | Current ISO 8601 UTC string |
AI
| API | Description |
|---|---|
ai(prompt) | Single-shot LLM call, returns string |
ai(prompt, image) | LLM call with vision (image analysis) |
say(text) | Send message to Chat Panel (spoken via TTS) |
Script Lifecycle
| API | Description |
|---|---|
script.running | true while active, false after stop |
script.name | This script's filename (without .js) |
Standard Globals
Math, JSON, Date, parseInt, parseFloat, isNaN, isFinite, Number, String, Boolean, Array, Object, Map, Set, Promise
Not Available
require, import, fs, process, net, http, child_process, eval, Proxy, Reflect, global, globalThis
For detailed explanations and examples, see the Script Guide.