Skip to main content
Version: 0.1

system.gateway

system.gateway describes the gateway itself: version, uptime, modules and device connections. All three functions are gateway calls open to any role, so they work in screen, cron, console and module scripts, and not in an expression tag. See The system API for how calls run. The same facts are also published as @gateway tags (see Logs and diagnostics).

info​

info(): { version: string; uptimeSeconds: number; timeZone: string; startedAt: number }
FieldMeaning
versionThe gateway's version, as @gateway.version
uptimeSecondsSeconds since it started, as @gateway.uptime
timeZoneThe zone the gateway keeps time in: an IANA id, or UTC, as @gateway.tz
startedAtEpoch milliseconds of the start, computed from the uptime
var g = system.gateway.info();
return g.version + ' up ' + system.util.round(g.uptimeSeconds / 3600, 1) + ' h (' + g.timeZone + ')';

modules​

modules(): { id: string; name: string; version: string; state: string }[]

The installed modules with their package id (such as io.scadex.cron), display name, version and lifecycle state (see Modules).

var stopped = system.gateway.modules().filter(function (m) { return m.state !== 'running'; });
if (stopped.length) console.warn(stopped.map(function (m) { return m.id + ': ' + m.state; }).join('\n'));

connections​

connections(): { id: string; name: string; driver: string; state: "connected" | "connecting" | "disconnected" | "disabled" }[]

The device connections (OPC UA servers, MQTT brokers, other drivers) and whether they are connected. driver is the kind of connection (the group it is listed under in the gateway's connection tags); id is the connection's own segment in that group; name is the configured name, or the id when there is none. state is disabled for a connection that is switched off, connected when its driver reports it connected, connecting while the driver's own state says so, and disconnected otherwise.

var down = system.gateway.connections().filter(function (c) { return c.state === 'disconnected'; });
return down.length ? { toast: { message: down.length + ' connections down', variant: 'error' } } : undefined;