Skip to main content

Node configuration

A node's configuration is the description its firmware publishes: which devices and services it has, what parameters each carries, and metadata such as model and firmware version. getConfig() reads the snapshot the SDK is holding, sync() fetches a fresh one, and delete() removes the node from the account.

Read the current snapshot

const config = node.getConfig();

console.log(config.info?.fw_version);
console.log(config.devices.length);

getConfig() returns NodeConfig synchronously; it does not touch the network. It is the last snapshot loaded, whether that came from the cache or from a sync().

NodeConfig carries the node's info block, config_version, data_model, attributes, params and the live devices and services arrays. Only fw_version is guaranteed inside info; type, model and name are optional, and a deployment may pass extra keys through, so read anything else defensively.

Fetch a fresh configuration

await node.sync();

sync() returns Promise<ESPRMNeoNode>, the same instance, updated. It fetches from the cloud, applies the result to the node, rebuilds devices and services, and writes the new snapshot to the local cache.

sync rebuilds devices and services

Rebuilding replaces the ESPRMNeoDevice, ESPRMNeoService and parameter instances with new objects. Any reference you were holding to a device or parameter points at the old graph after a sync and will no longer receive updates. Re-read them from node.devices and node.services afterwards.

You rarely need to call sync() on a schedule. The node does it for you when the cloud signals that its configuration version changed, which is how a firmware update that adds a parameter shows up without app intervention.

Cached versus live reads

The cache is what makes list screens fast. It applies when the node is fetched, not when the config is read:

CallBehaviour
group.getNode(id)Cache first, cloud if absent
group.getNode(id, { cache: false })Always cloud, refreshes cache
node.getConfig()No network, ever
node.sync()Always cloud, refreshes cache

Cached configurations are cleared on logout().

Delete a node

await node.delete();

delete() returns Promise<ESPAPIResponse> and fully disassociates the node from the account, addressing it at its root group. It is the same operation as rootGroup.removeNode(nodeId).

To take a node out of one room but keep it, call removeNode() on the subgroup instead. See Manage groups.

The instance is stale afterwards. Before dropping the last reference, stop its subscription so nothing is left behind:

node.unsubscribeFromMqttUpdates();

unsubscribeFromMqttUpdates() returns void. It unregisters the node from the MQTT orchestrator, removes its shadow listeners, and unsubscribes the shared topics if no other node still needs them. It does not clear local storage or the config cache.

Connectivity

if (node.connectivityStatus.isConnected) {
// the node is reachable over the cloud
}

connectivityStatus carries isConnected and lastConnectionTimestamp. It is seeded from the configuration when the node is built and then kept current by shadow updates.

Connectivity drives reachability directly: when a node reports online the SDK adds its mqtt transport, and removes it when the node goes offline. A node with no transport left cannot be read or written. See Transports.

Method summary

MethodReturns
getConfig()NodeConfig, synchronous
sync()ESPRMNeoNode
delete()ESPAPIResponse
unsubscribeFromMqttUpdates()void

applyNodeConfig(config) is also public. It replaces the configuration and rebuilds the device and service instances from a raw payload, and sync() calls it after a fetch. Applications should not call it directly; pushing a hand-built payload through it desynchronises the node from the cloud without any request being made.