The Octave Developer Hub

Welcome to the Octave developer hub. You'll find comprehensive guides and documentation to help you start working with Octave as quickly as possible, as well as support if you get stuck. Let's jump right in!

Get Started

Setting a Value From an Edge Action

This topic describes how to create and set a value from an edge action.

When writing the logic for an Edge Actions, you will typically begin by reading the Event data that has been Observed, and then set a value (e.g., active an Output (Actuator), display a status, etc.). This topic describes how to set that value in your Action Script's logic.

The following example illustrates an Edge Action that monitors the light sensor included on the Octave Edge Devices, computes the luminosity, and sends the result to the third line of the device's LCD screen.

  1. Create an Observation for the mangOH Red's /redSensor/light/value sensor resource and configure the Observation to send events to an Edge Action.
  2. Create an Edge Action with the following code:
function (event) {
  var lightReading = event.value;
  var lightDescription;

  if (lightReading > 1500) {
    lightDescription = "bright"
  } else if (lightReading > 300) {
    lightDescription = "a bit dim"
  } else {
    lightDescription = "dark"
  }

  var s = "It's " + lightDescription + " in here.";

  return {
    "dh://lcd/txt3": [s]
  }
}

The code reads the light value, concatenates it with some text describing the brightness, and then writes the string to the /lcd/txt3 Resource (third line of LCD screen).

Writing text to the LCD screen is accomplished by returning the string to the Data Hub which is indicated with dh:. For additional information see the Edge Action Runner Reference.

  1. Click Save. The logic has now been sent to the Octave Edge device and will execute when an Event from an Observation is received by the Edge Action.

📘

Return syntax

The returned object can include several paths, so several Resources can be updated from a single edge action.

Also, the Action Runner expects an array of objects for each path. As a consequence, even your script provides only one value, you must use the syntax "dh://resource_path": [ resource_value ].
Of course, the value you provide can itself be an array.

Updated 4 months ago


Setting a Value From an Edge Action


This topic describes how to create and set a value from an edge action.

Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.