Skip to main content
Complete, copy-paste patterns using the Script API globals (widget, ws, storage, db, location, context). Drop any of these into a dashboard’s Script tab.

Live gauge from device data

Bind an incoming reading to a gauge, recolor it past a threshold, and show a dialog when it goes critical.

Two-way control (button → command → ack)

Send a command when a button is pressed, and reflect the device’s acknowledgement.

Toggle a relay from a switch

Remember a user’s choice

Persist a selection and restore it next time the dashboard loads.

Save a form to the database

Render the latest reading

Periodic refresh

Throttle rapid slider changes

Avoid flooding the device while a user drags a slider.

Responsive & role-aware UI

Location-tagged report

Track button hold duration

push and release bracket a press — time it and branch on the duration.

Persistent click counter

storage survives reloads — count across sessions and unlock at a milestone.

Animate a widget

Move a widget across the canvas with a timer and widget.move.

Live clock label

Handle text-input submit

change fires with the raw value; submit fires with { value } — read data.value.

Pull from an external API

fetch is available in the sandbox — combine external data with your widgets.

Query with operator filters

db.query supports comparison operators, not just equality.

Clean up on destroy

Keep unsubscribe functions and release them when the widget is torn down.

API overview

Every global these recipes use.