Creating an Edge Action
The creation of an Edge Action allows you to specify the logic that will run at the edge to handle an event from the Edge Action's associated sources. These sources vary, depending on the firmware version of the Octave edge device:
- Firmware 3.4+: Multiple Observations, Inputs, and Outputs.
- Firmware versions below 3.4: Single Observation.
An Edge Action is created using the Octave Dashboard which will send the Edge Action to the Octave edge device when saved.
The following steps demonstrate how to create an Edge Action:
- Navigate to Build > Device > Actions.
- Click Add Edge Action.
- Select the source(s):
- Firmware 3.4+: Click the Resources dropdown (1) to display the Resource list, then click on the Add resource field (2) in the first row to select a source. You can filter the dropdown by Outputs, Inputs, and Observations (3). You can repeat this step to add additional sources.
- Firmware versions below 3.4: Click Source Observation and select an Observation whose data is to be processed by the Edge Action.
- Click the edit icon next to New edge action near the top of the screen, and enter a descriptive name.
- Ensure Enabled on the right side of the screen has a checkmark.
- Click the Code tab and enter your JavaScript logic to run in the Edge Action (i.e., to read and/or set a value):
function(event) {
// Your code here…
}
This logic will run at the edge (i.e., on the Octave device) when Events from the underlying source(s) (selected in step 3) are received.
7. Click Save on the bottom right corner to save and apply the Edge Action.
Note
After saving the Edge Action, Octave will send it to the device when the device's connection is in the registered state. If the device is not in this state at the time of saving the Edge Action, Octave will store the Edge Action and send it to the device once it successfully connects.
This state is indicated by the /util/cellular/signal/status Utility Resource. For a complete list of device connectivity states see Cellular Signal Status Values.
Note
When an Edge Action is assigned to a Device, the JavaScript is sent to the Device and loaded. It is bound to specific source(s) (e.g., an Observation), such that when a new Event is created from the source(s), the JavaScript is executed with the Event as the input parameter.
Updated about 3 years ago