Agent Config: Set Node

The Agent Config: Set Node allows you to change the configuration settings for an instance of the Gateway Edge Agent. This is accomplished by updating the TOML configuration file and restarting the agent. This node is only available in edge workflows.

Note that any options or configurations already specified as command line flags or environmental variables in the Gateway Edge Agent’s docker run command will take precedence over changes made to the configuration file using this node.

Agent Config: Set Node

Configuration

There is one main configuration section for this node:

Agent Config: Set Node Configuration

New Configuration

Specify the new configuration fields for your device. The new configuration options will always be merged with the existing configuration.

  • Individual Fields: You can input values for specific fields that can be filled in using individual string templates.
  • JSON Template: This option takes a JSON template string that can be parsed into a JSON object that validates against all valid configuration settings.
  • Payload Path: This option takes a payload path to an object on the current payload and applies it as the new configuration. The object must validate against all valid configuration settings.

Providing a null or undefined configuration value will remove that option and reset it to its default value if it has one.

JSON Template and Payload Path objects can be passed in two different forms:

  • As a deeply nested object:

    { "gateway": { "id": <deviceId>, "secret" : <deviceSecret> }  }
  • As a flattened object:

    { "gateway.id": <deviceId>, "gateway.secret": <deviceSecret> }

Note: It is possible to use this node to write a configuration file that, while technically valid, will result in a non-working Gateway Edge Agent—such as by configuring gateway.id to a device ID that does not exist, or by setting webserver.enabled to false.

In the case that something like this happens, you can fall back on configuring the agent through environment variables (which always take priority over the configuration file), or by manually rewriting the configuration file on the device.

Result

Optionally, you may specify a payload path for where the result of the write operation should be stored.

Agent Config: Set Node Result

Node Example

In the example above, the workflow will set your config options based on the object at working.edgeConfig on the payload.

If the write operation was successful, your output would look like the following:

{
  "working": {
    "result": { "success": true }
  }
}

A success result means the new configuration has been written to your GEA configuration, but the new configuration will not be applied until all currently running workflows are finished.

If you provide invalid configurations, the result will also contain an error field:

{
  "working": {
    "result": {
      "error" : {
        "message": "The following configuration errors were found:\nThe provided Device Id (notAnId)) is invalid",
        "type": "LosantAgentConfigurationError"
      },
      "success": false
     }
  }
}

Was this page helpful?


Still looking for help? You can also search the Losant Forums or submit your question there.