For the complete documentation index, see llms.txt. Markdown versions of documentation pages are available by appending .md to page URLs.
Skip to content

Widget data (onInfo / onData)

Read a Custom Metric widget's variables and values with useWidgetEvents — onInfo descriptors and onData values, joined by variableId

The widget receives its data through useWidgetEvents(). onInfo carries the descriptors: what to render and how it looks. onData carries the values. Join them by variableId.

GET

useWidgetEvents() returns:

{ onInfo, onData, onReady, onError, emitWidgetEvent, onWidgetEvent, onAnyWidgetEvent, widgetId }

Every on* subscriber returns an unsubscribe function. Return it from the useEffect.

onInfo(cb): the descriptors

It fires on load and whenever the widget's settings or devices change.

{
  templateId,
  variables: [{ id, label, name, unit, icon, color, aggregationMethod, span }],
  devices: [{ id, label, name }] // the devices that OWN the configured variables
}

onData(cb): the values

The payload has the same shape on the initial load and on every real-time tick.

{
  start, // ISO 8601 string (e.g. "2025-01-01T00:00:00.000Z") or undefined
  end, // ISO 8601 string or undefined
  results: [{ variableId, deviceId, value, timestamp }]
  // timestamp -> epoch ms (number); value -> number or null
}

How to implement: render the configured variables

Render adaptively: derive scales, ranges and colors from the values you receive, and recompute them on each onData tick so real-time updates are reflected automatically.

Last updated

Was this helpful?