Edge Workflows

Edge Workflows run on your own gateway hardware and are executed by Losant’s Gateway Edge Agent. They provide additional nodes and triggers specifically designed to interface with local peripherals and data sources. They can run without an internet connection and will buffer any reported data while offline. They are versioned independently.

Edge Workflow

Advantages

When choosing a workflow type, there are a few benefits of edge workflows to consider …

  • Since edge workflows execute on their deployed devices, network latency issues are mitigated. If a snap decision needs to be made locally on the device (for example, shut its attached machine down if vibration levels exceed a certain threshold), that decision is no longer dependent on the device having an internet connection.
  • Any payloads that the device should send up to the Losant platform are queued and sent up the next time the device establishes a connection. This allows for devices to be deployed in the field where internet connectivity may be sparse; it also allows for battery conservation as the device needs only to connect intermittently to report its collected data.
  • Edge workflows have a few special nodes that allow for reading and writing to the device’s file system, executing scripts and interacting with connected devices such as Modbus.

Limitations

The main limitation of edge workflows is a lack of functionality that is available within application workflows. For example, edge workflows cannot edit Losant resources or send messages through email or SMS (without using the SendGrid, Mailgun, or Twilio Nodes).

Also, changing or removing an edge workflow from a device requires the device to have an internet connection, which means that workflows deployed to edge devices could continue executing previously deployed versions until those devices establish a connection to the Losant platform.

Configuration

There are a few configuration options that are specific to edge workflows.

Workflow Storage

Edge Workflows Storage Tab

You may still use the Storage: Get Value and Storage: Set Value Nodes in an edge workflow; however, the values are specific to each device where the workflow is deployed, and there is no way to tell what the current values stored on the device are. Therefore, the workflow storage tab offers no way to view or set storage values for edge workflows.

Debugging

Debug Node Choose Device

When debugging edge workflows, it is necessary to choose a single device to view debug output from. This requires the device to have a version of the workflow deployed to it and to have an internet connection at the time you wish to debug. You may switch the selected device at any time.

Gateway Edge Agent Version

Workflow Gateway Edge Agent Tab

In order to utilize newly released edge workflow functionality (such as new nodes), it is necessary to upgrade your workflow’s Gateway Edge Agent version – and to deploy the new agent to your Edge Compute devices.

To do this, use the Agent Version tab in the workflow editor. The upgrade can only be applied to the “develop” version. If you upgrade the GEA version and make changes to your “develop” workflow, you will have to create new versions of the workflow before deploying them to your devices.

Payload

The fields on a triggering payload for an edge workflow are very similar to what is available on an application workflow, with a few edge-only additions. The following are the initial root fields on all edge payloads:

  • agentEnvironment is an object of the current environment variables for the Gateway Edge Agent (minus any GEA configuration environment variables). This is unique to edge workflows, and only available in GEA version 1.2 or greater.
  • applicationId is the Losant ID of the application that the Edge Compute device (and the workflow) belong to.
  • applicationName is the name of the Losant application that the Edge Compute device (and the workflow) belong to.
  • data is an object with trigger-specific data. The contents of this object change significantly based on the workflow trigger.
  • deviceId is the Losant ID of the Edge Compute device.
  • deviceName is the name of the Edge Compute device.
  • deviceTags is an object of the tags for the Edge Compute device.
  • flowId is the Losant ID of the current workflow that is running.
  • flowName is the name of the current workflow that is running.
  • flowVersion is the version of the current workflow that is running.
  • globals is an object of any workflow or application globals available within the workflow.
  • isConnectedToLosant is a boolean representing if the device is currently connected to Losant. This is unique to edge workflows, and only available in Gateway Edge Agent version 1.2 or greater.
  • time is the timestamp of the current workflow run.
  • triggerId is the Losant ID of the trigger that caused this workflow run.
  • triggerType is the type of trigger that caused this workflow run.

Saving and Deploying

Unlike application workflows and experience workflows, saving and deploying edge workflows are two separate actions, and saving a workflow is not enough to propagate the changes to your edge devices unless utilizing a test device.

Deploy and Save Edge Workflow

Saving Changes

The “Save” button will be enabled whenever there are changes to your “develop” workflow version. When there are no pending changes, the button will be disabled. The button is only present when viewing the “develop” version and if you have edit permissions for the workflow in question.

Setting a Test Device

A test device can be configured for edge workflows that utilize GEA version 1.39.0 or greater. The convenience of setting a test device is that saved changes to the “develop” version will be automatically deployed to that device. This enables you to quickly and easily iterate over your “develop” version without needing to manually create new versions and re-deploy each time you make a change.

To set a test device, visit the form in the dropdown on the right side of the “Save” button or “Debug” in the side panel.

It’s important to note that only one device can be set as the test device for a workflow, but the option to change the test device exists in the dropdown.

More information on edge workflow test devices is available within the edge deployments documentation.

Deploying Versions

Any version of an edge workflow can be deployed by clicking the “Deploy” button in the top right corner. This will display a configuration modal for which devices to deploy the selected workflow to. If you are viewing the “develop” version when the “Deploy” button is clicked, you will have to create a new version as part of the process.

More information on deploying edge workflows is available within the edge compute documentation.

Deleting Edge Workflows

Edge workflows can be deleted directly by clicking the “Delete Flow” button at the bottom of the workflow’s Properties panel. They can also be deleted by clicking the “Delete” icon in your application’s workflow list.

Delete Workflow

Note that deleting an edge workflow - or a deployed version - will remove the workflow from all devices where it is deployed only once the device is connected to the platform. If the device is offline, it will continue to execute the workflow until it reconnects and receives the deletion message.

On-Disk Workflows

Edge workflows can also be placed directly onto your edge device’s local storage, so that they can potentially run before connecting to your application.

Workflow files for on-disk execution can be exported from edge flows within your application and placed in a directory on your device specified by your Gateway Edge Agent configuration. The default workflow directory is /data/workflows from the GEA’s root directory.

Due to the nature of these workflows, there are a few limitations to how you are able to interact with them:

  • Debugging: Since on-disk flows are not represented within your application, Debug Nodes will not be able to return any information. If you need to receive information from an on-disk flow execution, we recommend using an MQTT Output Node and listening for its response using an application workflow and an MQTT Trigger.
  • Deleting on-disk workflows: Because on-disk flows are loaded directly from your device’s local files, the only way to delete them is to remove them from the device itself.

Was this page helpful?


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